1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
|
%!PS-Adobe-3.0
%%Creator: groff version 1.09
%%CreationDate: Sat Feb 24 21:37:20 1996
%%DocumentNeededResources: font Times-Bold
%%+ font Times-Italic
%%+ font Times-Roman
%%+ font Courier
%%+ font Symbol
%%DocumentSuppliedResources: file manual-er.eps
%%+ file manual-files.eps
%%+ file manual-arch.eps
%%+ procset grops 1.09 0
%%Pages: 84
%%PageOrder: Ascend
%%Orientation: Portrait
%%EndComments
%%BeginProlog
%%BeginResource: procset grops 1.09 0
/setpacking where{
pop
currentpacking
true setpacking
}if
/grops 120 dict dup begin
/SC 32 def
/A/show load def
/B{0 SC 3 -1 roll widthshow}bind def
/C{0 exch ashow}bind def
/D{0 exch 0 SC 5 2 roll awidthshow}bind def
/E{0 rmoveto show}bind def
/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
/G{0 rmoveto 0 exch ashow}bind def
/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/I{0 exch rmoveto show}bind def
/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
/K{0 exch rmoveto 0 exch ashow}bind def
/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/M{rmoveto show}bind def
/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
/O{rmoveto 0 exch ashow}bind def
/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/Q{moveto show}bind def
/R{moveto 0 SC 3 -1 roll widthshow}bind def
/S{moveto 0 exch ashow}bind def
/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
/SF{
findfont exch
[exch dup 0 exch 0 exch neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/MF{
findfont
[5 2 roll
0 3 1 roll
neg 0 0]makefont
dup setfont
[exch/setfont cvx]cvx bind def
}bind def
/level0 0 def
/RES 0 def
/PL 0 def
/LS 0 def
/PLG{
gsave newpath clippath pathbbox grestore
exch pop add exch pop
}bind def
/BP{
/level0 save def
1 setlinecap
1 setlinejoin
72 RES div dup scale
LS{
90 rotate
}{
0 PL translate
}ifelse
1 -1 scale
}bind def
/EP{
level0 restore
showpage
}bind def
/DA{
newpath arcn stroke
}bind def
/SN{
transform
.25 sub exch .25 sub exch
round .25 add exch round .25 add exch
itransform
}bind def
/DL{
SN
moveto
SN
lineto stroke
}bind def
/DC{
newpath 0 360 arc closepath
}bind def
/TM matrix def
/DE{
TM currentmatrix pop
translate scale newpath 0 0 .5 0 360 arc closepath
TM setmatrix
}bind def
/RC/rcurveto load def
/RL/rlineto load def
/ST/stroke load def
/MT/moveto load def
/CL/closepath load def
/FL{
currentgray exch setgray fill setgray
}bind def
/BL/fill load def
/LW/setlinewidth load def
/RE{
findfont
dup maxlength 1 index/FontName known not{1 add}if dict begin
{
1 index/FID ne{def}{ pop pop}ifelse
}forall
/Encoding exch def
dup/FontName exch def
currentdict end definefont pop
}bind def
/DEFS 0 def
/EBEGIN{
moveto
DEFS begin
}bind def
/EEND/end load def
/CNT 0 def
/level1 0 def
/PBEGIN{
/level1 save def
translate
div 3 1 roll div exch scale
neg exch neg exch translate
0 setgray
0 setlinecap
1 setlinewidth
0 setlinejoin
10 setmiterlimit
[] 0 setdash
/setstrokeadjust where{
pop
false setstrokeadjust
}if
/setoverprint where{
pop
false setoverprint
}if
newpath
/CNT countdictstack def
userdict begin
/showpage{} def
}bind def
/PEND{
clear
countdictstack CNT sub{end}repeat
level1 restore
}bind def
end def
/setpacking where{
pop
setpacking
}if
%%EndResource
%%IncludeResource: font Times-Bold
%%IncludeResource: font Times-Italic
%%IncludeResource: font Times-Roman
%%IncludeResource: font Courier
%%IncludeResource: font Symbol
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
/Courier@0 ENC0/Courier RE/Times-Roman@0 ENC0/Times-Roman RE
/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
%%EndProlog
%%Page: 1 1
%%BeginPageSetup
BP
%%EndPageSetup
/F0 20/Times-Bold@0 SF(The)167.817 255.4 Q/F1 19/Times-Bold@0 SF
(POSTGRES)5 E F0(95 User Manual)A/F2 11/Times-Bold@0 SF -1.1(Ve)231.7
268.6 S(rsion 1.0 \(September 5, 1995\))1.1 E/F3 11/Times-Italic@0 SF
(Andr)247.958 308.2 Q .33 -.165(ew Y)-.407 H 2.75(ua)-.847 G(nd J)-2.75
E(olly Chen)-.275 E(\(with the)243.736 321.4 Q/F4 10/Times-Italic@0 SF
(POSTGRES)2.75 E F3(Gr)2.75 E(oup\))-.495 E(Computer Science Div)220.557
334.6 Q(., Dept. of EECS)-.814 E(Univer)227.141 347.8 Q
(sity of California at Berk)-.11 E(ele)-.11 E(y)-.33 E .32 LW 76 493.2
72 493.2 DL 80 493.2 76 493.2 DL 84 493.2 80 493.2 DL 88 493.2 84 493.2
DL 92 493.2 88 493.2 DL 96 493.2 92 493.2 DL 100 493.2 96 493.2 DL 104
493.2 100 493.2 DL 108 493.2 104 493.2 DL 112 493.2 108 493.2 DL 116
493.2 112 493.2 DL 120 493.2 116 493.2 DL 124 493.2 120 493.2 DL 128
493.2 124 493.2 DL 132 493.2 128 493.2 DL 136 493.2 132 493.2 DL 140
493.2 136 493.2 DL 144 493.2 140 493.2 DL 148 493.2 144 493.2 DL 152
493.2 148 493.2 DL 156 493.2 152 493.2 DL 160 493.2 156 493.2 DL 164
493.2 160 493.2 DL 168 493.2 164 493.2 DL 172 493.2 168 493.2 DL 176
493.2 172 493.2 DL 180 493.2 176 493.2 DL 184 493.2 180 493.2 DL 188
493.2 184 493.2 DL 192 493.2 188 493.2 DL 196 493.2 192 493.2 DL 200
493.2 196 493.2 DL 204 493.2 200 493.2 DL 208 493.2 204 493.2 DL 212
493.2 208 493.2 DL 216 493.2 212 493.2 DL/F5 7/Times-Roman@0 SF
(POSTGRES)93.6 505.2 Q/F6 8/Times-Roman@0 SF .461(95 is cop)B .461
(yright \251 1994-5 by the Re)-.08 F .461(gents of the Uni)-.12 F -.12
(ve)-.2 G .461(rsity of California.).12 F .46(Permission to use, cop)
4.461 F 1.5 -.52(y, m)-.08 H(odify).52 E 2.46(,a)-.52 G .46(nd dis-)
-2.46 F(trib)72 514.8 Q .333(ute this softw)-.16 F .333
(are and its documentation for an)-.08 F 2.333(yp)-.12 G .333(urpose, w\
ithout fee, and without a written agreement is hereby granted, pro)
-2.333 F(vided)-.12 E(that the abo)72 524.4 Q .24 -.12(ve c)-.12 H(op)
.12 E(yright notice and this paragraph and the follo)-.08 E(wing tw)-.2
E 2(op)-.08 G(aragraphs appear in all copies.)-2 E/F7 11/Times-Roman@0
SF .886(IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE T)133
541.5 R(O)-.198 E 3.598(ANY P)108 554.7 R(AR)-1.012 E 3.598
(TY FOR DIRECT)-.66 F 6.348(,I)-.814 G(NDIRECT)-6.348 E 6.348(,S)-.814 G
3.599(PECIAL, INCIDENT)-6.348 F 3.599(AL, OR CONSE-)-1.023 F -.11(QU)108
567.9 S .13(ENTIAL D).11 F(AMA)-.44 E .13(GES, INCLUDING LOST PR)-.44 F
.129(OFITS, ARISING OUT OF THE USE)-.44 F 1.216(OF THIS SOFTW)108 581.1
R 1.216(ARE AND ITS DOCUMENT)-1.32 F -1.221(AT)-1.023 G 1.216
(ION, EVEN IF THE UNIVERSITY)1.221 F 1.557(OF CALIFORNIA HAS BEEN AD)108
594.3 R 1.556(VISED OF THE POSSIBILITY OF SUCH D)-.44 F(AM-)-.44 E -.44
(AG)108 607.5 S(E.).44 E 4.677(THE UNIVERSITY OF CALIFORNIA SPECIFICALL)
133 624.6 R 7.428(YD)-1.1 G 4.678(ISCLAIMS ANY)-7.428 F -1.32(WA)108
637.8 S 4.519(RRANTIES, INCLUDING, B)1.32 F 4.518(UT NO)-.11 F 7.268(TL)
-.44 G 4.518(IMITED T)-7.268 F 4.518(O, THE IMPLIED W)-.198 F(AR-)-1.32
E 2.476(RANTIES OF MERCHANT)108 651 R 2.476(ABILITY AND FITNESS FOR A P)
-1.023 F(AR)-1.012 E 2.477(TICULAR PUR-)-.66 F 2.847(POSE. THE)108 664.2
R(SOFTW)2.847 E .097(ARE PR)-1.32 F -.55(OV)-.44 G .097
(IDED HEREUNDER IS ON AN "AS IS" B).55 F .097(ASIS, AND)-.385 F 4.279
(THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGA)108 677.4 R 4.279(TIONS T)
-1.221 F 7.029(OP)-.198 G -.44(RO)-7.029 G(VIDE)-.11 E(MAINTEN)108 690.6
Q .586(ANCE, SUPPOR)-.385 F 2.213 -.814(T, U)-.66 H(PD).814 E -1.221(AT)
-.44 G .585(ES, ENHANCEMENTS, OR MODIFICA)1.221 F(TIONS.)-1.221 E F2(1)
285.25 756 Q EP
%%Page: 2 2
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(1. INTR)72 165.4 R(ODUCTION)-.57 E
77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL
91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL
108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6
DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130
178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6
146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5
178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185
178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL
201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6
DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5
178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6
240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6
256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5
178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295
178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL
311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6
DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5
178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6
350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6
366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5
178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405
178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL
421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6
DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5
178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6
460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6
476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5
178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF 1.763
(This document is the user manual for the)108 208.9 R/F2 10
/Times-Roman@0 SF(POSTGRES)4.514 E F1 1.764
(95 database management system)B(de)108 222.1 Q -.165(ve)-.275 G 1.139
(loped at the Uni).165 F -.165(ve)-.275 G 1.138
(rsity of California at Berk).165 F(ele)-.11 E -.715(y.)-.165 G F2
(POSTGRES)7.353 E F1 1.138(95 is based on)B F2(POST)3.888 E(-)-.92 E
(GRES)108 235.3 Q F1 1.881(release 4.2. The)4.631 F F2(POSTGRES)4.631 E
F1 1.881(project, led by Professor Michael Stonebrak)4.631 F(er)-.11 E
4.631(,h)-.44 G(as)-4.631 E .07(been sponsored by the Defense Adv)108
248.5 R .07(anced Research Projects Agenc)-.275 F 2.82(y\()-.165 G -.44
(DA)-2.82 G(RP).44 E .07(A\), the Army)-1.012 F(Research Of)108 261.7 Q
(\214ce \(AR)-.275 E(O\), the National Science F)-.44 E
(oundation \(NSF\), and ESL, Inc.)-.165 E/F3 12/Times-Bold@0 SF 3
(1.1. What)72 287.9 R(is)3 E/F4 11/Times-Bold@0 SF(POSTGRES)3 E F3(?)A
F1 -.385(Tr)108 305 S .35(aditional relational database management syst\
ems \(DBMSs\) support a data model con-).385 F .45
(sisting of a collection of named relations, containing attrib)108 318.2
R .45(utes of a speci\214c type.)-.22 F .45(In cur)5.95 F(-)-.22 E .357
(rent commercial systems, possible types include \215oating point numbe\
rs, inte)108 331.4 R .358(gers, charac-)-.165 F .066(ter strings, mone)
108 344.6 R 1.496 -.715(y, a)-.165 H .066(nd dates.).715 F .066
(It is commonly recognized that this model is inadequate for)5.566 F
(future data processing applications.)108 357.8 Q .659
(The relational model successfully replaced pre)108 374.9 R .659
(vious models in part because of its \231Spar)-.275 F(-)-.22 E .74
(tan simplicity\232.)108 388.1 R(Ho)6.24 E(we)-.275 E -.165(ve)-.275 G
1.619 -.44(r, a).165 H 3.489(sm).44 G .739
(entioned, this simplicity often mak)-3.489 F .739
(es the implementation)-.11 F 1.613(of certain applications v)108 401.3
R 1.613(ery dif)-.165 F 1.613(\214cult to implement.)-.275 F F2
(POSTGRES)7.113 E F1(of)4.364 E 1.614(fers substantial addi-)-.275 F
.032(tional po)108 414.5 R .032(wer by incorporating the follo)-.275 F
.031(wing four additional basic constructs in such a w)-.275 F(ay)-.11 E
(that users can easily e)108 427.7 Q(xtend the system:)-.165 E(classes)
148 453.9 Q(inheritance)148 467.1 Q(types)148 480.3 Q(functions)148
493.5 Q(In addition,)108 519.7 Q F2(POSTGRES)2.75 E F1(supports a po)
2.75 E(werful production rule system.)-.275 E F3 3(1.2. A)72 545.9 R
(Short History of the)3 E F4(POSTGRES)3 E F3(Pr)3 E(oject)-.216 E F1
1.658(Implementation of the)108 563 R F2(POSTGRES)4.409 E F1 1.659
(DBMS be)4.409 F -.055(ga)-.165 G 4.409(ni).055 G 4.409(n1)-4.409 G
4.409(986. The)-4.409 F 1.659(initial concepts for the)4.409 F .42
(system were presented in [ST)108 576.2 R .42
(ON86] and the de\214nition of the initial data model appeared)-.198 F
.805(in [R)108 589.4 R -.385(OW)-.44 G 3.555(E87]. The).385 F .805
(design of the rule system at that time w)3.555 F .806
(as described in [ST)-.11 F(ON87a].)-.198 E(The rationale and architect\
ure of the storage manager were detailed in [ST)108 602.6 Q(ON87b].)
-.198 E F2(POSTGRES)108 619.7 Q F1 .861(has under)3.611 F .861(gone se)
-.198 F -.165(ve)-.275 G .861(ral major releases since then.).165 F .86
(The \214rst \231demo)6.36 F -.11(wa)-.275 G .86(re\232 sys-).11 F .253
(tem became operational in 1987 and w)108 632.9 R .253(as sho)-.11 F
.253(wn at the 1988 A)-.275 F .253(CM-SIGMOD Conference.)-.44 F 2.052
-.88(We r)108 646.1 T .292(eleased V).88 F .291
(ersion 1, described in [ST)-1.221 F .291(ON90a], to a fe)-.198 F 3.041
(we)-.275 G .291(xternal users in June 1989.)-3.206 F(In)5.791 E .659
(response to a critique of the \214rst rule system [ST)108 659.3 R .659
(ON89], the rule system w)-.198 F .66(as redesigned)-.11 F([ST)108 672.5
Q .023(ON90b] and V)-.198 F .023(ersion 2 w)-1.221 F .023
(as released in June 1990 with the ne)-.11 F 2.772(wr)-.275 G .022
(ule system.)-2.772 F -1.221(Ve)5.522 G .022(rsion 3)1.221 F 1.18(appea\
red in 1991 and added support for multiple storage managers, an impro)
108 685.7 R -.165(ve)-.165 G 3.93(dq).165 G(uery)-3.93 E -.165(exe)108
698.9 S(cutor).165 E 3.24(,a)-.44 G .49(nd a re)-3.24 F .49(written re)
-.275 F .49(write rule system.)-.275 F -.165(Fo)5.99 G 3.239(rt).165 G
.489(he most part, releases since then ha)-3.239 F -.165(ve)-.22 G
(focused on portability and reliability)108 712.1 Q(.)-.715 E F4(2)
285.25 756 Q EP
%%Page: 3 3
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Times-Roman@0 SF(POSTGRES)108 97.2 Q/F1 11/Times-Roman@0 SF .639
(has been used to implement man)3.389 F 3.39(yd)-.165 G(if)-3.39 E .64
(ferent research and production applica-)-.275 F 3.207(tions. These)108
110.4 R .456(include: a \214nancial data analysis system, a jet engine \
performance monitor)3.207 F(-)-.22 E 1.105(ing package, an asteroid tra\
cking database, a medical information database, and se)108 123.6 R -.165
(ve)-.275 G(ral).165 E .268(geographic information systems.)108 136.8 R
F0(POSTGRES)5.768 E F1 .267
(has also been used as an educational tool at)3.018 F(se)108 150 Q -.165
(ve)-.275 G 1.628(ral uni).165 F -.165(ve)-.275 G 4.378
(rsities. Finally).165 F 4.378(,I)-.715 G 1.628(llustra Information T)
-4.378 F 1.628(echnologies pick)-.77 F 1.628(ed up the code and)-.11 F
(commercialized it.)108 163.2 Q F0(POSTGRES)108 180.3 Q F1 .654(became \
the primary data manager for the Sequoia 2000 scienti\214c computing)
3.404 F .017(project in late 1992.)108 193.5 R .018
(Furthermore, the size of the e)5.518 F .018
(xternal user community nearly doubled)-.165 F .376(during 1993.)108
206.7 R .376(It became increasingly ob)5.876 F .376
(vious that maintenance of the prototype code and)-.165 F .961
(support w)108 219.9 R .961(as taking up lar)-.11 F .962
(ge amounts of time that should ha)-.198 F 1.292 -.165(ve b)-.22 H .962
(een de).165 F -.22(vo)-.275 G .962(ted to database).22 F 3.025
(research. In)108 233.1 R .275(an ef)3.025 F .274
(fort to reduce this support b)-.275 F .274(urden, the project of)-.22 F
.274(\214cially ended with V)-.275 F(er)-1.221 E(-)-.22 E(sion 4.2.)108
246.3 Q/F2 12/Times-Bold@0 SF 3(1.3. What)72 272.5 R(is)3 E/F3 11
/Times-Bold@0 SF(POSTGRES)3 E F2(95?)A F0(POSTGRES)108 289.6 Q F1 .953
(95 is a deri)B -.275(va)-.275 G(ti).275 E 1.283 -.165(ve o)-.275 H
3.703(ft).165 G .953(he last of)-3.703 F .953(\214cial release of)-.275
F F0(POSTGRES)3.703 E F1(\(v)3.703 E .953(ersion 4.2\). The)-.165 F .165
(code is no)108 302.8 R 2.915(wc)-.275 G .165(ompletely ANSI C and the \
code size has been trimmed by 25%. There are a)-2.915 F .395
(lot of internal changes that impro)108 316 R .726 -.165(ve p)-.165 H
.396(erformance and code maintainability).165 F(.)-.715 E F0(POSTGRES)
3.146 E F1(95)A 1.58(runs about 30-50% f)108 329.2 R 1.58
(aster on the W)-.11 F 1.579
(isconsin Benchmark compared to v4.2. Apart from)-.44 F -.22(bu)108
342.4 S 2.75<678c>.22 G -.165(xe)-2.75 G
(s, these are the major enhancements:).165 E 5.5<8354>113.5 359.5 S
1.527(he query language POSTQ)-5.5 F 1.527
(UEL has been replaced with SQL \(implemented in the)-.11 F(serv)122.85
372.7 Q .73(er\). W)-.165 F 3.48(ed)-.88 G 3.48(on)-3.48 G .729
(ot support subqueries \(which can be imitated with user de\214ned SQL)
-3.48 F .487(functions\) at the moment. Aggre)122.85 385.9 R -.055(ga)
-.165 G .487(tes ha).055 F .817 -.165(ve b)-.22 H .487
(een re-implemented. W).165 F 3.237(ea)-.88 G .487(lso added sup-)-3.237
F(port for GR)122.85 399.1 Q(OUP BY)-.44 E 2.75(.T)-1.419 G
(he libpq interf)-2.75 E(ace is still a)-.11 E -.275(va)-.22 G
(ilable for C programs.).275 E 5.5<8349>113.5 412.3 S 3.291(na)-5.5 G
.541(ddition to the monitor program, we pro)-3.291 F .541(vide a ne)
-.165 F 3.29(wp)-.275 G .54(rogram \(psql\) which supports)-3.29 F
(GNU readline.)122.85 425.5 Q 5.5<8357>113.5 438.7 S 3.201(ea)-6.38 G
.452(dded a ne)-3.201 F 3.202(wf)-.275 G .452(ront-end library)-3.202 F
3.202(,l)-.715 G .452(ibpgtcl, that supports Tcl-based clients.)-3.202 F
3.202(As)5.952 G(ample)-3.202 E 1.056(shell, pgtclsh, pro)122.85 451.9 R
1.056(vides ne)-.165 F 3.805(wT)-.275 G 1.055(cl commands to interf)
-3.805 F 1.055(ace tcl programs with the)-.11 F F0(POST)3.805 E(-)-.92 E
(GRES)122.85 465.1 Q F1(95 back)A(end.)-.11 E 5.5<8354>113.5 478.3 S
.369(he lar)-5.5 F .369(ge object interf)-.198 F .37(ace has been o)-.11
F -.165(ve)-.165 G .37(rhauled. W).165 F 3.12(ek)-.88 G .37(ept In)-3.23
F -.165(ve)-.44 G .37(rsion lar).165 F .37(ge objects as the)-.198 F
.828(only mechanism for storing lar)122.85 491.5 R .827
(ge objects. \(This is not to be confused with the In)-.198 F -.165(ve)
-.44 G -.22(r-).165 G(sion \214le system which has been remo)122.85
504.7 Q -.165(ve)-.165 G(d.\)).165 E 5.5<8354>113.5 517.9 S 1.011
(he instance-le)-5.5 F -.165(ve)-.275 G 3.761(lr).165 G 1.011
(ule system has been remo)-3.761 F -.165(ve)-.165 G 1.011
(d. Rules are still a).165 F -.275(va)-.22 G 1.011(ilable as re).275 F
(write)-.275 E(rules.)122.85 531.1 Q 5.5<8341>113.5 544.3 S .062
(short tutorial introducing re)-2.688 F .061
(gular SQL features as well as those of ours is distrib)-.165 F(uted)
-.22 E(with the source code.)122.85 557.5 Q 5.5<8347>113.5 570.7 S .945
(NU mak)-5.5 F 3.695(e\()-.11 G .945(instead of BSD mak)-3.695 F .946
(e\) is used for the b)-.11 F .946(uild. Also,)-.22 F F0(POSTGRES)3.696
E F1 .946(95 can be)B(compiled with an unpatched gcc \(data alignment o\
f doubles has been \214x)122.85 583.9 Q(ed\).)-.165 E F2 3(1.4. About)72
610.1 R(This Release)3 E F0(POSTGRES)108 627.2 Q F1 1.871(95 is a)B
-.275(va)-.22 G 1.871(ilable free of char).275 F 1.871
(ge. This manual describes v)-.198 F 1.87(ersion 1.0 of)-.165 F F0(POST)
4.62 E(-)-.92 E(GRES)108 640.4 Q F1 4.86(95. The)B 2.11(authors ha)4.86
F 2.44 -.165(ve c)-.22 H 2.11(ompiled and tested).165 F F0(POSTGRES)4.86
E F1 2.11(95 on the follo)B 2.11(wing plat-)-.275 F(forms:)108 653.6 Q
F3(3)285.25 756 Q EP
%%Page: 4 4
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 481.389 88.75 130.61 88.75 DL/F0 11/Times-Roman@0 SF 42.488
(architecture processor)160.106 99.2 R(operating system)61.429 E 481.389
103.95 130.61 103.95 DL 481.389 105.95 130.61 105.95 DL(DECstation 3000)
136.11 116.4 Q(Alpha AXP)40.326 E(OSF/1 2.1, 3.0, 3.2)16.5 E
(DECstation 5000)136.11 129.6 Q 39.71(MIPS UL)40.326 F(TRIX 4.4)-1.012 E
91.047(Sun4 SP)136.11 142.8 R 31.548(ARC SunOS)-1.012 F
(4.1.3, 4.1.3_U1; Solaris 2.4)2.75 E(H-P 9000/700 and 800)136.11 156 Q
-1.012(PA)16.5 G 24.222(-RISC HP-UX)1.012 F(9.00, 9.01, 9.03)2.75 E 93.5
(Intel X86)136.11 169.2 R(Linux 1.2.8, ELF)49.192 E 481.389 173.95
130.61 173.95 DL 312.407 88.75 312.407 173.95 DL 244.273 88.75 244.273
173.95 DL 481.389 88.75 481.389 173.95 DL 130.61 88.75 130.61 173.95 DL
/F1 12/Times-Bold@0 SF 3(1.5. Outline)72 208.4 R(of This Manual)3 E F0
.296(From no)108 225.5 R 3.046(wo)-.275 G .296(n, W)-3.046 F 3.046(ew)
-.88 G .296(ill use)-3.046 F/F2 10/Times-Roman@0 SF(POSTGRES)3.046 E F0
.296(to mean)3.046 F F2(POSTGRES)3.046 E F0 3.046(95. The)B .295
(\214rst part of this man-)3.046 F .108(ual goes o)108 238.7 R -.165(ve)
-.165 G 2.859(rs).165 G .109
(ome basic system concepts and procedures for starting the)-2.859 F F2
(POSTGRES)2.859 E F0(sys-)2.859 E 3.817(tem. W)108 251.9 R 3.817(et)-.88
G 1.067(hen turn to a tutorial o)-3.817 F -.165(ve)-.165 G(rvie).165 E
3.817(wo)-.275 G 3.817(ft)-3.817 G(he)-3.817 E F2(POSTGRES)3.817 E F0
1.066(data model and SQL query)3.817 F 1.26(language, introducing a fe)
108 265.1 R 4.01(wo)-.275 G 4.01(fi)-4.01 G 1.26(ts adv)-4.01 F 1.26
(anced features.)-.275 F(Ne)6.76 E 1.26(xt, we e)-.165 F 1.26
(xplain the)-.165 F F2(POSTGRES)4.011 E F0 .745(approach to e)108 278.3
R .745(xtensibility and describe ho)-.165 F 3.495(wu)-.275 G .745
(sers can e)-3.495 F(xtend)-.165 E F2(POSTGRES)3.495 E F0 .745
(by adding user)3.495 F(-)-.22 E .122(de\214ned types, operators, aggre)
108 291.5 R -.055(ga)-.165 G .122
(tes, and both query language and programming language).055 F 3.516
(functions. After)108 304.7 R .766(an e)3.516 F .766(xtremely brief o)
-.165 F -.165(ve)-.165 G(rvie).165 E 3.516(wo)-.275 G 3.516(ft)-3.516 G
(he)-3.516 E F2(POSTGRES)3.516 E F0 .766(rule system, the manual)3.516 F
.468
(concludes with a detailed appendix that discusses some of the more in)
108 317.9 R -.22(vo)-.44 G(lv).22 E .468(ed and operat-)-.165 F
(ing system-speci\214c procedures in)108 331.1 Q -.22(vo)-.44 G(lv).22 E
(ed in e)-.165 E(xtending the system.)-.165 E 1.76 -.88(We a)108 357.5 T
(ssume pro\214cienc).88 E 2.75(yw)-.165 G(ith UNIX and C programming.)
-2.75 E .32 LW 76 659.4 72 659.4 DL 80 659.4 76 659.4 DL 84 659.4 80
659.4 DL 88 659.4 84 659.4 DL 92 659.4 88 659.4 DL 96 659.4 92 659.4 DL
100 659.4 96 659.4 DL 104 659.4 100 659.4 DL 108 659.4 104 659.4 DL 112
659.4 108 659.4 DL 116 659.4 112 659.4 DL 120 659.4 116 659.4 DL 124
659.4 120 659.4 DL 128 659.4 124 659.4 DL 132 659.4 128 659.4 DL 136
659.4 132 659.4 DL 140 659.4 136 659.4 DL 144 659.4 140 659.4 DL 148
659.4 144 659.4 DL 152 659.4 148 659.4 DL 156 659.4 152 659.4 DL 160
659.4 156 659.4 DL 164 659.4 160 659.4 DL 168 659.4 164 659.4 DL 172
659.4 168 659.4 DL 176 659.4 172 659.4 DL 180 659.4 176 659.4 DL 184
659.4 180 659.4 DL 188 659.4 184 659.4 DL 192 659.4 188 659.4 DL 196
659.4 192 659.4 DL 200 659.4 196 659.4 DL 204 659.4 200 659.4 DL 208
659.4 204 659.4 DL 212 659.4 208 659.4 DL 216 659.4 212 659.4 DL/F3 7
/Times-Roman@0 SF(UNIX)93.6 671.4 Q/F4 8/Times-Roman@0 SF .042
(is a trademark of X/Open, Ltd.)2.042 F .042(Sun4, SP)4.042 F .041
(ARC, SunOS and Solaris are trademarks of Sun Microsystems, Inc.)-.736 F
.041(DEC, DEC-)4.041 F 1.409(station, Alpha AXP and UL)72 681 R 1.409
(TRIX are trademarks of Digital Equipment Corp.)-.736 F -.736(PA)5.41 G
1.41(-RISC and HP-UX are trademarks of He).736 F(wlett-)-.2 E -.12(Pa)72
690.6 S(ckard Co.).12 E(OSF/1 is a trademark of the Open Softw)4 E
(are F)-.08 E(oundation.)-.12 E/F5 11/Times-Bold@0 SF(4)285.25 756 Q EP
%%Page: 5 5
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(2. POSTGRES)72 165.4 R
(ARCHITECTURE CONCEPTS)4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6
DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL
102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6
DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5
178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6
141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6
157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5
178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196
178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL
212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6
DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5
178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6
251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6
267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5
178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306
178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL
322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6
DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5
178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6
361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6
377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5
178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416
178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL
432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6
DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5
178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6
471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6
487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11
/Times-Roman@0 SF 1.972
(Before we continue, you should understand the basic)108 208.9 R/F2 10
/Times-Roman@0 SF(POSTGRES)4.722 E F1 1.971(system architecture.)4.722 F
.235(Understanding ho)108 222.1 R 2.985(wt)-.275 G .235(he parts of)
-2.985 F F2(POSTGRES)2.985 E F1 .235(interact will mak)2.985 F 2.985(et)
-.11 G .236(he ne)-2.985 F .236(xt chapter some)-.165 F(what)-.275 E
77.5 247.3 72 247.3 DL 80.5 247.3 75 247.3 DL 86 247.3 80.5 247.3 DL
91.5 247.3 86 247.3 DL 97 247.3 91.5 247.3 DL 102.5 247.3 97 247.3 DL
108 247.3 102.5 247.3 DL 113.5 247.3 108 247.3 DL 119 247.3 113.5 247.3
DL 124.5 247.3 119 247.3 DL 130 247.3 124.5 247.3 DL 135.5 247.3 130
247.3 DL 141 247.3 135.5 247.3 DL 146.5 247.3 141 247.3 DL 152 247.3
146.5 247.3 DL 157.5 247.3 152 247.3 DL 163 247.3 157.5 247.3 DL 168.5
247.3 163 247.3 DL 174 247.3 168.5 247.3 DL 179.5 247.3 174 247.3 DL 185
247.3 179.5 247.3 DL 190.5 247.3 185 247.3 DL 196 247.3 190.5 247.3 DL
201.5 247.3 196 247.3 DL 207 247.3 201.5 247.3 DL 212.5 247.3 207 247.3
DL 218 247.3 212.5 247.3 DL 223.5 247.3 218 247.3 DL 229 247.3 223.5
247.3 DL 234.5 247.3 229 247.3 DL 240 247.3 234.5 247.3 DL 245.5 247.3
240 247.3 DL 251 247.3 245.5 247.3 DL 256.5 247.3 251 247.3 DL 262 247.3
256.5 247.3 DL 267.5 247.3 262 247.3 DL 273 247.3 267.5 247.3 DL 278.5
247.3 273 247.3 DL 284 247.3 278.5 247.3 DL 289.5 247.3 284 247.3 DL 295
247.3 289.5 247.3 DL 300.5 247.3 295 247.3 DL 306 247.3 300.5 247.3 DL
311.5 247.3 306 247.3 DL 317 247.3 311.5 247.3 DL 322.5 247.3 317 247.3
DL 328 247.3 322.5 247.3 DL 333.5 247.3 328 247.3 DL 339 247.3 333.5
247.3 DL 344.5 247.3 339 247.3 DL 350 247.3 344.5 247.3 DL 355.5 247.3
350 247.3 DL 361 247.3 355.5 247.3 DL 366.5 247.3 361 247.3 DL 372 247.3
366.5 247.3 DL 377.5 247.3 372 247.3 DL 383 247.3 377.5 247.3 DL 388.5
247.3 383 247.3 DL 394 247.3 388.5 247.3 DL 399.5 247.3 394 247.3 DL 405
247.3 399.5 247.3 DL 410.5 247.3 405 247.3 DL 416 247.3 410.5 247.3 DL
421.5 247.3 416 247.3 DL 427 247.3 421.5 247.3 DL 432.5 247.3 427 247.3
DL 438 247.3 432.5 247.3 DL 443.5 247.3 438 247.3 DL 449 247.3 443.5
247.3 DL 454.5 247.3 449 247.3 DL 460 247.3 454.5 247.3 DL 465.5 247.3
460 247.3 DL 471 247.3 465.5 247.3 DL 476.5 247.3 471 247.3 DL 482 247.3
476.5 247.3 DL 487.5 247.3 482 247.3 DL 493 247.3 487.5 247.3 DL 498.5
247.3 493 247.3 DL 504 247.3 498.5 247.3 DL 0 0 288 470 -360 649 144
633.7 PBEGIN
%%BeginDocument: manual-arch.eps
%%Title: stdin
%%Creator: fig2dev Version 3.1 Patchlevel 0
%%CreationDate: Sat Feb 24 21:36:25 1996
%%For: jolly@arcadia.CS.Berkeley.EDU (Jolly Chen,421 Soda,(510) 6421863,540-5955)
%%Orientation: Portrait
%%BoundingBox: 0 0 470 649
%%Pages: 0
%%BeginSetup
%%IncludeFeature: *PageSize Letter
%%EndSetup
%%EndComments
/$F2psDict 200 dict def
$F2psDict begin
$F2psDict /mtrx matrix put
/col-1 {} def
/col0 {0.000 0.000 0.000 srgb} bind def
/col1 {0.000 0.000 1.000 srgb} bind def
/col2 {0.000 1.000 0.000 srgb} bind def
/col3 {0.000 1.000 1.000 srgb} bind def
/col4 {1.000 0.000 0.000 srgb} bind def
/col5 {1.000 0.000 1.000 srgb} bind def
/col6 {1.000 1.000 0.000 srgb} bind def
/col7 {1.000 1.000 1.000 srgb} bind def
/col8 {0.000 0.000 0.560 srgb} bind def
/col9 {0.000 0.000 0.690 srgb} bind def
/col10 {0.000 0.000 0.820 srgb} bind def
/col11 {0.530 0.810 1.000 srgb} bind def
/col12 {0.000 0.560 0.000 srgb} bind def
/col13 {0.000 0.690 0.000 srgb} bind def
/col14 {0.000 0.820 0.000 srgb} bind def
/col15 {0.000 0.560 0.560 srgb} bind def
/col16 {0.000 0.690 0.690 srgb} bind def
/col17 {0.000 0.820 0.820 srgb} bind def
/col18 {0.560 0.000 0.000 srgb} bind def
/col19 {0.690 0.000 0.000 srgb} bind def
/col20 {0.820 0.000 0.000 srgb} bind def
/col21 {0.560 0.000 0.560 srgb} bind def
/col22 {0.690 0.000 0.690 srgb} bind def
/col23 {0.820 0.000 0.820 srgb} bind def
/col24 {0.500 0.190 0.000 srgb} bind def
/col25 {0.630 0.250 0.000 srgb} bind def
/col26 {0.750 0.380 0.000 srgb} bind def
/col27 {1.000 0.500 0.500 srgb} bind def
/col28 {1.000 0.630 0.630 srgb} bind def
/col29 {1.000 0.750 0.750 srgb} bind def
/col30 {1.000 0.880 0.880 srgb} bind def
/col31 {1.000 0.840 0.000 srgb} bind def
end
save
-17.0 662.0 translate
1 -1 scale
/clp {closepath} bind def
/ef {eofill} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/l {lineto} bind def
/m {moveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/tr {translate} bind def
/tnt {dup dup currentrgbcolor
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
bind def
/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
4 -2 roll mul srgb} bind def
/DrawEllipse {
/endangle exch def
/startangle exch def
/yrad exch def
/xrad exch def
/y exch def
/x exch def
/savematrix mtrx currentmatrix def
x y tr xrad yrad sc 0 0 1 startangle endangle arc
closepath
savematrix setmatrix
} def
/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def
$F2psBegin
10 setmiterlimit
0.06000 0.06000 sc
/Times-Roman findfont 240.00 scalefont setfont
5550 1350 m
gs 1 -1 sc (POSTMASTER) col-1 show gr
7.500 slw
% Polyline
n 405 600 m 300 600 300 1320 105 arcto 4 {pop} repeat 300 1425 3270 1425 105 arcto 4 {pop} repeat 3375 1425 3375 705 105 arcto 4 {pop} repeat 3375 600 405 600 105 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 2325 600 m 2325 1425 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
375 1275 m
gs 1 -1 sc (APPLICATION) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
2475 1125 m
gs 1 -1 sc (LIBPQ) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
900 975 m
gs 1 -1 sc (USER) col-1 show gr
% Polyline
n 405 3225 m 300 3225 300 3945 105 arcto 4 {pop} repeat 300 4050 3270 4050 105 arcto 4 {pop} repeat 3375 4050 3375 3330 105 arcto 4 {pop} repeat 3375 3225 405 3225 105 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 2325 3225 m 2325 4050 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
375 3900 m
gs 1 -1 sc (APPLICATION) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
2475 3750 m
gs 1 -1 sc (LIBPQ) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
900 3600 m
gs 1 -1 sc (USER) col-1 show gr
% Polyline
n 5280 3075 m 5175 3075 5175 3495 105 arcto 4 {pop} repeat 5175 3600 7245 3600 105 arcto 4 {pop} repeat 7350 3600 7350 3180 105 arcto 4 {pop} repeat 7350 3075 5280 3075 105 arcto 4 {pop} repeat clp gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
5325 3450 m
gs 1 -1 sc (POSTMASTER) col-1 show gr
% Polyline
n 5655 3900 m 5550 3900 5550 4320 105 arcto 4 {pop} repeat 5550 4425 6795 4425 105 arcto 4 {pop} repeat 6900 4425 6900 4005 105 arcto 4 {pop} repeat 6900 3900 5655 3900 105 arcto 4 {pop} repeat clp gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
5700 4275 m
gs 1 -1 sc (SERVER) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
300 2100 m
gs 1 -1 sc (\(a\) frontend sends request to) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
675 2400 m
gs 1 -1 sc (postmaster via well-known) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
675 2700 m
gs 1 -1 sc (network socket) col-1 show gr
% Polyline
n 406 8251 m 301 8251 301 8971 105 arcto 4 {pop} repeat 301 9076 3271 9076 105 arcto 4 {pop} repeat 3376 9076 3376 8356 105 arcto 4 {pop} repeat 3376 8251 406 8251 105 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 2326 8251 m 2326 9076 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
376 8926 m
gs 1 -1 sc (APPLICATION) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
2476 8776 m
gs 1 -1 sc (LIBPQ) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
901 8626 m
gs 1 -1 sc (USER) col-1 show gr
% Polyline
n 5431 8476 m 5326 8476 5326 8896 105 arcto 4 {pop} repeat 5326 9001 7396 9001 105 arcto 4 {pop} repeat 7501 9001 7501 8581 105 arcto 4 {pop} repeat 7501 8476 5431 8476 105 arcto 4 {pop} repeat clp gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
5476 8851 m
gs 1 -1 sc (POSTMASTER) col-1 show gr
% Polyline
n 405 5625 m 300 5625 300 6345 105 arcto 4 {pop} repeat 300 6450 3270 6450 105 arcto 4 {pop} repeat 3375 6450 3375 5730 105 arcto 4 {pop} repeat 3375 5625 405 5625 105 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 2325 5625 m 2325 6450 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
375 6300 m
gs 1 -1 sc (APPLICATION) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
2475 6150 m
gs 1 -1 sc (LIBPQ) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
900 6000 m
gs 1 -1 sc (USER) col-1 show gr
% Polyline
n 5655 6675 m 5550 6675 5550 7095 105 arcto 4 {pop} repeat 5550 7200 6795 7200 105 arcto 4 {pop} repeat 6900 7200 6900 6780 105 arcto 4 {pop} repeat 6900 6675 5655 6675 105 arcto 4 {pop} repeat clp gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
5700 7050 m
gs 1 -1 sc (SERVER) col-1 show gr
% Polyline
n 5430 5850 m 5325 5850 5325 6270 105 arcto 4 {pop} repeat 5325 6375 7395 6375 105 arcto 4 {pop} repeat 7500 6375 7500 5955 105 arcto 4 {pop} repeat 7500 5850 5430 5850 105 arcto 4 {pop} repeat clp gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
5475 6225 m
gs 1 -1 sc (POSTMASTER) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
300 7200 m
gs 1 -1 sc (\(c\) frontend connected) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
675 7500 m
gs 1 -1 sc (to backend server) col-1 show gr
% Polyline
n 5505 975 m 5400 975 5400 1395 105 arcto 4 {pop} repeat 5400 1500 7470 1500 105 arcto 4 {pop} repeat 7575 1500 7575 1080 105 arcto 4 {pop} repeat 7575 975 5505 975 105 arcto 4 {pop} repeat clp gs col-1 s gr
% Ellipse
n 4425 1200 105 105 0 360 DrawEllipse gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
5701 9676 m
gs 1 -1 sc (SERVER1) col-1 show gr
% Ellipse
n 4425 3825 105 105 0 360 DrawEllipse gs col-1 s gr
% Ellipse
n 6105 3705 1680 1080 0 360 DrawEllipse gs col-1 s gr
% Ellipse
n 6105 1305 1680 1080 0 360 DrawEllipse gs col-1 s gr
% Ellipse
n 4471 8716 105 105 0 360 DrawEllipse gs col-1 s gr
% Ellipse
n 6105 6405 1680 1080 0 360 DrawEllipse gs col-1 s gr
% Ellipse
n 4470 6090 105 105 0 360 DrawEllipse gs col-1 s gr
% Ellipse
n 6225 9375 1875 1650 0 360 DrawEllipse gs col-1 s gr
% Polyline
[66.7] 0 setdash
n 4500 1200 m 5400 1200 l gs col-1 s gr [] 0 setdash
% Polyline
n 6225 3600 m 6225 3900 l gs col-1 s gr
n 6262.50 3765.00 m 6225.00 3900.00 l 6187.50 3765.00 l gs col-1 s gr
% Polyline
[66.7] 0 setdash
n 4576 8701 m 5326 8701 l gs col-1 s gr [] 0 setdash
% Polyline
[66.7] 0 setdash
n 4575 6075 m 5325 6075 l gs col-1 s gr [] 0 setdash
% Polyline
n 3450 9525 m 3000 9075 l gs col-1 s gr
% Polyline
n 5656 9301 m 5551 9301 5551 9721 105 arcto 4 {pop} repeat 5551 9826 6796 9826 105 arcto 4 {pop} repeat 6901 9826 6901 9406 105 arcto 4 {pop} repeat 6901 9301 5656 9301 105 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 5730 10125 m 5625 10125 5625 10545 105 arcto 4 {pop} repeat 5625 10650 6870 10650 105 arcto 4 {pop} repeat 6975 10650 6975 10230 105 arcto 4 {pop} repeat 6975 10125 5730 10125 105 arcto 4 {pop} repeat clp gs col-1 s gr
% Interp Spline
n 3375 1050 m
3503.93 1040.59 3560.18 1040.59 3600 1050 curveto
3679.17 1068.69 3820.83 1181.31 3900 1200 curveto
3966.39 1215.67 4060.14 1215.67 4275 1200 curveto
gs col-1 s gr
n 4137.63 1172.42 m 4275.00 1200.00 l 4143.09 1247.22 l gs col-1 s gr
% Interp Spline
n 3375 3675 m
3679.71 3639.77 3810.96 3621.02 3900 3600 curveto
4059.28 3562.40 4415.07 3411.27 4575 3375 curveto
4676.94 3351.89 4826.94 3333.14 5175 3300 curveto
gs col-1 s gr
n 5037.05 3275.46 m 5175.00 3300.00 l 5044.16 3350.13 l gs col-1 s gr
% Interp Spline
n 3376 8701 m
3679.72 8719.96 3810.97 8738.71 3901 8776 curveto
4070.77 8846.32 4347.49 9141.91 4501 9226 curveto
4632.16 9297.85 4958.41 9412.76 5101 9451 curveto
5177.14 9471.42 5289.64 9490.17 5551 9526 curveto
gs col-1 s gr
n 5422.34 9470.51 m 5551.00 9526.00 l 5412.16 9544.82 l gs col-1 s gr
% Interp Spline
n 3375 6075 m
3678.72 6093.96 3809.97 6112.71 3900 6150 curveto
4069.77 6220.32 4346.49 6515.91 4500 6600 curveto
4631.16 6671.85 4957.41 6786.76 5100 6825 curveto
5176.14 6845.42 5288.64 6864.17 5550 6900 curveto
gs col-1 s gr
n 5421.34 6844.51 m 5550.00 6900.00 l 5411.16 6918.82 l gs col-1 s gr
% Interp Spline
n 3450 9525 m
3753.72 9543.96 3884.97 9562.71 3975 9600 curveto
4144.77 9670.32 4421.49 9965.91 4575 10050 curveto
4706.16 10121.85 5032.41 10236.76 5175 10275 curveto
5251.14 10295.42 5363.64 10314.17 5625 10350 curveto
gs col-1 s gr
n 5496.34 10294.51 m 5625.00 10350.00 l 5486.16 10368.82 l gs col-1 s gr
/Times-Roman findfont 210.00 scalefont setfont
5775 2100 m
gs 1 -1 sc (server host) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
4650 1425 m
gs 1 -1 sc (listening) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
4125 1050 m
gs 1 -1 sc (TCP port) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
3450 3375 m
gs 1 -1 sc (connection) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
3450 3150 m
gs 1 -1 sc (initial) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
6300 3825 m
gs 1 -1 sc (forks child ) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
300 4800 m
gs 1 -1 sc (\(b\) postmaster creates backend server) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
3601 9226 m
gs 1 -1 sc (queries/) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
3601 9451 m
gs 1 -1 sc (data) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
4576 9001 m
gs 1 -1 sc (listening) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
301 9826 m
gs 1 -1 sc (\(d\) frontend connected) col-1 show gr
/Times-Bold findfont 240.00 scalefont setfont
676 10126 m
gs 1 -1 sc (to multiple backend servers) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
3600 6600 m
gs 1 -1 sc (queries/) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
3600 6825 m
gs 1 -1 sc (data) col-1 show gr
/Times-Roman findfont 210.00 scalefont setfont
4575 6375 m
gs 1 -1 sc (listening) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
5775 10500 m
gs 1 -1 sc (SERVER2) col-1 show gr
$F2psEnd
restore
%%EndDocument
end PEND/F3 11/Times-Bold@0 SF(Figur)192.151 660.1 Q 2.75(e1)-.198 G F1
5.5(.H)-2.75 G .55 -.275(ow a c)-5.5 H(onnection is established.).275 E
77.5 673.3 72 673.3 DL 80.5 673.3 75 673.3 DL 86 673.3 80.5 673.3 DL
91.5 673.3 86 673.3 DL 97 673.3 91.5 673.3 DL 102.5 673.3 97 673.3 DL
108 673.3 102.5 673.3 DL 113.5 673.3 108 673.3 DL 119 673.3 113.5 673.3
DL 124.5 673.3 119 673.3 DL 130 673.3 124.5 673.3 DL 135.5 673.3 130
673.3 DL 141 673.3 135.5 673.3 DL 146.5 673.3 141 673.3 DL 152 673.3
146.5 673.3 DL 157.5 673.3 152 673.3 DL 163 673.3 157.5 673.3 DL 168.5
673.3 163 673.3 DL 174 673.3 168.5 673.3 DL 179.5 673.3 174 673.3 DL 185
673.3 179.5 673.3 DL 190.5 673.3 185 673.3 DL 196 673.3 190.5 673.3 DL
201.5 673.3 196 673.3 DL 207 673.3 201.5 673.3 DL 212.5 673.3 207 673.3
DL 218 673.3 212.5 673.3 DL 223.5 673.3 218 673.3 DL 229 673.3 223.5
673.3 DL 234.5 673.3 229 673.3 DL 240 673.3 234.5 673.3 DL 245.5 673.3
240 673.3 DL 251 673.3 245.5 673.3 DL 256.5 673.3 251 673.3 DL 262 673.3
256.5 673.3 DL 267.5 673.3 262 673.3 DL 273 673.3 267.5 673.3 DL 278.5
673.3 273 673.3 DL 284 673.3 278.5 673.3 DL 289.5 673.3 284 673.3 DL 295
673.3 289.5 673.3 DL 300.5 673.3 295 673.3 DL 306 673.3 300.5 673.3 DL
311.5 673.3 306 673.3 DL 317 673.3 311.5 673.3 DL 322.5 673.3 317 673.3
DL 328 673.3 322.5 673.3 DL 333.5 673.3 328 673.3 DL 339 673.3 333.5
673.3 DL 344.5 673.3 339 673.3 DL 350 673.3 344.5 673.3 DL 355.5 673.3
350 673.3 DL 361 673.3 355.5 673.3 DL 366.5 673.3 361 673.3 DL 372 673.3
366.5 673.3 DL 377.5 673.3 372 673.3 DL 383 673.3 377.5 673.3 DL 388.5
673.3 383 673.3 DL 394 673.3 388.5 673.3 DL 399.5 673.3 394 673.3 DL 405
673.3 399.5 673.3 DL 410.5 673.3 405 673.3 DL 416 673.3 410.5 673.3 DL
421.5 673.3 416 673.3 DL 427 673.3 421.5 673.3 DL 432.5 673.3 427 673.3
DL 438 673.3 432.5 673.3 DL 443.5 673.3 438 673.3 DL 449 673.3 443.5
673.3 DL 454.5 673.3 449 673.3 DL 460 673.3 454.5 673.3 DL 465.5 673.3
460 673.3 DL 471 673.3 465.5 673.3 DL 476.5 673.3 471 673.3 DL 482 673.3
476.5 673.3 DL 487.5 673.3 482 673.3 DL 493 673.3 487.5 673.3 DL 498.5
673.3 493 673.3 DL 504 673.3 498.5 673.3 DL F3(5)285.25 756 Q EP
%%Page: 6 6
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF(clearer)108 97.2 Q(.)-.605 E 1.025
(In database jar)108 114.3 R(gon,)-.198 E/F1 10/Times-Roman@0 SF
(POSTGRES)3.775 E F0 1.025(uses a simple \231process-per)3.775 F 1.025
(-user\232 client/serv)-.22 F 1.024(er model.)-.165 F(A)6.524 E F1
(POSTGRES)108 127.5 Q F0(session consists of the follo)2.75 E
(wing cooperating)-.275 E F1(UNIX)2.75 E F0(processes \(programs\):)2.75
E 5.5<8341>113.5 144.6 S(supervisory daemon process \(the)-2.75 E/F2 11
/Courier@0 SF(postmaster)2.75 E F0(\),)A 5.5<8374>113.5 157.8 S
(he user')-5.5 E 2.75(sf)-.605 G(rontend application \(e.g., the)-2.75 E
F2(psql)2.75 E F0(program\), and)2.75 E 5.5<8374>113.5 171 S
(he one or more back)-5.5 E(end database serv)-.11 E(ers \(the)-.165 E
F2(postgres)2.75 E F0(process itself\).)2.75 E 2.783(As)108 188.1 S
(ingle)-2.783 E F2(postmaster)2.783 E F0 .034(manages a gi)2.783 F -.165
(ve)-.275 G 2.784(nc).165 G .034(ollection of)-2.784 F/F3 11
/Times-Italic@0 SF(databases)2.784 E F0 .034(on a single host.)2.784 F
.034(Such a)5.534 F .214(collection of databases is called an)108 201.3
R F3(installation)2.963 E F0(or)2.963 E F3(site)2.963 E F0 5.713(.F)C
.213(rontend applications that wish to)-5.713 F 2.462(access a gi)108
214.5 R -.165(ve)-.275 G 5.213(nd).165 G 2.463
(atabase within an installation mak)-5.213 F 5.213(ec)-.11 G 2.463
(alls to the)-5.213 F F1(LIBPQ)5.213 E F0(library)5.213 E 7.963(.T)-.715
G(he)-7.963 E .275(library sends user requests o)108 227.7 R -.165(ve)
-.165 G 3.024(rt).165 G .274(he netw)-3.024 F .274(ork to the)-.11 F F2
(postmaster)3.024 E F0 .274(\(Figure 1\(a\)\), which in)3.024 F .591
(turn starts a ne)108 240.9 R 3.341(wb)-.275 G(ack)-3.341 E .591
(end serv)-.11 F .592
(er process \(Figure 1\(b\)\) and connects the frontend process)-.165 F
.165(to the ne)108 254.1 R 2.915(ws)-.275 G(erv)-2.915 E .165
(er \(Figure 1\(c\)\).)-.165 F .164
(From that point on, the frontend process and the back)5.664 F(end)-.11
E(serv)108 267.3 Q .625(er communicate without interv)-.165 F .626
(ention by the)-.165 F F2(postmaster)3.376 E F0 6.126(.H)C .626
(ence, the)-6.126 F F2(postmas-)3.376 E(ter)108 280.5 Q F0 1.72(is al)
4.47 F -.11(wa)-.11 G 1.72(ys running, w).11 F 1.72
(aiting for requests, whereas frontend and back)-.11 F 1.72
(end processes)-.11 F .795(come and go.)108 293.7 R(The)6.296 E F1
(LIBPQ)3.546 E F0 .796(library allo)3.546 F .796
(ws a single frontend to mak)-.275 F 3.546(em)-.11 G .796
(ultiple connections)-3.546 F 1.511(to back)108 306.9 R 1.511
(end processes.)-.11 F(Ho)7.011 E(we)-.275 E -.165(ve)-.275 G 2.391 -.44
(r, t).165 H 1.511
(he frontend application is still a single-threaded pro-).44 F 3.294
(cess. Multithreaded)108 320.1 R(frontend/back)3.294 E .545
(end connections are not currently supported in)-.11 F F1(LIBPQ)3.295 E
F0(.)A .054(One implication of this architecture is that the)108 337.2 R
F2(postmaster)2.803 E F0 .053(and the back)2.803 F .053(end al)-.11 F
-.11(wa)-.11 G .053(ys run).11 F .831
(on the same machine \(the database serv)108 350.4 R .832
(er\), while the frontend application may run an)-.165 F(y-)-.165 E
3.659(where. Y)108 363.6 R .909(ou should k)-1.21 F .908
(eep this in mind, because the \214les that can be accessed on a client)
-.11 F .943
(machine may not be accessible \(or may only be accessed using a dif)108
376.8 R .943(ferent \214lename\) on)-.275 F(the database serv)108 390 Q
(er machine.)-.165 E -1.21(Yo)108 407.1 S 3.967(us)1.21 G 1.217
(hould also be a)-3.967 F -.11(wa)-.165 G 1.217(re that the).11 F F2
(postmaster)3.967 E F0(and)3.967 E F2(postgres)3.967 E F0(serv)3.967 E
1.216(ers run with the)-.165 F(user)108 420.3 Q .493(-id of the)-.22 F
F1(POSTGRES)3.243 E F0(\231superuser)3.243 E 4.783 -.77(.\232 N)-.605 H
.493(ote that the).77 F F1(POSTGRES)3.244 E F0 .494
(superuser does not ha)3.244 F -.165(ve)-.22 G .931
(to be a special user \(e.g., a user named \231postgres\232\).)108 433.5
R .931(Furthermore, the)6.431 F F1(POSTGRES)3.681 E F0(supe-)3.681 E
.171(ruser should de\214nitely not be the)108 446.7 R F1(UNIX)2.921 E F0
(superuser)2.921 E 2.921<2c99>-.44 G 2.921(root\232! In)-2.921 F(an)
2.921 E 2.921(yc)-.165 G .171(ase, all \214les relating to)-2.921 F 2.75
(ad)108 459.9 S(atabase should belong to this)-2.75 E F1(POSTGRES)2.75 E
F0(superuser)2.75 E(.)-.605 E/F4 11/Times-Bold@0 SF(6)285.25 756 Q EP
%%Page: 7 7
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(3. GETTING)72 165.4 R(ST)4.75 E(AR)
-1.71 E(TED WITH POSTGRES)-.76 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
/F1 11/Times-Roman@0 SF .735(This section discusses ho)108 208.9 R 3.485
(wt)-.275 G 3.485(os)-3.485 G(tart)-3.485 E/F2 10/Times-Roman@0 SF
(POSTGRES)3.484 E F1 .734(and set up your o)3.484 F .734(wn en)-.275 F
.734(vironment so that)-.44 F .707(you can use frontend applications. W)
108 222.1 R 3.458(ea)-.88 G(ssume)-3.458 E F2(POSTGRES)3.458 E F1 .708
(has already been successfully)3.458 F
(installed. \(Refer to the installation notes for ho)108 235.3 Q 2.75
(wt)-.275 G 2.75(oi)-2.75 G(nstall)-2.75 E F2(POSTGRES)2.75 E F1(.\))A
.637(Some of the steps listed in this section will apply to all)108
261.7 R F2(POSTGRES)3.386 E F1 .636(users, and some will)3.386 F 1.135
(apply primarily to the site database administrator)108 274.9 R 6.635
(.T)-.605 G(his)-6.635 E/F3 11/Times-Italic@0 SF 1.135(site administr)
3.885 F(ator)-.165 E F1 1.135(is the person)3.885 F .129
(who installed the softw)108 288.1 R .129
(are, created the database directories and started the)-.11 F/F4 11
/Courier@0 SF(postmaster)2.879 E F1 4.183(process. This)108 301.3 R
1.433(person does not ha)4.183 F 1.763 -.165(ve t)-.22 H 4.183(ob).165 G
4.183(et)-4.183 G(he)-4.183 E F2(UNIX)4.183 E F1(superuser)4.183 E 4.184
<2c99>-.44 G(root,)-4.184 E 4.184<9a6f>-.77 G 4.184(rt)-4.184 G 1.434
(he computer)-4.184 F(system administrator)108 314.5 Q(.)-.605 E 1.512(\
In this section, items for end users are labelled \231User\232 and item\
s intended for the site)108 331.6 R(administrator are labelled \231)108
344.8 Q(Admin.)-.88 E<9a>-.77 E .677(Throughout this manual, an)108
361.9 R 3.427(ye)-.165 G .677(xamples that be)-3.592 F .678
(gin with the character `)-.165 F(`)-.814 E F4(%)A F1 2.306 -.814('' a)D
.678(re commands).814 F 1.067(that should be typed at the)108 375.1 R F2
(UNIX)3.817 E F1 1.067(shell prompt.)3.817 F 1.067(Examples that be)
6.567 F 1.067(gin with the character)-.165 F -.814(``)108 388.3 S F4(*)
.814 E F1 1.628 -.814('' a)D(re commands in the).814 E F2(POSTGRES)2.75
E F1(query language,)2.75 E F2(POSTGRES)2.75 E F1(SQL.)2.75 E/F5 12
/Times-Bold@0 SF 3(3.1. Admin/User:)72 414.5 R(Setting Up Y)3 E(our En)
-1.332 E(vir)-.48 E(onment)-.216 E 77.5 439.7 72 439.7 DL 80.5 439.7 75
439.7 DL 86 439.7 80.5 439.7 DL 91.5 439.7 86 439.7 DL 97 439.7 91.5
439.7 DL 102.5 439.7 97 439.7 DL 108 439.7 102.5 439.7 DL 113.5 439.7
108 439.7 DL 119 439.7 113.5 439.7 DL 124.5 439.7 119 439.7 DL 130 439.7
124.5 439.7 DL 135.5 439.7 130 439.7 DL 141 439.7 135.5 439.7 DL 146.5
439.7 141 439.7 DL 152 439.7 146.5 439.7 DL 157.5 439.7 152 439.7 DL 163
439.7 157.5 439.7 DL 168.5 439.7 163 439.7 DL 174 439.7 168.5 439.7 DL
179.5 439.7 174 439.7 DL 185 439.7 179.5 439.7 DL 190.5 439.7 185 439.7
DL 196 439.7 190.5 439.7 DL 201.5 439.7 196 439.7 DL 207 439.7 201.5
439.7 DL 212.5 439.7 207 439.7 DL 218 439.7 212.5 439.7 DL 223.5 439.7
218 439.7 DL 229 439.7 223.5 439.7 DL 234.5 439.7 229 439.7 DL 240 439.7
234.5 439.7 DL 245.5 439.7 240 439.7 DL 251 439.7 245.5 439.7 DL 256.5
439.7 251 439.7 DL 262 439.7 256.5 439.7 DL 267.5 439.7 262 439.7 DL 273
439.7 267.5 439.7 DL 278.5 439.7 273 439.7 DL 284 439.7 278.5 439.7 DL
289.5 439.7 284 439.7 DL 295 439.7 289.5 439.7 DL 300.5 439.7 295 439.7
DL 306 439.7 300.5 439.7 DL 311.5 439.7 306 439.7 DL 317 439.7 311.5
439.7 DL 322.5 439.7 317 439.7 DL 328 439.7 322.5 439.7 DL 333.5 439.7
328 439.7 DL 339 439.7 333.5 439.7 DL 344.5 439.7 339 439.7 DL 350 439.7
344.5 439.7 DL 355.5 439.7 350 439.7 DL 361 439.7 355.5 439.7 DL 366.5
439.7 361 439.7 DL 372 439.7 366.5 439.7 DL 377.5 439.7 372 439.7 DL 383
439.7 377.5 439.7 DL 388.5 439.7 383 439.7 DL 394 439.7 388.5 439.7 DL
399.5 439.7 394 439.7 DL 405 439.7 399.5 439.7 DL 410.5 439.7 405 439.7
DL 416 439.7 410.5 439.7 DL 421.5 439.7 416 439.7 DL 427 439.7 421.5
439.7 DL 432.5 439.7 427 439.7 DL 438 439.7 432.5 439.7 DL 443.5 439.7
438 439.7 DL 449 439.7 443.5 439.7 DL 454.5 439.7 449 439.7 DL 460 439.7
454.5 439.7 DL 465.5 439.7 460 439.7 DL 471 439.7 465.5 439.7 DL 476.5
439.7 471 439.7 DL 482 439.7 476.5 439.7 DL 487.5 439.7 482 439.7 DL 493
439.7 487.5 439.7 DL 498.5 439.7 493 439.7 DL 504 439.7 498.5 439.7 DL 0
0 432 826 -170.061 317 72 636.161 PBEGIN
%%BeginDocument: manual-files.eps
%%Title: stdin
%%Creator: fig2dev Version 3.1 Patchlevel 0
%%CreationDate: Sat Feb 24 21:36:26 1996
%%For: jolly@arcadia.CS.Berkeley.EDU (Jolly Chen,421 Soda,(510) 6421863,540-5955)
%%Orientation: Portrait
%%BoundingBox: 0 0 826 317
%%Pages: 0
%%BeginSetup
%%IncludeFeature: *PageSize Letter
%%EndSetup
%%EndComments
/$F2psDict 200 dict def
$F2psDict begin
$F2psDict /mtrx matrix put
/col-1 {} def
/col0 {0.000 0.000 0.000 srgb} bind def
/col1 {0.000 0.000 1.000 srgb} bind def
/col2 {0.000 1.000 0.000 srgb} bind def
/col3 {0.000 1.000 1.000 srgb} bind def
/col4 {1.000 0.000 0.000 srgb} bind def
/col5 {1.000 0.000 1.000 srgb} bind def
/col6 {1.000 1.000 0.000 srgb} bind def
/col7 {1.000 1.000 1.000 srgb} bind def
/col8 {0.000 0.000 0.560 srgb} bind def
/col9 {0.000 0.000 0.690 srgb} bind def
/col10 {0.000 0.000 0.820 srgb} bind def
/col11 {0.530 0.810 1.000 srgb} bind def
/col12 {0.000 0.560 0.000 srgb} bind def
/col13 {0.000 0.690 0.000 srgb} bind def
/col14 {0.000 0.820 0.000 srgb} bind def
/col15 {0.000 0.560 0.560 srgb} bind def
/col16 {0.000 0.690 0.690 srgb} bind def
/col17 {0.000 0.820 0.820 srgb} bind def
/col18 {0.560 0.000 0.000 srgb} bind def
/col19 {0.690 0.000 0.000 srgb} bind def
/col20 {0.820 0.000 0.000 srgb} bind def
/col21 {0.560 0.000 0.560 srgb} bind def
/col22 {0.690 0.000 0.690 srgb} bind def
/col23 {0.820 0.000 0.820 srgb} bind def
/col24 {0.500 0.190 0.000 srgb} bind def
/col25 {0.630 0.250 0.000 srgb} bind def
/col26 {0.750 0.380 0.000 srgb} bind def
/col27 {1.000 0.500 0.500 srgb} bind def
/col28 {1.000 0.630 0.630 srgb} bind def
/col29 {1.000 0.750 0.750 srgb} bind def
/col30 {1.000 0.880 0.880 srgb} bind def
/col31 {1.000 0.840 0.000 srgb} bind def
end
save
-17.0 331.0 translate
1 -1 scale
/clp {closepath} bind def
/ef {eofill} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/l {lineto} bind def
/m {moveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/tr {translate} bind def
/tnt {dup dup currentrgbcolor
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
bind def
/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
4 -2 roll mul srgb} bind def
/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def
$F2psBegin
10 setmiterlimit
0.06000 0.06000 sc
/Times-Roman findfont 240.00 scalefont setfont
1650 3990 m
gs 1 -1 sc (pg_class ....) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
3750 2415 m
gs 1 -1 sc ([shared classes]) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
3750 2115 m
gs 1 -1 sc (pg_log) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
3750 4215 m
gs 1 -1 sc ([private classes]) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
3750 3990 m
gs 1 -1 sc (pg_class ....) col-1 show gr
7.500 slw
% Polyline
n 2850 1665 m 1575 1890 l gs col-1 s gr
% Polyline
n 2850 1665 m 2475 1890 l gs col-1 s gr
% Polyline
n 1500 2265 m 1050 2790 l gs col-1 s gr
% Polyline
n 2475 2265 m 2475 2790 l gs col-1 s gr
% Polyline
n 2850 1680 m 4050 1905 l gs col-1 s gr
% Polyline
n 2475 2265 m 4500 2790 l gs col-1 s gr
% Polyline
n 4575 3165 m 4575 3690 l gs col-1 s gr
% Polyline
n 2475 3165 m 2475 3690 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
1350 2190 m
gs 1 -1 sc (files) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
2250 2190 m
gs 1 -1 sc (base) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
1950 3090 m
gs 1 -1 sc (template1) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
2625 1590 m
gs 1 -1 sc (data) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
450 3090 m
gs 1 -1 sc ([.bki files]) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
3225 3090 m
gs 1 -1 sc ( ) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
4500 2190 m
gs 1 -1 sc (....) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
4275 3090 m
gs 1 -1 sc (mydb ....) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
6600 4875 m
gs 1 -1 sc (EXECUTABLE) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
6600 5175 m
gs 1 -1 sc (PROGRAMS) col-1 show gr
% Polyline
n 7800 465 m 10125 1290 l gs col-1 s gr
% Polyline
n 10125 1665 m 10125 1890 l gs col-1 s gr
% Polyline
n 7800 465 m 11475 1290 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
1650 4215 m
gs 1 -1 sc ([private classes]) col-1 show gr
% Polyline
n 11475 1665 m 11475 1890 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
11100 2190 m
gs 1 -1 sc (libpq-fe.h ....) col-1 show gr
% Polyline
n 7800 465 m 12675 1290 l gs col-1 s gr
% Polyline
n 7800 465 m 13650 1290 l gs col-1 s gr
% Polyline
n 7800 450 m 2850 1275 l gs col-1 s gr
% Polyline
n 7800 450 m 7350 1275 l gs col-1 s gr
% Polyline
n 300 4500 m 5550 4500 l gs col-1 s gr
% Polyline
n 300 4575 m 5550 4575 l gs col-1 s gr
% Polyline
n 5775 4500 m 9600 4500 l gs col-1 s gr
% Polyline
n 5775 4575 m 9600 4575 l gs col-1 s gr
% Polyline
n 9825 4500 m 14025 4500 l gs col-1 s gr
% Polyline
n 9825 4575 m 14025 4575 l gs col-1 s gr
% Polyline
n 7350 1665 m 6225 1890 l gs col-1 s gr
% Polyline
n 7350 1665 m 7275 1890 l gs col-1 s gr
% Polyline
n 7350 1665 m 8475 1890 l gs col-1 s gr
/Times-Roman findfont 240.00 scalefont setfont
9825 2190 m
gs 1 -1 sc (libpq.a) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
9975 1590 m
gs 1 -1 sc (lib) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
11100 1590 m
gs 1 -1 sc (include) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
12600 1590 m
gs 1 -1 sc (src) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
13500 1590 m
gs 1 -1 sc (doc) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
7350 390 m
gs 1 -1 sc (postgres) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
2400 4950 m
gs 1 -1 sc (DATA) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
10950 5175 m
gs 1 -1 sc (DEVELOPMENT) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
10950 4875 m
gs 1 -1 sc (APPLICATION ) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
10950 5475 m
gs 1 -1 sc (ENVIRONMENT) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
7200 1590 m
gs 1 -1 sc (bin) col-1 show gr
/Times-Roman findfont 240.00 scalefont setfont
5775 2190 m
gs 1 -1 sc ( psql postgres postmaster....) col-1 show gr
$F2psEnd
restore
%%EndDocument
end PEND/F6 11/Times-Bold@0 SF(Figur)214.358 662.561 Q 2.75(e2)-.198 G
F1(.)-2.75 E F2(POSTGRES)5.5 E F1(\214le layout.)2.75 E 77.5 675.761 72
675.761 DL 80.5 675.761 75 675.761 DL 86 675.761 80.5 675.761 DL 91.5
675.761 86 675.761 DL 97 675.761 91.5 675.761 DL 102.5 675.761 97
675.761 DL 108 675.761 102.5 675.761 DL 113.5 675.761 108 675.761 DL 119
675.761 113.5 675.761 DL 124.5 675.761 119 675.761 DL 130 675.761 124.5
675.761 DL 135.5 675.761 130 675.761 DL 141 675.761 135.5 675.761 DL
146.5 675.761 141 675.761 DL 152 675.761 146.5 675.761 DL 157.5 675.761
152 675.761 DL 163 675.761 157.5 675.761 DL 168.5 675.761 163 675.761 DL
174 675.761 168.5 675.761 DL 179.5 675.761 174 675.761 DL 185 675.761
179.5 675.761 DL 190.5 675.761 185 675.761 DL 196 675.761 190.5 675.761
DL 201.5 675.761 196 675.761 DL 207 675.761 201.5 675.761 DL 212.5
675.761 207 675.761 DL 218 675.761 212.5 675.761 DL 223.5 675.761 218
675.761 DL 229 675.761 223.5 675.761 DL 234.5 675.761 229 675.761 DL 240
675.761 234.5 675.761 DL 245.5 675.761 240 675.761 DL 251 675.761 245.5
675.761 DL 256.5 675.761 251 675.761 DL 262 675.761 256.5 675.761 DL
267.5 675.761 262 675.761 DL 273 675.761 267.5 675.761 DL 278.5 675.761
273 675.761 DL 284 675.761 278.5 675.761 DL 289.5 675.761 284 675.761 DL
295 675.761 289.5 675.761 DL 300.5 675.761 295 675.761 DL 306 675.761
300.5 675.761 DL 311.5 675.761 306 675.761 DL 317 675.761 311.5 675.761
DL 322.5 675.761 317 675.761 DL 328 675.761 322.5 675.761 DL 333.5
675.761 328 675.761 DL 339 675.761 333.5 675.761 DL 344.5 675.761 339
675.761 DL 350 675.761 344.5 675.761 DL 355.5 675.761 350 675.761 DL 361
675.761 355.5 675.761 DL 366.5 675.761 361 675.761 DL 372 675.761 366.5
675.761 DL 377.5 675.761 372 675.761 DL 383 675.761 377.5 675.761 DL
388.5 675.761 383 675.761 DL 394 675.761 388.5 675.761 DL 399.5 675.761
394 675.761 DL 405 675.761 399.5 675.761 DL 410.5 675.761 405 675.761 DL
416 675.761 410.5 675.761 DL 421.5 675.761 416 675.761 DL 427 675.761
421.5 675.761 DL 432.5 675.761 427 675.761 DL 438 675.761 432.5 675.761
DL 443.5 675.761 438 675.761 DL 449 675.761 443.5 675.761 DL 454.5
675.761 449 675.761 DL 460 675.761 454.5 675.761 DL 465.5 675.761 460
675.761 DL 471 675.761 465.5 675.761 DL 476.5 675.761 471 675.761 DL 482
675.761 476.5 675.761 DL 487.5 675.761 482 675.761 DL 493 675.761 487.5
675.761 DL 498.5 675.761 493 675.761 DL 504 675.761 498.5 675.761 DL F6
(7)285.25 756 Q EP
%%Page: 8 8
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF .856(Figure 2 sho)108 97.2 R .856(ws ho)-.275 F
3.606(wt)-.275 G(he)-3.606 E/F1 10/Times-Roman@0 SF(POSTGRES)3.606 E F0
(distrib)3.606 E .856(ution is laid out when installed in the def)-.22 F
(ault)-.11 E -.11(wa)108 110.4 S 2.629 -.715(y. F).11 H 1.199
(or simplicity).55 F 3.949(,w)-.715 G 3.949(ew)-3.949 G 1.199
(ill assume that)-3.949 F F1(POSTGRES)3.949 E F0 1.198
(has been installed in the directory)3.949 F/F2 11/Courier@0 SF
(/usr/local/postgres95)108 123.6 Q F0 16.351(.T)C 10.851
(herefore, where)-16.351 F -.165(ve)-.275 G 13.601(ry).165 G 10.852
(ou see the directory)-13.601 F F2(/usr/local/postgres95)108 136.8 Q F0
2.02(you should substitute the name of the directory where)4.771 F F1
(POSTGRES)108 150 Q F0(is actually installed.)2.75 E(All)108 167.1 Q F1
(POSTGRES)24.549 E F0 21.8(commands are installed in the directory)24.55
F F2(/usr/local/postgres95/bin)108 180.3 Q F0 6.918(.T)C 1.418
(herefore, you should add this directory to your)-6.918 F(shell)108
193.5 Q/F3 11/Times-Italic@0 SF .391(command path)3.141 F F0 5.891(.I)C
3.141(fy)-5.891 G .391(ou use a v)-3.141 F .391(ariant of the Berk)-.275
F(ele)-.11 E 3.142(yCs)-.165 G .392(hell, such as)-3.142 F F2(csh)3.142
E F0(or)3.142 E F2(tcsh)3.142 E F0(,)A(you w)108 206.7 Q(ould add)-.11 E
/F4 10/Courier@0 SF 6(%s)148 231.9 S
(et path = \( /usr/local/postgres95/bin $path \))-6 E F0 .213(in the)108
258.1 R F2(.login)2.963 E F0 .212(\214le in your home directory)2.963 F
5.712(.I)-.715 G 2.962(fy)-5.712 G .212(ou use a v)-2.962 F .212
(ariant of the Bourne shell, such)-.275 F(as)108 271.3 Q F2(sh)2.75 E F0
(,)A F2(ksh)2.75 E F0 2.75(,o)C(r)-2.75 E F2(bash)2.75 E F0 2.75(,t)C
(hen you w)-2.75 E(ould add)-.11 E F4 6(%P)148 296.5 S
(ATH=/usr/local/postgres95/bin:$PATH)-6 E 6(%e)148 308.7 S(xport PATH)-6
E F0(to the)108 334.9 Q F2(.profile)2.75 E F0
(\214le in your home directory)2.75 E(.)-.715 E .322(From no)108 352 R
3.072(wo)-.275 G .322(n, we will assume that you ha)-3.072 F .652 -.165
(ve a)-.22 H .323(dded the).165 F F1(POSTGRES)3.073 E F2(bin)3.073 E F0
.323(directory to your)3.073 F 2.893(path. In)108 365.2 R .143
(addition, we will mak)2.893 F 2.893(ef)-.11 G .143
(requent reference to \231setting a shell v)-2.893 F .143
(ariable\232 or \231setting)-.275 F .826(an en)108 378.4 R .826
(vironment v)-.44 F .827(ariable\232 throughout this document.)-.275 F
.827(If you did not fully understand the)6.327 F .056
(last paragraph on modifying your search path, you should consult the)
108 391.6 R F1(UNIX)2.806 E F0 .056(manual pages)2.806 F
(that describe your shell before going an)108 404.8 Q 2.75(yf)-.165 G
(urther)-2.75 E(.)-.605 E/F5 12/Times-Bold@0 SF 3(3.2. Admin:)72 431 R
(Starting the P)3 E(ostmaster)-.24 E F0 1.227(It should be clear from t\
he preceding discussion that nothing can happen to a database)108 448.1
R .602(unless the)108 461.3 R F2(postmaster)3.352 E F0 .602
(process is running.)3.352 F .602(As the site administrator)6.102 F
3.351(,t)-.44 G .601(here are a num-)-3.351 F 1.686
(ber of things you should remember before starting the)108 474.5 R F2
(postmaster)4.436 E F0 7.186(.T)C 1.686(hese are dis-)-7.186 F 2.24
(cussed in the section of this manual titled, \231)108 487.7 R
(Administering)-.88 E F1(POSTGRES)4.989 E F0 6.529 -.77(.\232 H)D -.275
(ow).77 G -2.365 -.275(ev e).275 H 3.119 -.44(r, i).275 H(f).44 E F1
(POSTGRES)108 500.9 Q F0 .106(has been installed by follo)2.856 F .107
(wing the installation instructions e)-.275 F .107(xactly as written,)
-.165 F(the follo)108 514.1 Q
(wing simple command is all you should need to start the)-.275 E F2
(postmaster)2.75 E F0(:)A F4 6(%p)148 539.3 S(ostmaster &)-6 E F0(The)
108 569.4 Q F2(postmaster)3.005 E F0 .255
(occasionally prints out messages which are often helpful during trou-)
3.005 F 3.201(bleshooting. If)108 582.6 R .451(you wish to vie)3.201 F
3.201(wd)-.275 G(eb)-3.201 E .451(ugging messages from the postmaster)
-.22 F 3.201(,y)-.44 G .451(ou can start)-3.201 F
(it with the -d option and redirect the output to the log \214le:)108
595.8 Q F4 6(%p)148 621 S(ostmaster -d >& pm.log &)-6 E F0
(If you do not wish to see these messages, you can type)108 647.2 Q F4 6
(%p)148 672.4 S(ostmaster -S)-6 E F0 .921(and the)108 698.6 R F2
(postmaster)3.671 E F0 .921(will be \231S\232ilent.)3.671 F .921
(Notice that there is no ampersand \(\231&\232\) at the)6.421 F
(end of the last e)108 711.8 Q(xample.)-.165 E/F6 11/Times-Bold@0 SF(8)
285.25 756 Q EP
%%Page: 9 9
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(3.3. Admin:)72 97.2 R
(Adding and Deleting Users)3 E/F1 11/Times-Roman@0 SF(The)108 114.3 Q/F2
11/Courier@0 SF(createuser)7.893 E F1 5.144
(command enables speci\214c users to access)7.894 F/F3 10/Times-Roman@0
SF(POSTGRES)7.894 E F1 10.644(.T)C(he)-10.644 E F2(destroyuser)108 127.5
Q F1 .524(command remo)3.274 F -.165(ve)-.165 G 3.274(su).165 G .524
(sers and pre)-3.274 F -.165(ve)-.275 G .524(nts them from accessing)
.165 F F3(POSTGRES)3.273 E F1(.)A 1.744
(Note that these commands only af)108 140.7 R 1.744
(fect users with respect to)-.275 F F3(POSTGRES)4.495 E F1 4.495(;t)C
(he)-4.495 E 4.495(yh)-.165 G -2.475 -.22(av e)-4.495 H(no)4.715 E(ef)
108 153.9 Q
(fect administration of users that the operating system manages.)-.275 E
F0 3(3.4. User:)72 180.1 R(Starting A)3 E(pplications)-.3 E F1 .087
(Assuming that your site administrator has properly started the)108
197.2 R F2(postmaster)2.837 E F1 .087(process and)2.837 F .186
(authorized you to use the database, you \(as a user\) may be)108 210.4
R .187(gin to start up applications.)-.165 F(As)5.687 E(pre)108 223.6 Q
.303(viously mentioned, you should add)-.275 F F2
(/usr/local/postgres95/bin)3.052 E F1 .302(to your shell)3.052 F
(search path.)108 239 Q(In most cases, this is all you should ha)5.5 E
.33 -.165(ve t)-.22 H 2.75(od).165 G 2.75(oi)-2.75 G 2.75(nt)-2.75 G
(erms of preparation.)-2.75 E/F4 8/Times-Roman@0 SF(1)-4.4 I F1 1.245
(If you get the follo)108 256.1 R 1.245(wing error message from a)-.275
F F3(POSTGRES)3.995 E F1 1.245(command \(such as)3.995 F F2(psql)3.995 E
F1(or)3.996 E F2(createdb)108 269.3 Q F1(\):)A/F5 10/Courier@0 SF(conne\
ctDB\(\) failed: Is the postmaster running at 'localhost' on port '4322\
'?)148 294.5 Q F1 1.103(it is usually because \(1\) the)108 320.7 R F2
(postmaster)3.852 E F1 1.102
(is not running, or \(2\) you are attempting to)3.852 F
(connect to the wrong serv)108 333.9 Q(er host.)-.165 E
(If you get the follo)108 351 Q(wing error message:)-.275 E F5
(FATAL 1:Feb 17 23:19:55:process userid \(2360\) !=)148 376.2 Q
(database owner \(268\))160 388.4 Q F1 .188
(it means that the site administrator started the)108 414.6 R F2
(postmaster)2.938 E F1 .188(as the wrong user)2.938 F 5.688(.T)-.605 G
.188(ell him)-6.458 F(to restart it as the)108 427.8 Q F3(POSTGRES)2.75
E F1(superuser)2.75 E(.)-.605 E F0 3(3.5. User:)72 454 R
(Managing a Database)3 E F1(No)108 471.1 Q 2.859(wt)-.275 G(hat)-2.859 E
F3(POSTGRES)2.859 E F1 .109
(is up and running we can create some databases to e)2.859 F .108
(xperiment with.)-.165 F
(Here, we describe the basic commands for managing a database.)108 484.3
Q F0 3(3.5.1. Cr)72 510.5 R(eating a Database)-.216 E F1(Let')108 527.6
Q 2.96(ss)-.605 G .21(ay you w)-2.96 F .21
(ant to create a database named)-.11 F F2(mydb)2.96 E F1 5.71(.Y)C .211
(ou can do this with the follo)-6.92 F(wing)-.275 E(command:)108 540.8 Q
F5 6(%c)148 566 S(reatedb mydb)-6 E F3(POSTGRES)108 592.2 Q F1(allo)2.8
E .05(ws you to create an)-.275 F 2.8(yn)-.165 G .05
(umber of databases at a gi)-2.8 F -.165(ve)-.275 G 2.799(ns).165 G .049
(ite and you automat-)-2.799 F 2.104(ically become the)108 605.4 R/F6 11
/Times-Italic@0 SF 2.104(database administr)4.854 F(ator)-.165 E F1
2.104(of the database you just created.)4.854 F(Database)7.604 E
(names must ha)108 618.6 Q .33 -.165(ve a)-.22 H 2.75(na).165 G(lphabet\
ic \214rst character and are limited to 16 characters in length.)-2.75 E
.32 LW 76 638.6 72 638.6 DL 80 638.6 76 638.6 DL 84 638.6 80 638.6 DL 88
638.6 84 638.6 DL 92 638.6 88 638.6 DL 96 638.6 92 638.6 DL 100 638.6 96
638.6 DL 104 638.6 100 638.6 DL 108 638.6 104 638.6 DL 112 638.6 108
638.6 DL 116 638.6 112 638.6 DL 120 638.6 116 638.6 DL 124 638.6 120
638.6 DL 128 638.6 124 638.6 DL 132 638.6 128 638.6 DL 136 638.6 132
638.6 DL 140 638.6 136 638.6 DL 144 638.6 140 638.6 DL 148 638.6 144
638.6 DL 152 638.6 148 638.6 DL 156 638.6 152 638.6 DL 160 638.6 156
638.6 DL 164 638.6 160 638.6 DL 168 638.6 164 638.6 DL 172 638.6 168
638.6 DL 176 638.6 172 638.6 DL 180 638.6 176 638.6 DL 184 638.6 180
638.6 DL 188 638.6 184 638.6 DL 192 638.6 188 638.6 DL 196 638.6 192
638.6 DL 200 638.6 196 638.6 DL 204 638.6 200 638.6 DL 208 638.6 204
638.6 DL 212 638.6 208 638.6 DL 216 638.6 212 638.6 DL/F7 5
/Times-Roman@0 SF(1)93.6 649 Q F4 .431
(If your site administrator has not set things up in the def)2.431 3.2 N
.431(ault w)-.08 F(ay)-.08 E 2.431(,y)-.52 G .431(ou may ha)-2.431 F
.671 -.12(ve s)-.16 H .431(ome more w).12 F .431(ork to do.)-.08 F -.12
(Fo)4.432 G 2.432(re).12 G .432(xample, if the)-2.552 F .068
(database serv)72 661.8 R .068
(er machine is a remote machine, you will need to set the)-.12 F/F8 8
/Courier@0 SF(PGHOST)2.068 E F4(en)2.068 E .067(vironment v)-.32 F .067
(ariable to the name of the database serv-)-.2 F .131(er machine.)72
671.4 R .131(The en)4.131 F .131(vironment v)-.32 F(ariable)-.2 E F8
(PGPORT)2.131 E F4 .131(may also ha)2.131 F .372 -.12(ve t)-.16 H 2.132
(ob).12 G 2.132(es)-2.132 G 2.132(et. The)-2.132 F .132
(bottom line is this: if you try to start an application pro-)2.132 F
.614(gram and it complains that it cannot connect to the)72 681 R F8
(postmaster)2.613 E F4 2.613(,y)C .613
(ou should immediately consult your site administrator to mak)-2.613 F
(e)-.08 E(sure that your en)72 690.6 Q(vironment is properly set up.)
-.32 E/F9 11/Times-Bold@0 SF(9)285.25 756 Q EP
%%Page: 10 10
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF 2.528(Not e)108 97.2 R -.165(ve)-.275 G 2.528
(ry user has authorization to become a database administrator).165 F
8.027(.I)-.605 G(f)-8.027 E/F1 10/Times-Roman@0 SF(POSTGRES)5.277 E F0
.333(refuses to create databases for you, then the site administrator n\
eeds to grant you permis-)108 110.4 R(sion to create databases.)108
123.6 Q(Consult your site administrator if this occurs.)5.5 E/F2 12
/Times-Bold@0 SF 3(3.5.2. Accessing)72 149.8 R 3(aD)3 G(atabase)-3 E F0
(Once you ha)108 166.9 Q .33 -.165(ve c)-.22 H
(onstructed a database, you can access it by:).165 E 5.5<8372>113.5 184
S 2.696(unning the)-5.5 F F1(POSTGRES)5.446 E F0 2.696
(terminal monitor programs \()5.446 F/F3 11/Courier@0 SF(monitor)5.446 E
F0(or)5.445 E F3(psql)5.445 E F0 5.445(\)w)C(hich)-5.445 E(allo)122.85
197.2 Q(ws you to interacti)-.275 E -.165(ve)-.275 G(ly enter).165 E
2.75(,e)-.44 G(dit, and e)-2.75 E -.165(xe)-.165 G(cute SQL commands.)
.165 E 5.5<8377>113.5 210.4 S 1.107(riting a C program using the)-5.5 F
F1(LIBPQ)3.857 E F0 1.107(subroutine library)3.857 F 6.607(.T)-.715 G
1.108(his allo)-6.607 F 1.108(ws you to submit)-.275 F .883(SQL command\
s from C and get answers and status messages back to your program.)
122.85 223.6 R(This interf)122.85 236.8 Q
(ace is discussed further in section ??.)-.11 E -1.21(Yo)108 253.9 S
3.472(um)1.21 G .722(ight w)-3.472 F .722(ant to start up)-.11 F F3
(psql)3.472 E F0 3.472(,t)C 3.472(ot)-3.472 G .722(ry out the e)-3.472 F
.723(xamples in this manual. It can be acti-)-.165 F -.275(va)108 267.1
S(ted for the).275 E F3(mydb)2.75 E F0(database by typing the command:)
2.75 E/F4 10/Courier@0 SF 6(%p)148 292.3 S(sql mydb)-6 E F0 -1.21(Yo)108
318.5 S 2.75(uw)1.21 G(ill be greeted with the follo)-2.75 E
(wing message:)-.275 E F4
(Welcome to the POSTGRES95 interactive sql monitor:)148 343.7 Q
(type \\? for help on slash commands)166 368.1 Q(type \\q to quit)166
380.3 Q(type \\g or terminate with semicolon to execute query)166 392.5
Q(You are currently connected to the database: mydb)154 404.7 Q(mydb=>)
148 429.1 Q F0 .632(This prompt indicates that the terminal monitor is \
listening to you and that you can type)108 455.3 R(SQL queries into a w)
108 468.5 Q(orkspace maintained by the terminal monitor)-.11 E(.)-.605 E
(The)108 485.6 Q F3(psql)2.959 E F0 .209
(program responds to escape codes that be)2.959 F .209
(gin with the backslash character)-.165 F 2.959<2c99>-.44 G<5c9a2e>
-2.959 E -.165(Fo)108 498.8 S 3.786(re).165 G 1.035
(xample, you can get help on the syntax of v)-3.951 F(arious)-.275 E F1
(POSTGRES)3.785 E F0 1.035(SQL commands by)3.785 F(typing:)108 512 Q F4
(mydb=> \\h)148 537.2 Q F0 .761(Once you ha)108 563.4 R 1.091 -.165
(ve \214)-.22 H .761(nished entering your queries into the w).165 F .762
(orkspace, you can pass the con-)-.11 F(tents of the w)108 576.6 Q
(orkspace to the)-.11 E F1(POSTGRES)2.75 E F0(serv)2.75 E(er by typing:)
-.165 E F4(mydb=> \\g)148 601.8 Q F0 .593(This tells the serv)108 628 R
.593(er to process the query)-.165 F 6.093(.I)-.715 G 3.342(fy)-6.093 G
.592(ou terminate your query with a semicolon,)-3.342 F
(the \\g is not necessary)108 641.2 Q 5.5(.P)-.715 G
(sql will automatically process semicolon-terminated queries.)-5.5 E
1.76 -.88(To r)108 658.3 T(ead queries from a \214le, say).88 E F3
(myFile,)2.75 E F0(instead of entering them interacti)2.75 E -.165(ve)
-.275 G(ly).165 E 2.75(,t)-.715 G(ype:)-2.75 E F4(mydb=> \\i fileName)
148 683.5 Q F0 1.76 -.88(To g)108 709.7 T(et out of psql and return to)
.88 E F1(UNIX)2.75 E F0 2.75(,t)C(ype)-2.75 E/F5 11/Times-Bold@0 SF(10)
282.5 756 Q EP
%%Page: 11 11
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(mydb=> \\q)148 96.2 Q/F1 11/Times-Roman@0 SF(and)108
122.4 Q/F2 11/Courier@0 SF(psql)3.184 E F1 .434
(will quit and return you to your command shell. \(F)3.184 F .434
(or more escape codes, type)-.165 F F2(\\h)108 135.6 Q F1(at the)2.75 E
F2(monitor)2.75 E F1(prompt.\))2.75 E .855
(White space \(i.e., spaces, tabs and ne)108 152.7 R .855
(wlines\) may be used freely in SQL queries.)-.275 F(Com-)6.354 E .099
(ments are denoted by)108 165.9 R F2(--)2.849 E F1 5.599(.E)C -.165(ve)
-5.599 G .1
(rything after the dashes up to the end of the line is ignored.).165 F
/F3 12/Times-Bold@0 SF 3(3.5.3. Destr)72 183 R(oying a Database)-.216 E
F1 .453(If you are the database administrator for the database)108 200.1
R F2(mydb)3.202 E F1 3.202(,y)C .452(ou can destro)-3.202 F 3.202(yi)
-.11 G 3.202(tu)-3.202 G .452(sing the)-3.202 F(follo)108 213.3 Q(wing)
-.275 E/F4 10/Times-Roman@0 SF(UNIX)2.75 E F1(command:)2.75 E F0 6(%d)
148 238.5 S(estroydb mydb)-6 E F1 .08(This action ph)108 264.7 R .08
(ysically remo)-.055 F -.165(ve)-.165 G 2.83(sa).165 G .08(ll of the)
-2.83 F F4(UNIX)2.83 E F1 .081
(\214les associated with the database and can-)2.83 F(not be undone, so\
this should only be done with a great deal of forethought.)108 277.9 Q
/F5 11/Times-Bold@0 SF(11)282.5 756 Q EP
%%Page: 12 12
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(4. THE)72 165.4 R -.19(QU)4.75 G(ER)
.19 E 4.75(YL)-.665 G(ANGU)-4.75 E -1.045(AG)-1.14 G(E)1.045 E 77.5
178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5
178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108
178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL
124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6
DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5
178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6
163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6
179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5
178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218
178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL
234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6
DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5
178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6
273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6
289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5
178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328
178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL
344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6
DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5
178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6
383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6
399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5
178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438
178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL
454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6
DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5
178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6
493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF(The)108
208.9 Q/F2 10/Times-Roman@0 SF(POSTGRES)3.209 E F1 .459
(query language is a v)3.209 F .459(ariant of SQL-3. It has man)-.275 F
3.209(ye)-.165 G .458(xtensions such as an)-3.374 F -.165(ex)108 222.1 S
1.643(tensible type system, inheritance, functions and production rules\
. Those are features).165 F .139(carried o)108 235.3 R -.165(ve)-.165 G
2.889(rf).165 G .139(rom the original)-2.889 F F2(POSTGRES)2.889 E F1
.139(query language, POSTQ)2.889 F .138(UEL. This section pro-)-.11 F
(vides an o)108 248.5 Q -.165(ve)-.165 G(rvie).165 E 2.75(wo)-.275 G
2.75(fh)-2.75 G .55 -.275(ow t)-2.75 H 2.75(ou).275 G(se)-2.75 E F2
(POSTGRES)2.75 E F1(SQL to perform simple operations.)2.75 E .357
(This manual is only intended to gi)108 265.6 R .687 -.165(ve y)-.275 H
.357(ou an idea of our \215a).165 F -.22(vo)-.22 G 3.107(ro).22 G 3.107
(fS)-3.107 G .357(QL and is in no w)-3.107 F .357(ay a)-.11 F .093
(complete tutorial on SQL. Numerous books ha)108 278.8 R .423 -.165
(ve b)-.22 H .093(een written on SQL. F).165 F .093(or instance, con-)
-.165 F .283(sult [MEL)108 292 R .283(T93] or [D)-1.012 F -1.221(AT)-.44
G .283(E93]. Y)1.221 F .283(ou should also be a)-1.21 F -.11(wa)-.165 G
.283(re that some features are not part of).11 F(the ANSI standard.)108
305.2 Q 2.094(In the e)108 322.3 R 2.093(xamples that follo)-.165 F
3.523 -.715(w, w)-.275 H 4.843(ea).715 G 2.093(ssume that you ha)-4.843
F 2.423 -.165(ve c)-.22 H 2.093(reated the).165 F/F3 11/Courier@0 SF
(mydb)4.843 E F1 2.093(database as)4.843 F(described in the pre)108
335.5 Q(vious subsection and ha)-.275 E .33 -.165(ve s)-.22 H
(tarted psql.).165 E 24.523
(Examples in this manual can also be found in)108 352.6 R F3
(/usr/local/postgres95/src/tutorial)108 365.8 Q F1 7.623(.R)C 2.123
(efer to the README \214le in that)-7.623 F(directory for ho)108 379 Q
2.75(wt)-.275 G 2.75(ou)-2.75 G(se them.)-2.75 E 1.76 -.88(To s)5.5 H
(tart the tutorial, do the follo).88 E(wing:)-.275 E/F4 10/Courier@0 SF
6(%c)148 404.2 S 6(d/)-6 G(usr/local/postgres95/src/tutorial)-6 E 6(%p)
148 416.4 S(sql -s mydb)-6 E
(Welcome to the POSTGRES95 interactive sql monitor:)148 428.6 Q
(type \\? for help on slash commands)166 453 Q(type \\q to quit)166
465.2 Q(type \\g or terminate with semicolon to execute query)166 477.4
Q(You are currently connected to the database: jolly)154 489.6 Q
(mydb=> \\i basics.sql)148 526.2 Q F1(The)108 556.3 Q F3(\\i)3.107 E F1
.357(command read in queries from the speci\214ed \214les. The)3.107 F
F3(-s)3.108 E F1 .358(option puts you in sin-)3.108 F .868
(gle step mode which pauses before sending a query to the back)108 569.5
R .868(end. Queries in this sec-)-.11 F(tion are in the \214le)108 582.7
Q F3(basics.sql)2.75 E F1(.)A/F5 12/Times-Bold@0 SF 3(4.1. Concepts)72
608.9 R F1 .824(The fundamental notion in)108 626 R F2(POSTGRES)3.574 E
F1 .824(is that of a)3.574 F/F6 11/Times-Italic@0 SF(class,)3.574 E F1
.824(which is a named collection of)3.574 F(object)108 639.2 Q F6
(instances)4.277 E F1 7.027(.E)C 1.526
(ach instance has the same collection of named)-7.027 F F6(attrib)4.276
E(utes)-.22 E F1 4.276(,a)C 1.526(nd each)-4.276 F(attrib)108 652.4 Q
.728(ute is of a speci\214c)-.22 F F6(type)3.478 E F1 6.228(.F)C .729
(urthermore, each instance has a permanent)-6.228 F F6 .729
(object identi-)3.479 F(\214er)108 665.6 Q F1 .004
(\(OID\) that is unique throughout the installation.)2.754 F .003
(Because SQL syntax refers to)5.503 F F6(tables,)2.753 E F1 .191
(we will use the terms)108 678.8 R F6(table)2.941 E F1(and)2.941 E F6
(class)2.941 E F1(interchangeably)2.941 E 5.691(.L)-.715 G(ik)-5.691 E
-.275(ew)-.11 G .192(ise, a).275 F F6 -.495(ro)2.942 G(w).495 E F1 .192
(is an)2.942 F F6(instance)2.942 E F1(and)2.942 E F6(columns)108 692 Q
F1(are)2.75 E F6(attrib)2.75 E(utes.)-.22 E F1 .183(As pre)108 709.1 R
.182(viously discussed, classes are grouped into databases, and a colle\
ction of databases)-.275 F(managed by a single)108 722.3 Q F3
(postmaster)2.75 E F1(process constitutes an installation or site.)2.75
E/F7 11/Times-Bold@0 SF(12)282.5 756 Q EP
%%Page: 13 13
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(4.2. Cr)72 97.2 R(eating a New Class)-.216 E/F1
11/Times-Roman@0 SF -1.21(Yo)108 114.3 S 3.643(uc)1.21 G .893
(an create a ne)-3.643 F 3.643(wc)-.275 G .893
(lass by specifying the class name, along with all attrib)-3.643 F .894
(ute names)-.22 F(and their types:)108 127.5 Q/F2 10/Courier@0 SF
(CREATE TABLE weather \()148 152.7 Q 66(city varchar\(80\),)196 164.9 R
48(temp_lo int,)196 177.1 R(-- low temperature)66 E 48(temp_hi int,)196
189.3 R(-- high temperature)66 E 66(prcp real,)196 201.5 R
(-- precipitation)54 E 66(date date)196 213.7 R(\);)160 225.9 Q F1 2.323
(Note that k)108 256 R -.165(ey)-.11 G -.11(wo).165 G 2.323
(rds are case-insensiti).11 F 2.653 -.165(ve b)-.275 H 2.323
(ut identi\214ers are case-sensiti)-.055 F -.165(ve)-.275 G(.).165 E/F3
10/Times-Roman@0 SF(POSTGRES)7.823 E F1 .214(SQL supports the usual SQL\
types int, \215oat, real, smallint, char\(N\), v)108 269.2 R .214
(archar\(N\), date, and)-.275 F 4.038(time. As)108 282.4 R 1.288
(we will see later)4.038 F(,)-.44 E F3(POSTGRES)4.038 E F1 1.287
(can be customized with an arbitrary number of)4.038 F(user)108 295.6 Q
(-de\214ned data types.)-.22 E(Consequently)5.5 E 2.75(,t)-.715 G
(ype names are not k)-2.75 E -.165(ey)-.11 G -.11(wo).165 G(rds.).11 E
.544(So f)108 312.7 R(ar)-.11 E 3.294(,t)-.44 G(he)-3.294 E F3(POSTGRES)
3.294 E/F4 11/Times-Bold@0 SF(cr)3.294 E(eate)-.198 E F1 .544
(command looks e)3.294 F .544(xactly lik)-.165 F 3.294(et)-.11 G .545
(he command used to create a)-3.294 F .688
(table in a traditional relational system.)108 325.9 R(Ho)6.188 E(we)
-.275 E -.165(ve)-.275 G 1.568 -.44(r, w).165 H 3.438(ew).44 G .688
(ill presently see that classes ha)-3.438 F -.165(ve)-.22 G
(properties that are e)108 339.1 Q(xtensions of the relational model.)
-.165 E F0 3(4.3. P)72 365.3 R(opulating a Class with Instances)-.24 E
F1(The)108 382.4 Q F4(insert)2.75 E F1
(statement is used to populate a class with instances:)2.75 E F2
(INSERT INTO weather)148 407.6 Q
(VALUES \('San Francisco', 46, 50, 0.25, '11/27/1994'\))166 419.8 Q F1
-1.21(Yo)108 449.9 S 4.457(uc)1.21 G 1.707(an also use the)-4.457 F F4
(copy)4.457 E F1 1.707(command to perform load lar)4.457 F 1.708
(ge amounts of data from \215at)-.198 F(\(ASCII\) \214les.)108 463.1 Q
F0 3(4.4. Querying)72 489.3 R 3(aC)3 G(lass)-3 E F1(The)108 506.4 Q/F5
11/Courier@0 SF(weather)5.528 E F1 2.778
(class can be queried with normal relational selection and projection)
5.528 F 3.033(queries. A)108 519.6 R F3(SQL)3.033 E F4(select)3.033 E F1
.284(statement is used to do this.)3.033 F .284(The statement is di)
5.784 F .284(vided into a)-.275 F/F6 11/Times-Italic@0 SF(tar)3.034 E
-.11(ge)-.407 G(t).11 E(list)108 532.8 Q F1 .208
(\(the part that lists the attrib)2.958 F .208
(utes to be returned\) and a)-.22 F F6(quali\214cation)2.957 E F1 .207
(\(the part that speci-)2.957 F(\214es an)108 546 Q 2.75(yr)-.165 G 2.75
(estrictions\). F)-2.75 F(or e)-.165 E(xample, to retrie)-.165 E .33
-.165(ve a)-.275 H(ll the ro).165 E(ws of)-.275 E F5(weather)2.75 E F1
2.75(,t)C(ype:)-2.75 E F2(SELECT * FROM WEATHER;)148 571.2 Q F1
(and the output should be:)108 596.4 Q .4 LW 464 613.9 148 613.9 DL F2
63(city temp_lo)153 623.6 R 9(temp_hi prcp date)15 F 464 628.1 148 628.1
DL(San Francisco)153 637.8 Q 39(46 50 0.25)15 F(11-27-1994)15 E 464
642.3 148 642.3 DL(San Francisco)153 652 Q 39(43 57 0)15 F(11-29-1994)33
E 464 656.5 148 656.5 DL 45(Hayward 37)153 666.2 R 78(54 11-29-1994)45 F
464 670.7 148 670.7 DL 464 613.9 464 670.7 DL 148 613.9 148 670.7 DL
391.5 613.9 391.5 670.7 DL 352.5 613.9 352.5 670.7 DL 295.5 613.9 295.5
670.7 DL 238.5 613.9 238.5 670.7 DL F1 -1.21(Yo)108 696.3 S 2.75(um)1.21
G(ay specify an)-2.75 E 2.75(ya)-.165 G(ribitrary e)-2.75 E
(xpressions in the tar)-.165 E(get list. F)-.198 E(or e)-.165 E
(xample, you can do:)-.165 E F4(13)282.5 756 Q EP
%%Page: 14 14
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF 6(*S)148 96.2 S
(ELECT city, \(temp_hi+temp_lo\)/2 AS temp_avg, date FROM weather;)-6 E
/F1 11/Times-Roman@0 SF 1.411(Arbitrary Boolean operators \()108 126.3 R
/F2 11/Times-Bold@0 SF(and)4.161 E F1(,)A F2(or)4.161 E F1(and)4.161 E
F2(not)4.161 E F1 4.161(\)a)C 1.411(re allo)-4.161 F 1.411
(wed in the quali\214cation of an)-.275 F(y)-.165 E(query)108 139.5 Q
5.5(.F)-.715 G(or e)-5.665 E(xample,)-.165 E F0(SELECT *)148 164.7 Q
(FROM weather)160 176.9 Q(WHERE city = 'San Francisco')160 189.1 Q
(and prcp > 0.0;)178 201.3 Q .4 LW 464 231.8 148 231.8 DL 63
(city temp_lo)153 241.5 R 9(temp_hi prcp date)15 F 464 246 148 246 DL
(San Francisco)153 255.7 Q 39(46 50 0.25)15 F(11-27-1994)15 E 464 260.2
148 260.2 DL 464 231.8 464 260.2 DL 148 231.8 148 260.2 DL 391.5 231.8
391.5 260.2 DL 352.5 231.8 352.5 260.2 DL 295.5 231.8 295.5 260.2 DL
238.5 231.8 238.5 260.2 DL F1 1.312
(As a \214nal note, you can specify that the results of a)108 285.8 R F2
(select)4.062 E F1 1.312(can be returned in a sorted)4.062 F
(order or with duplicate instances remo)108 299 Q -.165(ve)-.165 G(d.)
.165 E F0(SELECT DISTINCT city)148 324.2 Q(FROM weather)160 336.4 Q
(ORDER BY city;)160 348.6 Q/F3 12/Times-Bold@0 SF 3(4.5. Redir)72 387.8
R(ecting SELECT Queries)-.216 E F1(An)108 404.9 Q(y)-.165 E F2(select)
2.75 E F1(query can be redirected to a ne)2.75 E 2.75(wc)-.275 G(lass)
-2.75 E F0(SELECT * INTO temp from weather;)148 430.1 Q F1 1.177
(This creates an implicit)108 460.2 R F2(cr)3.928 E(eate)-.198 E F1
1.178(command, creating a ne)3.928 F 3.928(wc)-.275 G(lass)-3.928 E/F4
11/Courier@0 SF(temp)3.928 E F1 1.178(with the attrib)3.928 F(ute)-.22 E
1.316(names and types speci\214ed in the tar)108 473.4 R 1.315
(get list of the)-.198 F F2 1.315(SELECT INT)4.065 F(O)-.198 E F1 4.065
(command. W)4.065 F 4.065(ec)-.88 G(an)-4.065 E 1.632
(then, of course, perform an)108 486.6 R 4.383(yo)-.165 G 1.633
(perations on the resulting class that we can perform on)-4.383 F
(other classes.)108 499.8 Q F3 3(4.6. J)72 526 R(oins Between Classes)
-.18 E F1 .273(Thus f)108 543.1 R(ar)-.11 E 3.023(,o)-.44 G .273
(ur queries ha)-3.023 F .603 -.165(ve o)-.22 H .273
(nly accessed one class at a time.).165 F .272
(Queries can access multiple)5.773 F .191
(classes at once, or access the same class in such a w)108 556.3 R .191
(ay that multiple instances of the class)-.11 F 1.49
(are being processed at the same time.)108 569.5 R 4.24(Aq)6.99 G 1.489
(uery that accesses multiple instances of the)-4.24 F(same or dif)108
582.7 Q(ferent classes at one time is called a)-.275 E/F5 11
/Times-Italic@0 SF(join query)2.75 E F1(.)A 1.057(As an e)108 599.8 R
1.057(xample, say we wish to \214nd all the records that are in the tem\
perature range of)-.165 F 1.094(other records. In ef)108 613 R 1.093
(fect, we need to compare the)-.275 F F4(temp_lo)3.843 E F1(and)3.843 E
F4(temp_hi)3.843 E F1(attrib)3.843 E 1.093(utes of)-.22 F(each)108 628.4
Q F4(EMP)3.027 E F1 .277(instance to the)3.027 F F4(temp_lo)3.027 E F1
(and)3.027 E F4(temp_hi)3.027 E F1(attrib)3.027 E .277
(utes of all other)-.22 F F4(EMP)3.027 E F1(instances.)3.027 E/F6 8
/Times-Roman@0 SF(2)-4.4 I F1 1.76 -.88(We c)108 641.6 T
(an do this with the follo).88 E(wing query:)-.275 E F0
(SELECT W1.city, W1.temp_lo, W1.temp_hi,)148 666.8 Q
(W2.city, W2.temp_lo, W2.temp_hi)202 679 Q .32 LW 76 688.6 72 688.6 DL
80 688.6 76 688.6 DL 84 688.6 80 688.6 DL 88 688.6 84 688.6 DL 92 688.6
88 688.6 DL 96 688.6 92 688.6 DL 100 688.6 96 688.6 DL 104 688.6 100
688.6 DL 108 688.6 104 688.6 DL 112 688.6 108 688.6 DL 116 688.6 112
688.6 DL 120 688.6 116 688.6 DL 124 688.6 120 688.6 DL 128 688.6 124
688.6 DL 132 688.6 128 688.6 DL 136 688.6 132 688.6 DL 140 688.6 136
688.6 DL 144 688.6 140 688.6 DL 148 688.6 144 688.6 DL 152 688.6 148
688.6 DL 156 688.6 152 688.6 DL 160 688.6 156 688.6 DL 164 688.6 160
688.6 DL 168 688.6 164 688.6 DL 172 688.6 168 688.6 DL 176 688.6 172
688.6 DL 180 688.6 176 688.6 DL 184 688.6 180 688.6 DL 188 688.6 184
688.6 DL 192 688.6 188 688.6 DL 196 688.6 192 688.6 DL 200 688.6 196
688.6 DL 204 688.6 200 688.6 DL 208 688.6 204 688.6 DL 212 688.6 208
688.6 DL 216 688.6 212 688.6 DL/F7 5/Times-Roman@0 SF(2)93.6 699 Q F6
.094(This is only a conceptual model.)2.094 3.2 N .095
(The actual join may be performed in a more ef)4.095 F .095
(\214cient manner)-.2 F 2.095(,b)-.32 G .095(ut this is in)-2.255 F .095
(visible to the user)-.32 F(.)-.44 E F2(14)282.5 756 Q EP
%%Page: 15 15
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(FROM weather W1, weather W2)148 96.2 Q
(WHERE W1.temp_lo < W2.temp_lo)148 108.4 Q(and W1.temp_hi > W2.temp_hi;)
178 120.6 Q .4 LW 557 151.1 148 151.1 DL 63(city temp_lo)153 160.8 R 9
(temp_hi city)15 F 9(temp_lo temp_hi)69 F 557 165.3 148 165.3 DL
(San Francisco)153 175 Q 39(43 57 San)15 F 9(Francisco 46)6 F(50)45 E
557 179.5 148 179.5 DL(San Francisco)153 189.2 Q 39(37 54 San)15 F 9
(Francisco 46)6 F(50)45 E 557 193.7 148 193.7 DL 557 151.1 557 193.7 DL
148 151.1 148 193.7 DL 502.5 151.1 502.5 193.7 DL 445.5 151.1 445.5
193.7 DL 352.5 151.1 352.5 193.7 DL 295.5 151.1 295.5 193.7 DL 238.5
151.1 238.5 193.7 DL/F1 11/Times-Roman@0 SF .966(In this case, both)108
215.4 R/F2 11/Courier@0 SF(W1)3.716 E F1(and)3.716 E F2(W2)3.716 E F1
(are)3.716 E/F3 11/Times-Italic@0 SF(surr)3.716 E -.11(og)-.495 G(ates)
.11 E F1 .966(for an instance of the class)3.716 F F2(weather)3.716 E F1
3.716(,a)C(nd)-3.716 E .53(both range o)108 228.6 R -.165(ve)-.165 G
3.28(ra).165 G .53(ll instances of the class.)-3.28 F .529
(\(In the terminology of most database systems,)6.03 F F2(W1)108 241.8 Q
F1(and)3.184 E F2(W2)3.184 E F1 .434(are kno)3.184 F .434
(wn as \231range v)-.275 F(ariables.)-.275 E 3.184(\232\) A)-.77 F .434
(query can contain an arbitrary number of)3.184 F
(class names and surrog)108 257.2 Q(ates.)-.055 E/F4 8/Times-Roman@0 SF
(3)-4.4 I/F5 12/Times-Bold@0 SF 3(4.7. Updates)72 283.4 R F1 -1.21(Yo)
108 300.5 S 3.226(uc)1.21 G .476(an update e)-3.226 F .476
(xisting instances using the)-.165 F/F6 11/Times-Bold@0 SF(update)3.226
E F1 .475(command. Suppose you disco)3.226 F -.165(ve)-.165 G 3.225(rt)
.165 G(he)-3.225 E .94(temperature readings are all of)108 313.7 R 3.69
(fb)-.275 G 3.69(y2d)-3.69 G -.165(eg)-3.69 G .94(rees as of No).165 F
3.69(v2)-.165 G .94(8, you may update the data as)-3.69 F(follo)108
326.9 Q(w:)-.275 E F0 6(*U)148 352.1 S(PDATE weather)-6 E
(SET temp_hi = temp_hi - 2,)160 364.3 Q(temp_lo = temp_lo - 2)12 E
(WHERE date > '11/28/1994;)160 376.5 Q F5 3(4.8. Deletions)72 415.7 R F1
(Deletions are performed using the)108 432.8 Q F6(delete)2.75 E F1
(command:)2.75 E F0 6(*D)148 458 S
(ELETE FROM weather WHERE city = 'Hayward';)-6 E F1
(All weather recording belongs to Hayw)108 484.2 Q(ard is remo)-.11 E
-.165(ve)-.165 G(d.).165 E(One should be w)108 501.3 Q
(ary of queries of the form)-.11 E F0(DELETE FROM)148 526.5 Q/F7 10
/Times-Italic@0 SF(classname;)6 E F1 -.44(Wi)108 552.7 S .494
(thout a quali\214cation, the).44 F F6(delete)3.244 E F1 .493
(command will simply delete all instances of the gi)3.243 F -.165(ve)
-.275 G(n).165 E(class, lea)108 565.9 Q(ving it empty)-.22 E 5.5(.T)
-.715 G(he system)-5.5 E F6(will not r)2.75 E(equest con\214rmation)
-.198 E F1(before doing this.)2.75 E F5 3(4.9. Using)72 592.1 R(Aggr)3 E
(egate Functions)-.216 E F1(Lik)108 609.2 Q 2.854(em)-.11 G .104
(ost other query languages,)-2.854 F/F8 10/Times-Roman@0 SF(POSTGRES)
2.854 E F1 .104(supports aggre)2.854 F -.055(ga)-.165 G .104
(te functions.).055 F(Ho)5.604 E(we)-.275 E -.165(ve)-.275 G .985 -.44
(r, t).165 H(he).44 E 1.225(current implementation of)108 622.4 R F8
(POSTGRES)3.974 E F1(aggre)3.974 E -.055(ga)-.165 G 1.224
(te functions is v).055 F 1.224(ery limited.)-.165 F(Speci\214cally)
6.724 E(,)-.715 E 3.444(while there are aggre)108 635.6 R -.055(ga)-.165
G 3.444(tes to compute such functions as the count, sum, a).055 F -.165
(ve)-.22 G(rage,).165 E .32 LW 76 645.2 72 645.2 DL 80 645.2 76 645.2 DL
84 645.2 80 645.2 DL 88 645.2 84 645.2 DL 92 645.2 88 645.2 DL 96 645.2
92 645.2 DL 100 645.2 96 645.2 DL 104 645.2 100 645.2 DL 108 645.2 104
645.2 DL 112 645.2 108 645.2 DL 116 645.2 112 645.2 DL 120 645.2 116
645.2 DL 124 645.2 120 645.2 DL 128 645.2 124 645.2 DL 132 645.2 128
645.2 DL 136 645.2 132 645.2 DL 140 645.2 136 645.2 DL 144 645.2 140
645.2 DL 148 645.2 144 645.2 DL 152 645.2 148 645.2 DL 156 645.2 152
645.2 DL 160 645.2 156 645.2 DL 164 645.2 160 645.2 DL 168 645.2 164
645.2 DL 172 645.2 168 645.2 DL 176 645.2 172 645.2 DL 180 645.2 176
645.2 DL 184 645.2 180 645.2 DL 188 645.2 184 645.2 DL 192 645.2 188
645.2 DL 196 645.2 192 645.2 DL 200 645.2 196 645.2 DL 204 645.2 200
645.2 DL 208 645.2 204 645.2 DL 212 645.2 208 645.2 DL 216 645.2 212
645.2 DL/F9 5/Times-Roman@0 SF(3)93.6 655.6 Q F4 .265
(The semantics of such a join are that the quali\214cation is a truth e)
2.265 3.2 N .264
(xpression de\214ned for the Cartesian product of the classes in-)-.12 F
.273(dicated in the query)72 668.4 R 4.273(.F)-.52 G .273(or those inst\
ances in the Cartesian product for which the quali\214cation is true,)
-4.393 F/F10 7/Times-Roman@0 SF(POSTGRES)2.274 E F4 .274
(computes and returns)2.274 F .98(the v)72 678 R .98
(alues speci\214ed in the tar)-.2 F .979(get list.)-.144 F F10(POSTGRES)
4.979 E F4 .979(SQL does not assign an)2.979 F 2.979(ym)-.12 G .979
(eaning to duplicate v)-2.979 F .979(alues in such e)-.2 F 2.979
(xpressions. This)-.12 F .344(means that)72 687.6 R F10(POSTGRES)2.344 E
F4 .344(sometimes recomputes the same tar)2.344 F .344(get list se)-.144
F -.12(ve)-.2 G .344
(ral times \212 this frequently happens when Boolean e).12 F(xpressions)
-.12 E(are connected with an)72 697.2 Q/F11 8/Times-Bold@0 SF(or)2 E F4
4(.T)C 2(or)-4.64 G(emo)-2 E .24 -.12(ve s)-.12 H
(uch duplicates, you must use the).12 E F11(select distinct)2 E F4
(statement.)2 E F6(15)282.5 756 Q EP
%%Page: 16 16
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF .561(maximum and minimum o)108 97.2 R -.165(ve)
-.165 G 3.31(ras).165 G .56(et of instances, aggre)-3.31 F -.055(ga)
-.165 G .56(tes can only appear in the tar).055 F(get)-.198 E
(list of a query and not in the quali\214cation \()108 110.4 Q/F1 11
/Courier@0 SF(where)2.75 E F0(clause\) As an e)2.75 E(xample,)-.165 E/F2
10/Courier@0 SF(SELECT max\(temp_lo\))148 135.6 Q(FROM weather;)148
147.8 Q F0(Aggre)108 174 Q -.055(ga)-.165 G(tes may also ha).055 E .33
-.165(ve G)-.22 H -.44(RO).165 G(UP BY clauses:).44 E F2
(SELECT city, max\(temp_lo\))148 199.2 Q(FROM weather)148 211.4 Q
(GROUP BY city;)148 223.6 Q/F3 11/Times-Bold@0 SF(16)282.5 756 Q EP
%%Page: 17 17
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(5. AD)72 165.4 R -2.565(VA)-.76 G
(NCED POSTGRES SQL FEA)2.565 E(TURES)-1.805 E 77.5 178.6 72 178.6 DL
80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97
178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL
113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6
DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5
178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6
152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6
168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5
178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207
178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL
223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6
DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5
178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6
262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6
278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5
178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317
178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL
333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6
DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5
178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6
372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6
388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5
178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427
178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL
443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6
DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5
178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6
482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6
498.5 178.6 DL/F1 11/Times-Roman@0 SF(Ha)108 208.9 Q .065(ving co)-.22 F
-.165(ve)-.165 G .065(red the basics of using).165 F/F2 10/Times-Roman@0
SF(POSTGRES)2.816 E F1 .066(SQL to access your data, we will no)2.816 F
2.816(wd)-.275 G(is-)-2.816 E 1.624(cuss those features of)108 222.1 R
F2(POSTGRES)4.374 E F1 1.624(that distinguish it from con)4.374 F -.165
(ve)-.44 G 1.623(ntional data managers.).165 F 1.681
(These features include inheritance, time tra)108 235.3 R -.165(ve)-.22
G 4.431(la).165 G 1.681(nd non-atomic data v)-4.431 F 1.681
(alues \(array- and)-.275 F(set-v)108 248.5 Q(alued attrib)-.275 E
(utes\).)-.22 E 1.195(Examples in this section can also be found in)108
265.6 R/F3 11/Courier@0 SF(advance.sql)3.945 E F1 1.194
(in the tutorial directory)3.945 F(.)-.715 E
(\(Refer to the introduction of the pre)108 278.8 Q
(vious chapter for ho)-.275 E 2.75(wt)-.275 G 2.75(ou)-2.75 G(se it.\))
-2.75 E/F4 12/Times-Bold@0 SF 3(5.1. Inheritance)72 305 R F1(Let')108
322.1 Q 4.858(sc)-.605 G 2.108(reate tw)-4.858 F 4.858(oc)-.11 G 2.108
(lasses. The)-4.858 F F3(capitals)4.858 E F1 2.109
(class contains state capitals which are also)4.858 F(cities. Naturally)
108 335.3 Q 2.75(,t)-.715 G(he)-2.75 E F3(capitals)2.75 E F1
(class should)2.75 E/F5 11/Times-Italic@0 SF(inherit)2.75 E F1(from)2.75
E F3(cities)2.75 E F1(.)A/F6 10/Courier@0 SF(CREATE TABLE cities \()148
360.5 Q 66(name text,)196 372.7 R 30(population float,)196 384.9 R 42
(altitude int)196 397.1 R(-- \(in ft\))72 E(\);)148 409.3 Q
(CREATE TABLE capitals \()148 433.7 Q 60(state char2)196 445.9 R 6(\)I)
148 458.1 S(NHERITS \(cities\);)-6 E F1 .424
(In this case, an instance of)108 488.2 R F3(capitals)3.174 E F5
(inherits)3.173 E F1 .423(all attrib)3.173 F .423(utes \()-.22 F F3
(name)A F1(,)A F3(population)3.173 E F1 3.173(,a)C(nd)-3.173 E F3
(altitude)108 501.4 Q F1 3.006(\)f)C .256(rom its parent,)-3.006 F F3
(cities)3.006 E F1 5.756(.T)C .256(he type of the attrib)-5.756 F(ute)
-.22 E F3(name)3.006 E F1(is)3.006 E F3(text,)3.006 E F1 3.007(ab)3.007
G(uilt-)-3.227 E(in)108 514.6 Q F2(POSTGRES)2.935 E F1 .185(type for v)
2.935 F .185(ariable length ASCII strings.)-.275 F .185
(The type of the attrib)5.685 F(ute)-.22 E F3(popula-)2.935 E(tion)108
527.8 Q F1(is)3.958 E F3(float4,)3.958 E F1 3.959(ab)3.958 G(uilt-in)
-4.179 E F2(POSTGRES)3.959 E F1 1.209
(type for double precision \215oating point num-)3.959 F 2.89
(bres. State)108 541 R .14(capitals ha)2.89 F .47 -.165(ve a)-.22 H
2.889(ne).165 G .139(xtra attrib)-3.054 F(ute,)-.22 E F3(state)2.889 E
F1 2.889(,t)C .139(hat sho)-2.889 F .139(ws their state.)-.275 F(In)
5.639 E F2(POSTGRES)2.889 E F1(,)A 3.482(ac)108 556.4 S .732
(lass can inherit from zero or more other classes,)-3.482 F/F7 8
/Times-Roman@0 SF(4)-4.4 I F1 .733(and a query can reference either all)
3.483 4.4 N .095(instances of a class or all instances of a class plus \
all of its descendants.)108 569.6 R -.165(Fo)5.595 G 2.845(re).165 G
.095(xample, the)-3.01 F(follo)108 582.8 Q(wing query \214nds all the c\
ities that are situated at an attitude of 500 'ft or higher:)-.275 E F6
(SELECT name, altitude)148 608 Q(FROM cities)148 620.2 Q
(WHERE altitude > 500;)148 632.4 Q .32 LW 76 668.001 72 668.001 DL 80
668.001 76 668.001 DL 84 668.001 80 668.001 DL 88 668.001 84 668.001 DL
92 668.001 88 668.001 DL 96 668.001 92 668.001 DL 100 668.001 96 668.001
DL 104 668.001 100 668.001 DL 108 668.001 104 668.001 DL 112 668.001 108
668.001 DL 116 668.001 112 668.001 DL 120 668.001 116 668.001 DL 124
668.001 120 668.001 DL 128 668.001 124 668.001 DL 132 668.001 128
668.001 DL 136 668.001 132 668.001 DL 140 668.001 136 668.001 DL 144
668.001 140 668.001 DL 148 668.001 144 668.001 DL 152 668.001 148
668.001 DL 156 668.001 152 668.001 DL 160 668.001 156 668.001 DL 164
668.001 160 668.001 DL 168 668.001 164 668.001 DL 172 668.001 168
668.001 DL 176 668.001 172 668.001 DL 180 668.001 176 668.001 DL 184
668.001 180 668.001 DL 188 668.001 184 668.001 DL 192 668.001 188
668.001 DL 196 668.001 192 668.001 DL 200 668.001 196 668.001 DL 204
668.001 200 668.001 DL 208 668.001 204 668.001 DL 212 668.001 208
668.001 DL 216 668.001 212 668.001 DL/F8 5/Times-Roman@0 SF(4)93.6
678.401 Q F7(I.e., the inheritance hierarch)2 3.2 M 2(yi)-.04 G 2(sad)-2
G(irected ac)-2 E(yclic graph.)-.12 E/F9 11/Times-Bold@0 SF(17)282.5 756
Q EP
%%Page: 18 18
%%BeginPageSetup
BP
%%EndPageSetup
.4 LW 275 88.5 148 88.5 DL/F0 10/Courier@0 SF 39(name altitude)153 98.2
R 275 102.7 148 102.7 DL(Las Vegas)153 112.4 Q(2174)15 E 275 116.9 148
116.9 DL 15(Mariposa 1953)153 126.6 R 275 131.1 148 131.1 DL 275 88.5
275 131.1 DL 148 88.5 148 131.1 DL 214.5 88.5 214.5 131.1 DL/F1 11
/Times-Roman@0 SF .328(On the other hand, to \214nd the names of all ci\
ties, including state capitals, that are located)108 152.8 R
(at an altitude o)108 166 Q -.165(ve)-.165 G 2.75(r5).165 G
(00 'ft, the query is:)-2.75 E F0(SELECT c.name, c.altitude)148 191.2 Q
(FROM cities* c)148 203.4 Q(WHERE c.altitude > 500;)148 215.6 Q F1
(which returns:)108 240.8 Q 275 258.3 148 258.3 DL F0 39(name altitude)
153 268 R 275 272.5 148 272.5 DL(Las Vegas)153 282.2 Q(2174)15 E 275
286.7 148 286.7 DL 15(Mariposa 1953)153 296.4 R 275 300.9 148 300.9 DL
21(Madison 845)153 310.6 R 275 315.1 148 315.1 DL 275 258.3 275 315.1 DL
148 258.3 148 315.1 DL 214.5 258.3 214.5 315.1 DL F1 1.294(Here the)108
336.8 R/F2 11/Courier@0 SF(*)4.044 E F1(after)4.044 E F2(cities)4.044 E
F1 1.294(indicates that the query should be run o)4.044 F -.165(ve)-.165
G(r).165 E F2(cities)4.043 E F1 1.293(and all)4.043 F .067(classes belo)
108 350 R(w)-.275 E F2(cities)2.817 E F1 .068
(in the inheritance hierarch)2.817 F 4.248 -.715(y. M)-.055 H(an).715 E
2.818(yo)-.165 G 2.818(ft)-2.818 G .068(he commands that we ha)-2.818 F
-.165(ve)-.22 G .907(already discussed \212)108 363.2 R/F3 11
/Times-Bold@0 SF(select)3.657 E F1(,)A F3(update)3.657 E F1(and)3.657 E
F3(delete)3.657 E F1 3.657<8a73>3.657 G .907(upport this)-3.657 F F2(*)
3.657 E F1 .906(notation, as do others,)3.656 F(lik)108 376.4 Q(e)-.11 E
F3(alter)2.75 E F1(command.)2.75 E/F4 12/Times-Bold@0 SF 3(5.2. T)72
402.6 R(ime T)-.216 E(ra)-.888 E -.12(ve)-.3 G(l).12 E/F5 10
/Times-Roman@0 SF(POSTGRES)108 419.7 Q F1 .259(supports the notion of)
3.009 F/F6 11/Times-Italic@0 SF .26(time tr)3.01 F(avel)-.165 E F1 5.76
(.T)C .26(his feature allo)-5.76 F .26(ws a user to run historical)-.275
F 2.75(queries. F)108 432.9 R(or e)-.165 E
(xample, to \214nd the current population of Mariposa city)-.165 E 2.75
(,o)-.715 G(ne w)-2.75 E(ould query:)-.11 E F0
(SELECT * FROM cities WHERE name = 'Mariposa';)148 458.1 Q 344 488.6 148
488.6 DL 33(name population)153 498.3 R(altitude)15 E 344 502.8 148
502.8 DL 9(Mariposa 1320)153 512.5 R(1953)51 E 344 517 148 517 DL 344
488.6 344 517 DL 148 488.6 148 517 DL 283.5 488.6 283.5 517 DL 208.5
488.6 208.5 517 DL F5(POSTGRES)108 538.7 Q F1 1.068
(will automatically \214nd the v)3.818 F 1.068(ersion of Mariposa')-.165
F 3.817(sr)-.605 G 1.067(ecord v)-3.817 F 1.067(alid at the current)
-.275 F(time.)108 551.9 Q .794(One can also gi)108 569 R 1.124 -.165
(ve a t)-.275 H(ime).165 E F6 -.165(ra)3.545 G(ng).165 E(e)-.11 E F1
6.295(.F)C .795(or e)-6.46 F .795
(xample to see the past and present populations of)-.165 F
(Mariposa, one w)108 582.2 Q(ould query:)-.11 E F0
(SELECT name, population)148 607.4 Q(FROM cities['epoch', 'now'])148
619.6 Q(WHERE name = 'Mariposa';)148 631.8 Q F1 .81
(where \231epoch\232 indicates the be)108 660.2 R .81
(ginning of the system clock.)-.165 F/F7 8/Times-Roman@0 SF(5)-4.4 I F1
.809(If you ha)3.559 4.4 N 1.139 -.165(ve exe)-.22 H .809(cuted all of)
.165 F(the e)108 672.4 Q(xamples so f)-.165 E(ar)-.11 E 2.75(,t)-.44 G
(hen the abo)-2.75 E .33 -.165(ve q)-.165 H(uery returns:).165 E .32 LW
76 682 72 682 DL 80 682 76 682 DL 84 682 80 682 DL 88 682 84 682 DL 92
682 88 682 DL 96 682 92 682 DL 100 682 96 682 DL 104 682 100 682 DL 108
682 104 682 DL 112 682 108 682 DL 116 682 112 682 DL 120 682 116 682 DL
124 682 120 682 DL 128 682 124 682 DL 132 682 128 682 DL 136 682 132 682
DL 140 682 136 682 DL 144 682 140 682 DL 148 682 144 682 DL 152 682 148
682 DL 156 682 152 682 DL 160 682 156 682 DL 164 682 160 682 DL 168 682
164 682 DL 172 682 168 682 DL 176 682 172 682 DL 180 682 176 682 DL 184
682 180 682 DL 188 682 184 682 DL 192 682 188 682 DL 196 682 192 682 DL
200 682 196 682 DL 204 682 200 682 DL 208 682 204 682 DL 212 682 208 682
DL 216 682 212 682 DL/F8 5/Times-Roman@0 SF(5)93.6 692.4 Q F7(On)2 3.2 M
/F9 7/Times-Roman@0 SF(UNIX)2 E F7(systems, this is al)2 E -.08(wa)-.08
G(ys midnight, January 1, 1970 GMT).08 E(.)-.592 E F3(18)282.5 756 Q EP
%%Page: 19 19
%%BeginPageSetup
BP
%%EndPageSetup
.4 LW 281 88.5 148 88.5 DL/F0 10/Courier@0 SF 33(name population)153
98.2 R 281 102.7 148 102.7 DL 9(Mariposa 1200)153 112.4 R 281 116.9 148
116.9 DL 9(Mariposa 1320)153 126.6 R 281 131.1 148 131.1 DL 281 88.5 281
131.1 DL 148 88.5 148 131.1 DL 208.5 88.5 208.5 131.1 DL/F1 11
/Times-Roman@0 SF .247(The def)108 156.7 R .247(ault be)-.11 F .247(gin\
ning of a time range is the earliest time representable by the system a\
nd)-.165 F 2.009(the def)108 169.9 R 2.009
(ault end is the current time; thus, the abo)-.11 F 2.338 -.165(ve t)
-.165 H 2.008(ime range can be abbre).165 F 2.008(viated as)-.275 F
-.814(``)108 183.1 S/F2 11/Courier@0 SF([,]).814 E F1 -.77(.')C(')-.044
E/F3 12/Times-Bold@0 SF 3(5.3. Non-Atomic)72 209.3 R -1.104(Va)3 G(lues)
1.104 E F1 1.373
(One of the tenets of the relational model is that the attrib)108 226.4
R 1.374(utes of a relation are)-.22 F/F4 11/Times-Italic@0 SF(atomic)
4.124 E F1(.)A/F5 10/Times-Roman@0 SF(POSTGRES)108 239.6 Q F1 1.647
(does not ha)4.397 F 1.976 -.165(ve t)-.22 H 1.646
(his restriction; attrib).165 F 1.646(utes can themselv)-.22 F 1.646
(es contain sub-v)-.165 F(alues)-.275 E .112
(that can be accessed from the query language.)108 252.8 R -.165(Fo)
5.612 G 2.862(re).165 G .113(xample, you can create attrib)-3.027 F .113
(utes that)-.22 F(are)108 266 Q F4(arr)2.75 E(ays)-.165 E F1
(of base types.)2.75 E F3 3(5.3.1. Arrays)72 292.2 R F5(POSTGRES)108
309.3 Q F1(allo)4.98 E 2.23(ws attrib)-.275 F 2.23
(utes of an instance to be de\214ned as \214x)-.22 F 2.23
(ed-length or v)-.165 F(ariable-)-.275 E .319
(length multi-dimensional arrays. Arrays of an)108 322.5 R 3.069(yb)
-.165 G .319(ase type or user)-3.069 F .319(-de\214ned type can be cre-)
-.22 F(ated. T)108 335.7 Q 2.75(oi)-.88 G(llustrate their use, we \214r\
st create a class with arrays of base types.)-2.75 E F0 6(*C)148 360.9 S
(REATE TABLE SAL_EMP \()-6 E 66(name text,)196 373.1 R 6
(pay_by_quarter int4[],)196 385.3 R 42(schedule char16[][])196 397.5 R
(\);)148 409.7 Q F1 .313(The abo)108 435.9 R .643 -.165(ve q)-.165 H
.313(uery will create a class named).165 F F2(SAL_EMP)3.062 E F1 .312
(with a)3.062 F F2(text)3.062 E F1 .312(string \()3.062 F F2(name)A F1
.312(\), a one-)B 3.084(dimensional array of)108 449.1 R F2(int4)5.834 E
F1(\()5.834 E F2(pay_by_quarter)A F1 3.084
(\), which represents the emplo)B(yee')-.11 E(s)-.605 E 1.396
(salary by quarter and a tw)108 462.3 R 1.396(o-dimensional array of)
-.11 F F2(char16)4.146 E F1(\()4.146 E F2(schedule)A F1 1.396
(\), which repre-)B 1.737(sents the emplo)108 475.5 R(yee')-.11 E 4.487
(sw)-.605 G 1.737(eekly schedule.)-4.487 F(No)7.237 E 4.487(ww)-.275 G
4.487(ed)-4.487 G 4.487(os)-4.487 G(ome)-4.487 E F2(INSERTS)4.487 E F1
1.737(s; note that when)B .034(appending to an array)108 488.7 R 2.784
(,w)-.715 G 2.784(ee)-2.784 G .034(nclose the v)-2.784 F .034
(alues within braces and separate them by commas.)-.275 F(If you kno)108
501.9 Q 2.75(wC)-.275 G 2.75(,t)-2.75 G(his is not unlik)-2.75 E 2.75
(et)-.11 G(he syntax for initializing structures.)-2.75 E F0
(INSERT INTO SAL_EMP)148 527.1 Q(VALUES \('Bill',)178 539.3 Q
('{10000, 10000, 10000, 10000}',)226 551.5 Q
('{{"meeting", "lunch"}, {}}'\);)226 563.7 Q(INSERT INTO SAL_EMP)148
588.1 Q(VALUES \('Carol',)178 600.3 Q('{20000, 25000, 25000, 25000}',)
226 612.5 Q('{{"talk", "consult"}, {"meeting"}}'\);)226 624.7 Q F1 .582
(By def)108 650.9 R(ault,)-.11 E F5(POSTGRES)3.332 E F1 .583
(uses the \231one-based\232 numbering con)3.332 F -.165(ve)-.44 G .583
(ntion for arrays \212 that is,).165 F(an array of)108 664.1 Q F4(n)
3.146 E F1(elements starts with array[1] and ends with array[)3.014 E F4
(n).396 E F1(].).264 E(No)108 681.2 Q 1.852 -.715(w, w)-.275 H 3.172(ec)
.715 G .422(an run some queries on)-3.172 F F2(SAL_EMP)3.172 E F1 5.921
(.F)C .421(irst, we sho)-5.921 F 3.171(wh)-.275 G .971 -.275(ow t)-3.171
H 3.171(oa).275 G .421(ccess a single ele-)-3.171 F .803
(ment of an array at a time.)108 694.4 R .804(This query retrie)6.304 F
-.165(ve)-.275 G 3.554(st).165 G .804(he names of the emplo)-3.554 F
.804(yees whose pay)-.11 F(changed in the second quarter:)108 707.6 Q/F6
11/Times-Bold@0 SF(19)282.5 756 Q EP
%%Page: 20 20
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF 6(*S)148 96.2 S(ELECT name)-6 E(FROM SAL_EMP)160
108.4 Q(WHERE SAL_EMP.pay_by_quarter[1] <>)160 120.6 Q
(SAL_EMP.pay_by_quarter[2];)208 132.8 Q .4 LW 188 163.3 148 163.3 DL
(name)153 173 Q 188 177.5 148 177.5 DL(Carol)153 187.2 Q 188 191.7 148
191.7 DL 188 163.3 188 191.7 DL 148 163.3 148 191.7 DL/F1 11
/Times-Roman@0 SF(This query retrie)108 213.4 Q -.165(ve)-.275 G 2.75
(st).165 G(he third quarter pay of all emplo)-2.75 E(yees:)-.11 E F0 6
(*S)148 238.6 S(ELECT SAL_EMP.pay_by_quarter[3] FROM SAL_EMP;)-6 E 242
269.1 148 269.1 DL(pay_by_quarter)153 278.8 Q 242 283.3 148 283.3 DL
(10000)153 293 Q 242 297.5 148 297.5 DL(25000)153 307.2 Q 242 311.7 148
311.7 DL 242 269.1 242 311.7 DL 148 269.1 148 311.7 DL F1 1.873 -.88
(We c)108 333.4 T .113(an also access arbitrary).88 F/F2 11
/Times-Italic@0 SF(slices)2.863 E F1 .113(of an array)2.863 F 2.863(,o)
-.715 G(r)-2.863 E F2(subarr)2.863 E(ays)-.165 E F1 5.613(.T)C .113
(his query retrie)-5.613 F -.165(ve)-.275 G 2.863(st).165 G .112
(he \214rst)-2.863 F(item on Bill')108 346.6 Q 2.75(ss)-.605 G
(chedule for the \214rst tw)-2.75 E 2.75(od)-.11 G(ays of the week.)
-2.75 E F0 6(*S)148 371.8 S(ELECT SAL_EMP.schedule[1:2][1:1])-6 E
(FROM SAL_EMP)160 384 Q(WHERE SAL_EMP.name = 'Bill';)160 396.2 Q 266
426.7 148 426.7 DL(schedule)153 436.4 Q 266 440.9 148 440.9 DL
({{"meeting"},{""}})153 450.6 Q 266 455.1 148 455.1 DL 266 426.7 266
455.1 DL 148 426.7 148 455.1 DL/F3 11/Times-Bold@0 SF(20)282.5 756 Q EP
%%Page: 21 21
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(6. EXTENDING)72 165.4 R(SQL: AN O)
4.75 E(VER)-.95 E(VIEW)-1.045 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
/F1 11/Times-Roman@0 SF 1.923(In the sections that follo)108 208.9 R
3.353 -.715(w, w)-.275 H 4.673(ew).715 G 1.923(ill discuss ho)-4.673 F
4.673(wy)-.275 G 1.923(ou can e)-4.673 F 1.923(xtend the)-.165 F/F2 10
/Times-Roman@0 SF(POSTGRES)4.674 E F1(SQL)4.674 E
(query language by adding:)108 222.1 Q 5.5<8366>113.5 239.2 S(unctions)
-5.5 E 5.5<8374>113.5 252.4 S(ypes)-5.5 E 5.5<836f>113.5 265.6 S
(perators)-5.5 E 5.5<8361>113.5 278.8 S(ggre)-5.5 E -.055(ga)-.165 G
(tes).055 E/F3 12/Times-Bold@0 SF 3(6.1. Ho)72 305 R 3(wE)-.12 G
(xtensibility W)-3 E(orks)-.9 E F2(POSTGRES)108 322.1 Q F1 .453(is e)
3.203 F .453(xtensible because its operation is)-.165 F/F4 11
/Times-Italic@0 SF(catalo)3.202 E(g-driven)-.11 E F1 5.952(.I)C 3.202
(fy)-5.952 G .452(ou are f)-3.202 F .452(amiliar with)-.11 F .211
(standard relational systems, you kno)108 335.3 R 2.961(wt)-.275 G .211
(hat the)-2.961 F 2.961(ys)-.165 G .211
(tore information about databases, tables,)-2.961 F .408
(columns, etc., in what are commonly kno)108 348.5 R .408(wn as)-.275 F
F4 .408(system catalo)3.158 F(gs)-.11 E F1 5.908(.\()C .407
(Some systems call this)-5.908 F(the)108 361.7 Q F4 1.187
(data dictionary)3.937 F F1 3.937(\). The)B 1.187
(catalogs appear to the user as classes, lik)3.937 F 3.938(ea)-.11 G
1.518 -.165(ny o)-3.938 H(ther).165 E 3.938(,b)-.44 G 1.188(ut the)
-4.158 F .658(DBMS stores its internal bookk)108 374.9 R .658
(eeping in them.)-.11 F .657(One k)6.158 F .987 -.165(ey d)-.11 H(if)
.165 E .657(ference between)-.275 F F2(POSTGRES)3.407 E F1 1.334
(and standard relational systems is that)108 388.1 R F2(POSTGRES)4.084 E
F1 1.335(stores much more information in its)4.084 F .253
(catalogs \212 not only information about tables and columns, b)108
401.3 R .253(ut also information about its)-.22 F .778
(types, functions, access methods, and so on.)108 414.5 R .778
(These classes can be modi\214ed by the user)6.278 F(,)-.44 E .625
(and since)108 427.7 R F2(POSTGRES)3.375 E F1 .624
(bases its internal operation on these classes, this means that)3.375 F
F2(POST)3.374 E(-)-.92 E(GRES)108 440.9 Q F1 .205(can be e)2.955 F .205
(xtended by users.)-.165 F .206(By comparison, con)5.706 F -.165(ve)-.44
G .206(ntional database systems can only).165 F .07(be e)108 454.1 R .07
(xtended by changing hard-coded procedures within the DBMS or by loadin\
g modules)-.165 F(specially-written by the DBMS v)108 467.3 Q(endor)
-.165 E(.)-.605 E F2(POSTGRES)108 484.4 Q F1 1.749(is also unlik)4.499 F
4.499(em)-.11 G 1.75(ost other data managers in that the serv)-4.499 F
1.75(er can incorporate)-.165 F(user)108 497.6 Q 1.338
(-written code into itself through)-.22 F F4 1.338(dynamic loading)4.088
F F1 6.838(.T)C 1.338(hat is, the user can specify an)-6.838 F .323
(object code \214le \(e.g., a compiled)108 510.8 R/F5 11/Courier@0 SF
(.o)3.073 E F1 .323(\214le or shared library\) that implements a ne)
3.073 F 3.074(wt)-.275 G .324(ype or)-3.074 F 1.527(function and)108 524
R F2(POSTGRES)4.277 E F1 1.527(will load it as required.)4.277 F 1.526
(Code written in SQL are e)7.026 F -.165(ve)-.275 G 4.276(nm).165 G(ore)
-4.276 E(tri)108 537.2 Q(vial to add to the serv)-.275 E(er)-.165 E(.)
-.605 E 1.451
(This ability to modify its operation \231on the \215y\232 mak)108 554.3
R(es)-.11 E F2(POSTGRES)4.201 E F1 1.451(uniquely suited for)4.201 F
(rapid prototyping of ne)108 567.5 Q 2.75(wa)-.275 G
(pplications and storage structures.)-2.75 E F3 3(6.2. The)72 593.7 R/F6
11/Times-Bold@0 SF(POSTGRES)3 E F3 -.888(Ty)3 G(pe System).888 E F1(The)
108 610.8 Q F2(POSTGRES)2.75 E F1(type system can be brok)2.75 E(en do)
-.11 E(wn in se)-.275 E -.165(ve)-.275 G(ral w).165 E(ays.)-.11 E -.88
(Ty)108 627.9 S .435(pes are di).88 F .435(vided into)-.275 F F4(base)
3.185 E F1 .435(types and)3.185 F F4(composite)3.185 E F1 3.184
(types. Base)3.184 F .434(types are those, lik)3.184 F(e)-.11 E F5(int4)
3.184 E F1(,)A 1.371(that are implemented in a language such as C.)108
641.1 R(The)6.871 E 4.121(yg)-.165 G 1.371
(enerally correspond to what are)-4.121 F .34(often kno)108 654.3 R .34
(wn as \231abstract data types\232;)-.275 F F2(POSTGRES)3.09 E F1 .34
(can only operate on such types through)3.09 F 1.733(methods pro)108
667.5 R 1.733(vided by the user and only understands the beha)-.165 F
1.734(vior of such types to the)-.22 F -.165(ex)108 680.7 S .736
(tent that the user describes them.).165 F .736
(Composite types are created whene)6.236 F -.165(ve)-.275 G 3.486(rt)
.165 G .736(he user cre-)-3.486 F 1.165(ates a class.)108 693.9 R F5
(EMP)6.665 E F1 1.166(is an e)3.915 F 1.166(xample of a composite type.)
-.165 F F2(POSTGRES)6.666 E F1 1.166(stores these types in)3.916 F .58
(only one w)108 707.1 R .58
(ay \(within the \214le that stores all instances of the class\) b)-.11
F .579(ut the user can \231look)-.22 F 2.912(inside\232 at the attrib)
108 720.3 R 2.913
(utes of these types from the query language and optimize their)-.22 F
F6(21)282.5 756 Q EP
%%Page: 22 22
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF(retrie)108 97.2 Q -.275(va)-.275 G 2.75(lb).275
G 2.75(y\()-2.75 G(for e)-2.75 E
(xample\) de\214ning indices on the attrib)-.165 E(utes.)-.22 E/F1 10
/Times-Roman@0 SF(POSTGRES)108 114.3 Q F0 2.579
(base types are further di)5.329 F 2.579(vided into)-.275 F/F2 11
/Times-Italic@0 SF -.22(bu)5.329 G(ilt-in).22 E F0 2.578(types and)5.328
F F2(user)5.328 E(-de\214ned)-.22 E F0(types.)5.328 E 2.057
(Built-in types \(lik)108 127.5 R(e)-.11 E/F3 11/Courier@0 SF(int4)4.808
E F0 4.808(\)a)C 2.058(re those that are compiled into the system.)
-4.808 F(User)7.558 E(-de\214ned)-.22 E
(types are those created by the user in the manner to be described belo)
108 140.7 Q -.715(w.)-.275 G/F4 12/Times-Bold@0 SF 3(6.3. About)72 166.9
R(the)3 E/F5 11/Times-Bold@0 SF(POSTGRES)3 E F4(System Catalogs)3 E F0
(Ha)108 184 Q 1.236(ving introduced the basic e)-.22 F 1.236
(xtensibility concepts, we can no)-.165 F 3.986(wt)-.275 G(ak)-3.986 E
3.986(eal)-.11 G 1.236(ook at ho)-3.986 F 3.985(wt)-.275 G(he)-3.985 E
.694(catalogs are actually laid out.)108 197.2 R -1.21(Yo)6.194 G 3.444
(uc)1.21 G .695(an skip this section for no)-3.444 F 2.125 -.715(w, b)
-.275 H .695(ut some later sections).495 F .649
(will be incomprehensible without the information gi)108 210.4 R -.165
(ve)-.275 G 3.399(nh).165 G .649(ere, so mark this page for later)-3.399
F(reference.)108 223.6 Q 2.139(All system catalogs ha)108 240.7 R 2.469
-.165(ve n)-.22 H 2.139(ames that be).165 F 2.14(gin with)-.165 F F3
(pg_)4.89 E F0 7.64(.T)C 2.14(he follo)-7.64 F 2.14
(wing classes contain)-.275 F .912
(information that may be useful to the end user)108 253.9 R 6.411(.\()
-.605 G .911(There are man)-6.411 F 3.661(yo)-.165 G .911
(ther system catalogs,)-3.661 F -.22(bu)108 267.1 S 2.75(tt).22 G
(here should rarely be a reason to query them directly)-2.75 E(.\))-.715
E .44 LW 436.564 284.85 175.435 284.85 DL(catalog name)191.363 295.3 Q
(description)79.7 E 436.564 300.05 175.435 300.05 DL 436.564 302.05
175.435 302.05 DL F3(pg_database)180.935 312.5 Q F0(databases)23.1 E F3
(pg_class)180.935 325.7 Q F0(classes)42.9 E F3(pg_attribute)180.935
338.9 Q F0(class attrib)16.5 E(utes)-.22 E F3(pg_index)180.935 352.1 Q
F0(secondary indices)42.9 E F3(pg_proc)180.935 378.5 Q F0
(procedures \(both C and SQL\))49.5 E F3(pg_type)180.935 391.7 Q F0
(types \(both base and comple)49.5 E(x\))-.165 E F3(pg_operator)180.935
404.9 Q F0(operators)23.1 E F3(pg_aggregate)180.935 418.1 Q F0(aggre)
16.5 E -.055(ga)-.165 G(tes and aggre).055 E -.055(ga)-.165 G
(te functions).055 E F3(pg_am)180.935 444.5 Q F0(access methods)62.7 E
F3(pg_amop)180.935 457.7 Q F0(access method operators)49.5 E F3
(pg_amproc)180.935 470.9 Q F0(access method support functions)36.3 E F3
(pg_opclass)180.935 484.1 Q F0(access method operator classes)29.7 E
436.564 488.85 175.435 488.85 DL 268.385 284.85 268.385 488.85 DL
436.564 284.85 436.564 488.85 DL 175.435 284.85 175.435 488.85 DL 2.299
(The Reference Manual gi)108 510.3 R -.165(ve)-.275 G 5.049(sam).165 G
2.299(ore detailed e)-5.049 F 2.299
(xplanation of these catalogs and their)-.165 F(attrib)108 523.5 Q 3.35
(utes. Ho)-.22 F(we)-.275 E -.165(ve)-.275 G 1.48 -.44(r, F).165 H .6
(igure 3 sho).44 F .6
(ws the major entities and their relationships in the sys-)-.275 F .557
(tem catalogs.)108 536.7 R(\(Attrib)6.057 E .557
(utes that do not refer to other entities are not sho)-.22 F .558
(wn unless the)-.275 F 3.308(ya)-.165 G(re)-3.308 E(part of a primary k)
108 549.9 Q -.165(ey)-.11 G(.\))-.55 E .221(This diagram is more or les\
s incomprehensible until you actually start looking at the con-)108 567
R .887(tents of the catalogs and see ho)108 580.2 R 3.638(wt)-.275 G(he)
-3.638 E 3.638(yr)-.165 G .888(elate to each other)-3.638 F 6.388(.F)
-.605 G .888(or no)-6.553 F 2.318 -.715(w, t)-.275 H .888
(he main things to).715 F(tak)108 593.4 Q 2.75(ea)-.11 G -.11(wa)-2.915
G 2.75(yf).11 G(rom this diagram are as follo)-2.75 E(ws:)-.275 E 13.75
(\(1\) In)113.5 610.5 R(se)3.509 E -.165(ve)-.275 G .759
(ral of the sections that follo).165 F 2.189 -.715(w, w)-.275 H 3.509
(ew).715 G .759(ill present v)-3.509 F .759(arious join queries on the)
-.275 F .546(system catalogs that display information we need to e)
142.826 623.7 R .546(xtend the system.)-.165 F(Looking)6.046 E .319
(at this diagram should mak)142.826 636.9 R 3.069(es)-.11 G .319
(ome of these join queries \(which are often three- or)-3.069 F(four)
142.826 650.1 Q(-w)-.22 E 1.791(ay joins\) more understandable, because\
you will be able to see that the)-.11 F(attrib)142.826 663.3 Q
(utes used in the queries form foreign k)-.22 E -.165(ey)-.11 G 2.75(si)
.165 G 2.75(no)-2.75 G(ther classes.)-2.75 E 13.75(\(2\) Man)113.5 680.4
R 2.868(yd)-.165 G(if)-2.868 E .118(ferent features \(classes, attrib)
-.275 F .117(utes, functions, types, access methods, etc.\))-.22 F 2.01
(are tightly inte)142.826 693.6 R 2.01(grated in this schema.)-.165 F
4.76(As)7.51 G(imple)-4.76 E F5(cr)4.76 E(eate)-.198 E F0 2.01
(command may modify)4.76 F(man)142.826 706.8 Q 2.75(yo)-.165 G 2.75(ft)
-2.75 G(hese catalogs.)-2.75 E F5(22)282.5 756 Q EP
%%Page: 23 23
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 109.2 72 109.2 DL 80.5 109.2 75 109.2 DL 86 109.2 80.5 109.2
DL 91.5 109.2 86 109.2 DL 97 109.2 91.5 109.2 DL 102.5 109.2 97 109.2 DL
108 109.2 102.5 109.2 DL 113.5 109.2 108 109.2 DL 119 109.2 113.5 109.2
DL 124.5 109.2 119 109.2 DL 130 109.2 124.5 109.2 DL 135.5 109.2 130
109.2 DL 141 109.2 135.5 109.2 DL 146.5 109.2 141 109.2 DL 152 109.2
146.5 109.2 DL 157.5 109.2 152 109.2 DL 163 109.2 157.5 109.2 DL 168.5
109.2 163 109.2 DL 174 109.2 168.5 109.2 DL 179.5 109.2 174 109.2 DL 185
109.2 179.5 109.2 DL 190.5 109.2 185 109.2 DL 196 109.2 190.5 109.2 DL
201.5 109.2 196 109.2 DL 207 109.2 201.5 109.2 DL 212.5 109.2 207 109.2
DL 218 109.2 212.5 109.2 DL 223.5 109.2 218 109.2 DL 229 109.2 223.5
109.2 DL 234.5 109.2 229 109.2 DL 240 109.2 234.5 109.2 DL 245.5 109.2
240 109.2 DL 251 109.2 245.5 109.2 DL 256.5 109.2 251 109.2 DL 262 109.2
256.5 109.2 DL 267.5 109.2 262 109.2 DL 273 109.2 267.5 109.2 DL 278.5
109.2 273 109.2 DL 284 109.2 278.5 109.2 DL 289.5 109.2 284 109.2 DL 295
109.2 289.5 109.2 DL 300.5 109.2 295 109.2 DL 306 109.2 300.5 109.2 DL
311.5 109.2 306 109.2 DL 317 109.2 311.5 109.2 DL 322.5 109.2 317 109.2
DL 328 109.2 322.5 109.2 DL 333.5 109.2 328 109.2 DL 339 109.2 333.5
109.2 DL 344.5 109.2 339 109.2 DL 350 109.2 344.5 109.2 DL 355.5 109.2
350 109.2 DL 361 109.2 355.5 109.2 DL 366.5 109.2 361 109.2 DL 372 109.2
366.5 109.2 DL 377.5 109.2 372 109.2 DL 383 109.2 377.5 109.2 DL 388.5
109.2 383 109.2 DL 394 109.2 388.5 109.2 DL 399.5 109.2 394 109.2 DL 405
109.2 399.5 109.2 DL 410.5 109.2 405 109.2 DL 416 109.2 410.5 109.2 DL
421.5 109.2 416 109.2 DL 427 109.2 421.5 109.2 DL 432.5 109.2 427 109.2
DL 438 109.2 432.5 109.2 DL 443.5 109.2 438 109.2 DL 449 109.2 443.5
109.2 DL 454.5 109.2 449 109.2 DL 460 109.2 454.5 109.2 DL 465.5 109.2
460 109.2 DL 471 109.2 465.5 109.2 DL 476.5 109.2 471 109.2 DL 482 109.2
476.5 109.2 DL 487.5 109.2 482 109.2 DL 493 109.2 487.5 109.2 DL 498.5
109.2 493 109.2 DL 504 109.2 498.5 109.2 DL 0 0 432 754 -433.278 761 72
568.878 PBEGIN
%%BeginDocument: manual-er.eps
%%Title: stdin
%%Creator: fig2dev Version 3.1 Patchlevel 0
%%CreationDate: Sat Feb 24 21:36:26 1996
%%For: jolly@arcadia.CS.Berkeley.EDU (Jolly Chen,421 Soda,(510) 6421863,540-5955)
%%Orientation: Portrait
%%BoundingBox: 0 0 754 761
%%Pages: 0
%%BeginSetup
%%IncludeFeature: *PageSize Letter
%%EndSetup
%%EndComments
/$F2psDict 200 dict def
$F2psDict begin
$F2psDict /mtrx matrix put
/col-1 {} def
/col0 {0.000 0.000 0.000 srgb} bind def
/col1 {0.000 0.000 1.000 srgb} bind def
/col2 {0.000 1.000 0.000 srgb} bind def
/col3 {0.000 1.000 1.000 srgb} bind def
/col4 {1.000 0.000 0.000 srgb} bind def
/col5 {1.000 0.000 1.000 srgb} bind def
/col6 {1.000 1.000 0.000 srgb} bind def
/col7 {1.000 1.000 1.000 srgb} bind def
/col8 {0.000 0.000 0.560 srgb} bind def
/col9 {0.000 0.000 0.690 srgb} bind def
/col10 {0.000 0.000 0.820 srgb} bind def
/col11 {0.530 0.810 1.000 srgb} bind def
/col12 {0.000 0.560 0.000 srgb} bind def
/col13 {0.000 0.690 0.000 srgb} bind def
/col14 {0.000 0.820 0.000 srgb} bind def
/col15 {0.000 0.560 0.560 srgb} bind def
/col16 {0.000 0.690 0.690 srgb} bind def
/col17 {0.000 0.820 0.820 srgb} bind def
/col18 {0.560 0.000 0.000 srgb} bind def
/col19 {0.690 0.000 0.000 srgb} bind def
/col20 {0.820 0.000 0.000 srgb} bind def
/col21 {0.560 0.000 0.560 srgb} bind def
/col22 {0.690 0.000 0.690 srgb} bind def
/col23 {0.820 0.000 0.820 srgb} bind def
/col24 {0.500 0.190 0.000 srgb} bind def
/col25 {0.630 0.250 0.000 srgb} bind def
/col26 {0.750 0.380 0.000 srgb} bind def
/col27 {1.000 0.500 0.500 srgb} bind def
/col28 {1.000 0.630 0.630 srgb} bind def
/col29 {1.000 0.750 0.750 srgb} bind def
/col30 {1.000 0.880 0.880 srgb} bind def
/col31 {1.000 0.840 0.000 srgb} bind def
end
save
-30.0 776.0 translate
1 -1 scale
/clp {closepath} bind def
/ef {eofill} bind def
/gr {grestore} bind def
/gs {gsave} bind def
/l {lineto} bind def
/m {moveto} bind def
/n {newpath} bind def
/s {stroke} bind def
/slc {setlinecap} bind def
/slj {setlinejoin} bind def
/slw {setlinewidth} bind def
/srgb {setrgbcolor} bind def
/rot {rotate} bind def
/sc {scale} bind def
/tr {translate} bind def
/tnt {dup dup currentrgbcolor
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add
4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
bind def
/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
4 -2 roll mul srgb} bind def
/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
/$F2psEnd {$F2psEnteredState restore end} def
$F2psBegin
10 setmiterlimit
0.90000 0.90000 sc
0.500 slw
% Polyline
n 194 414 m 259 414 l 259 454 l 274 454 l gs col-1 s gr
% Polyline
n 194 234 m 274 234 l gs col-1 s gr
% Polyline
n 259 134 m 239 134 l 239 394 l 199 394 l gs col-1 s gr
% Polyline
n 259 54 m 219 54 l 219 389 l gs col-1 s gr
% Polyline
n 199 389 m 219 389 l gs col-1 s gr
% Polyline
n 279 254 m 259 254 l 259 399 l 199 399 l gs col-1 s gr
% Polyline
n 179 234 m 199 234 l gs col-1 s gr
% Polyline
n 259 74 m 199 74 l 199 214 l 179 214 l gs col-1 s gr
% Polyline
n 379 294 m 399 294 l gs col-1 s gr
% Polyline
n 384 239 m 459 239 l 459 514 l 499 514 l gs col-1 s gr
% Polyline
n 459 494 m 499 494 l gs col-1 s gr
% Polyline
n 379 274 m 514 274 l gs col-1 s gr
% Polyline
n 379 474 m 439 474 l gs col-1 s gr
% Polyline
n 379 494 m 439 494 l gs col-1 s gr
% Polyline
n 379 514 m 439 514 l gs col-1 s gr
% Polyline
n 379 534 m 439 534 l gs col-1 s gr
% Polyline
n 379 554 m 439 554 l gs col-1 s gr
% Polyline
n 379 574 m 439 574 l gs col-1 s gr
% Polyline
n 379 594 m 439 594 l gs col-1 s gr
% Polyline
n 379 614 m 439 614 l gs col-1 s gr
% Polyline
n 379 634 m 439 634 l gs col-1 s gr
% Polyline
n 379 654 m 439 654 l gs col-1 s gr
% Polyline
n 439 279 m 514 279 l gs col-1 s gr
% Polyline
n 434 439 m 444 449 l gs col-1 s gr
% Polyline
n 404 269 m 414 279 l gs col-1 s gr
% Polyline
n 454 439 m 464 449 l gs col-1 s gr
% Polyline
n 619 634 m 659 634 l gs col-1 s gr
% Polyline
n 634 519 m 644 529 l gs col-1 s gr
% Polyline
n 654 579 m 664 589 l gs col-1 s gr
% Polyline
n 499 494 m 519 494 l gs col-1 s gr
% Polyline
n 499 514 m 519 514 l gs col-1 s gr
% Polyline
n 599 104 m 599 79 l 514 79 l 514 104 l clp gs col-1 s gr
% Polyline
n 624 124 m 624 104 l 514 104 l 514 124 l clp gs col-1 s gr
% Polyline
n 459 534 m 499 534 l gs col-1 s gr
% Polyline
n 499 534 m 519 534 l gs col-1 s gr
% Polyline
n 459 534 m 459 514 l gs col-1 s gr
% Polyline
n 384 229 m 499 229 l 499 314 l 519 314 l gs col-1 s gr
% Polyline
n 624 114 m 639 114 l 639 354 l 619 354 l gs col-1 s gr
% Polyline
n 384 454 m 419 454 l 419 414 l 739 414 l gs col-1 s gr
% Polyline
n 384 449 m 399 449 l 399 399 l 699 399 l 699 54 l 739 54 l gs col-1 s gr
% Polyline
n 624 449 m 719 449 l 719 94 l 739 94 l gs col-1 s gr
% Polyline
n 679 134 m 744 134 l gs col-1 s gr
% Polyline
n 674 159 m 684 169 l gs col-1 s gr
% Polyline
n 839 74 m 859 74 l 859 249 l 844 249 l gs col-1 s gr
% Polyline
n 844 254 m 859 254 l 859 434 l 839 434 l gs col-1 s gr
% Polyline
n 624 269 m 679 269 l 679 114 l 739 114 l gs col-1 s gr
% Polyline
n 624 274 m 679 274 l 679 474 l 739 474 l gs col-1 s gr
% Polyline
n 521 284 m 514 284 514 357 7 arcto 4 {pop} repeat 514 364 617 364 7 arcto 4 {pop} repeat 624 364 624 291 7 arcto 4 {pop} repeat 624 284 521 284 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 179 604 m 179 579 l 74 579 l 74 604 l clp gs col-1 s gr
% Polyline
n 184 704 m 184 679 l 74 679 l 74 704 l clp gs col-1 s gr
% Polyline
n 81 604 m 74 604 74 617 7 arcto 4 {pop} repeat 74 624 177 624 7 arcto 4 {pop} repeat 184 624 184 611 7 arcto 4 {pop} repeat 184 604 81 604 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 184 724 m 184 704 l 74 704 l 74 724 l clp gs col-1 s gr
% Polyline
n 179 614 m 199 614 l 199 714 l 184 714 l gs col-1 s gr
% Polyline
n 184 764 m 184 724 l 74 724 l 74 764 l clp gs col-1 s gr
% Polyline
n 184 784 m 184 764 l 74 764 l 74 784 l clp gs col-1 s gr
% Polyline
n 81 724 m 74 724 74 777 7 arcto 4 {pop} repeat 74 784 177 784 7 arcto 4 {pop} repeat 184 784 184 731 7 arcto 4 {pop} repeat 184 724 81 724 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 166 804 m 159 804 159 812 7 arcto 4 {pop} repeat 159 819 172 819 7 arcto 4 {pop} repeat 179 819 179 811 7 arcto 4 {pop} repeat 179 804 166 804 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 439 654 m 439 279 l gs col-1 s gr
% Polyline
[4.4] 0 setdash
n 359 94 m 419 94 l 419 269 l 514 269 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 384 234 m 479 234 l 479 334 l 519 334 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 239 739 m 279 739 l gs col-1 s gr [] 0 setdash
% Polyline
n 239 759 m 279 759 l gs col-1 s gr
% Polyline
[4.4] 0 setdash
n 379 314 m 399 314 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 379 334 m 399 334 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 399 294 m 399 334 l gs col-1 s gr [] 0 setdash
% Polyline
n 399 274 m 399 294 l gs col-1 s gr
% Polyline
[4.4] 0 setdash
n 619 614 m 639 614 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 619 594 m 639 594 l gs col-1 s gr [] 0 setdash
% Polyline
n 521 464 m 514 464 514 677 7 arcto 4 {pop} repeat 514 684 617 684 7 arcto 4 {pop} repeat 624 684 624 471 7 arcto 4 {pop} repeat 624 464 521 464 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
[4.4] 0 setdash
n 639 594 m 639 614 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 619 574 m 639 574 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 619 554 m 639 554 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 624 454 m 639 454 l 639 594 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 619 654 m 659 654 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 619 674 m 659 674 l gs col-1 s gr [] 0 setdash
% Polyline
[4.4] 0 setdash
n 659 674 m 659 654 l gs col-1 s gr [] 0 setdash
% Polyline
n 624 279 m 659 279 l 659 634 l gs col-1 s gr
% Polyline
[4.4] 0 setdash
n 659 634 m 659 654 l gs col-1 s gr [] 0 setdash
% Polyline
n 154 184 m 154 159 l 69 159 l 69 184 l clp gs col-1 s gr
% Polyline
n 76 184 m 69 184 69 237 7 arcto 4 {pop} repeat 69 244 172 244 7 arcto 4 {pop} repeat 179 244 179 191 7 arcto 4 {pop} repeat 179 184 76 184 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 69 224 m 179 224 l gs col-1 s gr
% Polyline
n 174 414 m 194 414 l gs col-1 s gr
% Polyline
n 179 399 m 199 399 l gs col-1 s gr
% Polyline
n 179 394 m 199 394 l gs col-1 s gr
% Polyline
n 179 389 m 199 389 l gs col-1 s gr
% Polyline
n 179 404 m 179 384 l 69 384 l 69 404 l clp gs col-1 s gr
% Polyline
n 154 384 m 154 359 l 69 359 l 69 384 l clp gs col-1 s gr
% Polyline
n 179 424 m 179 404 l 69 404 l 69 424 l clp gs col-1 s gr
% Polyline
n 359 224 m 359 199 l 274 199 l 274 224 l clp gs col-1 s gr
% Polyline
n 384 244 m 384 224 l 274 224 l 274 244 l clp gs col-1 s gr
% Polyline
n 384 344 m 384 244 l 274 244 l 274 344 l clp gs col-1 s gr
% Polyline
n 339 44 m 339 19 l 254 19 l 254 44 l clp gs col-1 s gr
% Polyline
n 261 44 m 254 44 254 137 7 arcto 4 {pop} repeat 254 144 357 144 7 arcto 4 {pop} repeat 364 144 364 51 7 arcto 4 {pop} repeat 364 44 261 44 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 254 124 m 364 124 l gs col-1 s gr
% Polyline
n 819 44 m 819 19 l 734 19 l 734 44 l clp gs col-1 s gr
% Polyline
n 741 44 m 734 44 734 137 7 arcto 4 {pop} repeat 734 144 837 144 7 arcto 4 {pop} repeat 844 144 844 51 7 arcto 4 {pop} repeat 844 44 741 44 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 734 104 m 844 104 l gs col-1 s gr
% Polyline
n 819 244 m 819 219 l 734 219 l 734 244 l clp gs col-1 s gr
% Polyline
n 844 264 m 844 244 l 734 244 l 734 264 l clp gs col-1 s gr
% Polyline
n 599 264 m 599 239 l 514 239 l 514 264 l clp gs col-1 s gr
% Polyline
n 624 284 m 624 264 l 514 264 l 514 284 l clp gs col-1 s gr
% Polyline
n 624 364 m 624 284 l 514 284 l 514 364 l clp gs col-1 s gr
% Polyline
n 514 344 m 624 344 l gs col-1 s gr
% Polyline
n 819 404 m 819 379 l 734 379 l 734 404 l clp gs col-1 s gr
% Polyline
n 741 404 m 734 404 734 477 7 arcto 4 {pop} repeat 734 484 837 484 7 arcto 4 {pop} repeat 844 484 844 411 7 arcto 4 {pop} repeat 844 404 741 404 7 arcto 4 {pop} repeat clp gs col-1 s gr
% Polyline
n 734 464 m 844 464 l gs col-1 s gr
% Polyline
n 599 444 m 599 419 l 514 419 l 514 444 l clp gs col-1 s gr
% Polyline
n 624 464 m 624 444 l 514 444 l 514 464 l clp gs col-1 s gr
% Polyline
n 624 544 m 624 464 l 514 464 l 514 544 l clp gs col-1 s gr
% Polyline
n 624 684 m 624 544 l 514 544 l 514 684 l clp gs col-1 s gr
% Polyline
n 384 464 m 384 444 l 274 444 l 274 464 l clp gs col-1 s gr
% Polyline
n 359 444 m 359 419 l 274 419 l 274 444 l clp gs col-1 s gr
% Polyline
n 384 664 m 384 464 l 274 464 l 274 664 l clp gs col-1 s gr
% Interp Spline
n 219 799 m
219.84 787.54 219.84 782.54 219 779 curveto
217.75 773.72 212.79 763.10 209 759 curveto
205.29 754.99 199.04 751.24 184 744 curveto
gs col-1 s gr
n 190.34 749.27 m 184.00 744.00 l 192.08 745.67 l gs col-1 s gr
/Times-Roman findfont 14.00 scalefont setfont
589 339 m
gs 1 -1 sc ([8]) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
299 79 m
gs 1 -1 sc ([8]) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
119 659 m
gs 1 -1 sc (REFERS-TO) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
79 779 m
gs 1 -1 sc (non-key) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
249 459 m
gs 1 -1 sc (1) col-1 show gr
% Polyline
n 74 194 m 59 194 l 59 394 l 69 394 l gs col-1 s gr
/Times-Roman findfont 14.00 scalefont setfont
184 429 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
189 859 m
gs 1 -1 sc (identified by the non-oid primary key in other contexts\).) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
49 399 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
34 189 m
gs 1 -1 sc (13:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
264 229 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
184 229 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
184 209 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
229 89 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
209 379 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
229 379 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
249 379 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
229 129 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
229 49 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
389 439 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
409 439 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
389 349 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
504 264 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
489 349 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
489 329 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
389 224 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
629 369 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
629 109 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
429 669 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
504 294 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
369 89 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
469 254 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
389 254 m
gs 1 -1 sc (0:1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
284 739 m
gs 1 -1 sc (optional) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
284 759 m
gs 1 -1 sc (mandatory) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
424 194 m
gs 1 -1 sc (0:1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
709 49 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
709 89 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
629 444 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
629 469 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
629 629 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
664 639 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
649 294 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
629 264 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
669 299 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
709 489 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
689 429 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
849 449 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
849 69 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
849 244 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
849 269 m
gs 1 -1 sc (1) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
654 134 m
gs 1 -1 sc (0:N) col-1 show gr
/Times-Roman findfont 18.00 scalefont setfont
39 569 m
gs 1 -1 sc (KEY:) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
74 239 m
gs 1 -1 sc (atttypid) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 259 m
gs 1 -1 sc (typrelid) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 279 m
gs 1 -1 sc (typinput) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 299 m
gs 1 -1 sc (typoutput) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 319 m
gs 1 -1 sc (typreceive) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 339 m
gs 1 -1 sc (typsend) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
259 139 m
gs 1 -1 sc (indexrelid) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
739 119 m
gs 1 -1 sc (amopselect) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
739 139 m
gs 1 -1 sc (amopnpages) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 359 m
gs 1 -1 sc (prolang) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
739 479 m
gs 1 -1 sc (amproc) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 559 m
gs 1 -1 sc (oprcom) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 579 m
gs 1 -1 sc (oprnegate) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 599 m
gs 1 -1 sc (oprlsortop) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 619 m
gs 1 -1 sc (oprrsortop) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 639 m
gs 1 -1 sc (oprcode) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 659 m
gs 1 -1 sc (oprrest) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
519 679 m
gs 1 -1 sc (oprjoin) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 479 m
gs 1 -1 sc (amgettuple) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 499 m
gs 1 -1 sc (aminsert) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 519 m
gs 1 -1 sc (amdelete) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 539 m
gs 1 -1 sc (amgetattr) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 559 m
gs 1 -1 sc (ambeginscan) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 579 m
gs 1 -1 sc (amrescan) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 599 m
gs 1 -1 sc (amendscan) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 619 m
gs 1 -1 sc (ammarkpos) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 639 m
gs 1 -1 sc (amrestrpos) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
279 659 m
gs 1 -1 sc (ambuild) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
79 599 m
gs 1 -1 sc (DEPENDENT) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
79 699 m
gs 1 -1 sc (INDEPENDENT) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
74 179 m
gs 1 -1 sc (pg_attribute) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
74 379 m
gs 1 -1 sc (pg_class) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
259 39 m
gs 1 -1 sc (pg_index) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
279 219 m
gs 1 -1 sc (pg_type) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
279 439 m
gs 1 -1 sc (pg_am) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
519 259 m
gs 1 -1 sc (pg_proc) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
519 99 m
gs 1 -1 sc (pg_language) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
739 39 m
gs 1 -1 sc (pg_amop) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
739 239 m
gs 1 -1 sc (pg_opclass) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
739 399 m
gs 1 -1 sc (pg_amproc) col-1 show gr
/Times-Bold findfont 14.00 scalefont setfont
519 439 m
gs 1 -1 sc (pg_operator) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
74 199 m
gs 1 -1 sc (attrelid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
74 219 m
gs 1 -1 sc (attnum) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
74 419 m
gs 1 -1 sc (relam) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
74 399 m
gs 1 -1 sc (oid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
259 59 m
gs 1 -1 sc (indrelid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
259 79 m
gs 1 -1 sc (indkey) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
259 99 m
gs 1 -1 sc (indproc) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
259 119 m
gs 1 -1 sc (indpred) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
279 239 m
gs 1 -1 sc (oid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
279 459 m
gs 1 -1 sc (oid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
519 279 m
gs 1 -1 sc (oid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
519 119 m
gs 1 -1 sc (oid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
739 59 m
gs 1 -1 sc (amopid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
739 79 m
gs 1 -1 sc (amopclaid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
739 99 m
gs 1 -1 sc (amopopr) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
739 259 m
gs 1 -1 sc (oid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
739 419 m
gs 1 -1 sc (amid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
739 439 m
gs 1 -1 sc (amopclaid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
739 459 m
gs 1 -1 sc (amprocnum) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
519 459 m
gs 1 -1 sc (oid) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
79 719 m
gs 1 -1 sc (primary key) col-1 show gr
/Times-BoldItalic findfont 14.00 scalefont setfont
79 619 m
gs 1 -1 sc (foreign key) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
79 739 m
gs 1 -1 sc (non-oid primary) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
84 759 m
gs 1 -1 sc (key \(if any\)) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
519 479 m
gs 1 -1 sc (oprname) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
519 499 m
gs 1 -1 sc (oprleft) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
519 519 m
gs 1 -1 sc (oprright) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
519 539 m
gs 1 -1 sc (oprresult) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
519 299 m
gs 1 -1 sc (proname) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
519 319 m
gs 1 -1 sc (prorettype) col-1 show gr
/Times-Italic findfont 14.00 scalefont setfont
519 339 m
gs 1 -1 sc (proargtypes) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
189 819 m
gs 1 -1 sc (indicates these key values are alternate primary keys) col-1 show gr
/Times-Roman findfont 14.00 scalefont setfont
189 839 m
gs 1 -1 sc (\(i.e., this class is generally identified by oid but may be) col-1 show gr
$F2psEnd
restore
%%EndDocument
end PEND/F0 11/Times-Bold@0 SF(Figur)177.701 595.278 Q 2.75(e3)-.198 G
/F1 11/Times-Roman@0 SF 5.5(.T)-2.75 G(he major)-5.5 E/F2 10
/Times-Roman@0 SF(POSTGRES)2.75 E F1(system catalogs.)2.75 E 77.5
608.478 72 608.478 DL 80.5 608.478 75 608.478 DL 86 608.478 80.5 608.478
DL 91.5 608.478 86 608.478 DL 97 608.478 91.5 608.478 DL 102.5 608.478
97 608.478 DL 108 608.478 102.5 608.478 DL 113.5 608.478 108 608.478 DL
119 608.478 113.5 608.478 DL 124.5 608.478 119 608.478 DL 130 608.478
124.5 608.478 DL 135.5 608.478 130 608.478 DL 141 608.478 135.5 608.478
DL 146.5 608.478 141 608.478 DL 152 608.478 146.5 608.478 DL 157.5
608.478 152 608.478 DL 163 608.478 157.5 608.478 DL 168.5 608.478 163
608.478 DL 174 608.478 168.5 608.478 DL 179.5 608.478 174 608.478 DL 185
608.478 179.5 608.478 DL 190.5 608.478 185 608.478 DL 196 608.478 190.5
608.478 DL 201.5 608.478 196 608.478 DL 207 608.478 201.5 608.478 DL
212.5 608.478 207 608.478 DL 218 608.478 212.5 608.478 DL 223.5 608.478
218 608.478 DL 229 608.478 223.5 608.478 DL 234.5 608.478 229 608.478 DL
240 608.478 234.5 608.478 DL 245.5 608.478 240 608.478 DL 251 608.478
245.5 608.478 DL 256.5 608.478 251 608.478 DL 262 608.478 256.5 608.478
DL 267.5 608.478 262 608.478 DL 273 608.478 267.5 608.478 DL 278.5
608.478 273 608.478 DL 284 608.478 278.5 608.478 DL 289.5 608.478 284
608.478 DL 295 608.478 289.5 608.478 DL 300.5 608.478 295 608.478 DL 306
608.478 300.5 608.478 DL 311.5 608.478 306 608.478 DL 317 608.478 311.5
608.478 DL 322.5 608.478 317 608.478 DL 328 608.478 322.5 608.478 DL
333.5 608.478 328 608.478 DL 339 608.478 333.5 608.478 DL 344.5 608.478
339 608.478 DL 350 608.478 344.5 608.478 DL 355.5 608.478 350 608.478 DL
361 608.478 355.5 608.478 DL 366.5 608.478 361 608.478 DL 372 608.478
366.5 608.478 DL 377.5 608.478 372 608.478 DL 383 608.478 377.5 608.478
DL 388.5 608.478 383 608.478 DL 394 608.478 388.5 608.478 DL 399.5
608.478 394 608.478 DL 405 608.478 399.5 608.478 DL 410.5 608.478 405
608.478 DL 416 608.478 410.5 608.478 DL 421.5 608.478 416 608.478 DL 427
608.478 421.5 608.478 DL 432.5 608.478 427 608.478 DL 438 608.478 432.5
608.478 DL 443.5 608.478 438 608.478 DL 449 608.478 443.5 608.478 DL
454.5 608.478 449 608.478 DL 460 608.478 454.5 608.478 DL 465.5 608.478
460 608.478 DL 471 608.478 465.5 608.478 DL 476.5 608.478 471 608.478 DL
482 608.478 476.5 608.478 DL 487.5 608.478 482 608.478 DL 493 608.478
487.5 608.478 DL 498.5 608.478 493 608.478 DL 504 608.478 498.5 608.478
DL 13.75(\(3\) T)113.5 649.078 R .962(ypes and procedures)-.88 F/F3 8
/Times-Roman@0 SF(6)-4.4 I F1 .961(are central to the schema.)3.712 4.4
N .961(Nearly e)6.461 F -.165(ve)-.275 G .961(ry catalog contains).165 F
.739(some reference to instances in one or both of these classes.)
142.826 662.278 R -.165(Fo)6.239 G 3.489(re).165 G(xample,)-3.654 E F2
(POST)3.489 E(-)-.92 E(GRES)142.826 675.478 Q F1 .182(frequently uses t\
ype signatures \(e.g., of functions and operators\) to identify)2.933 F
.32 LW 76 685.078 72 685.078 DL 80 685.078 76 685.078 DL 84 685.078 80
685.078 DL 88 685.078 84 685.078 DL 92 685.078 88 685.078 DL 96 685.078
92 685.078 DL 100 685.078 96 685.078 DL 104 685.078 100 685.078 DL 108
685.078 104 685.078 DL 112 685.078 108 685.078 DL 116 685.078 112
685.078 DL 120 685.078 116 685.078 DL 124 685.078 120 685.078 DL 128
685.078 124 685.078 DL 132 685.078 128 685.078 DL 136 685.078 132
685.078 DL 140 685.078 136 685.078 DL 144 685.078 140 685.078 DL 148
685.078 144 685.078 DL 152 685.078 148 685.078 DL 156 685.078 152
685.078 DL 160 685.078 156 685.078 DL 164 685.078 160 685.078 DL 168
685.078 164 685.078 DL 172 685.078 168 685.078 DL 176 685.078 172
685.078 DL 180 685.078 176 685.078 DL 184 685.078 180 685.078 DL 188
685.078 184 685.078 DL 192 685.078 188 685.078 DL 196 685.078 192
685.078 DL 200 685.078 196 685.078 DL 204 685.078 200 685.078 DL 208
685.078 204 685.078 DL 212 685.078 208 685.078 DL 216 685.078 212
685.078 DL/F4 5/Times-Roman@0 SF(6)93.6 695.478 Q F3 1.28 -.64(We u)2
3.2 P(se the w).64 E(ords)-.08 E/F5 8/Times-Italic@0 SF(pr)2 E(ocedur)
-.36 E(e)-.296 E F3(and)2 E F5(function)2 E F3(more or less interchang)2
E(ably)-.04 E(.)-.52 E F0(23)282.5 756 Q EP
%%Page: 24 24
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF(unique instances of other catalogs.)142.826 97.2
Q 13.75(\(4\) There)113.5 114.3 R .222(are man)2.972 F 2.972(ya)-.165 G
(ttrib)-2.972 E .222(utes and relationships that ha)-.22 F .552 -.165
(ve o)-.22 H -.165(bv).165 G .222(ious meanings, b).165 F .222(ut there)
-.22 F 1.599(are man)142.826 127.5 R 4.349(y\()-.165 G 1.599
(particularly those that ha)-4.349 F 1.928 -.165(ve t)-.22 H 4.348(od)
.165 G 4.348(ow)-4.348 G 1.598(ith access methods\) that do not.)-4.348
F 1.899(The relationships between)142.826 140.7 R/F1 11/Courier@0 SF
(pg_am)4.649 E F0(,)A F1(pg_amop)4.649 E F0(,)A F1 -1.95
(pg_amproc, pg_operator)4.65 F F0(and)142.826 153.9 Q F1(pg_opclass)
4.062 E F0 1.312
(are particularly hard to understand and will be described in)4.062 F
.679(depth \(in the section on interf)142.826 167.1 R .68
(acing types and operators to indices\) after we ha)-.11 F -.165(ve)-.22
G(discussed basic e)142.826 180.3 Q(xtensions.)-.165 E/F2 11
/Times-Bold@0 SF(24)282.5 756 Q EP
%%Page: 25 25
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(7. EXTENDING)72 165.4 R
(SQL: FUNCTIONS)4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86
178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5
178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119
178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL
135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6
DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5
178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6
174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6
190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5
178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229
178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL
245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6
DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5
178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6
284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6
300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5
178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339
178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL
355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6
DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5
178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6
394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6
410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5
178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449
178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL
465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6
DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5
178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11
/Times-Roman@0 SF .665(As it turns out, part of de\214ning a ne)108
208.9 R 3.415(wt)-.275 G .664
(ype is the de\214nition of functions that describe its)-3.415 F(beha)
108 222.1 Q(vior)-.22 E 6.346(.C)-.605 G(onsequently)-6.346 E 3.596(,w)
-.715 G .846(hile it is possible to de\214ne a ne)-3.596 F 3.596(wf)
-.275 G .847(unction without de\214ning a)-3.596 F(ne)108 235.3 Q 4.407
(wt)-.275 G 1.657(ype, the re)-4.407 F -.165(ve)-.275 G 1.657
(rse is not true.).165 F 3.417 -.88(We t)7.157 H 1.657
(herefore describe ho).88 F 4.406(wt)-.275 G 4.406(oa)-4.406 G 1.656
(dd ne)-4.406 F 4.406(wf)-.275 G 1.656(unctions to)-4.406 F/F2 10
/Times-Roman@0 SF(POSTGRES)108 248.5 Q F1(before describing ho)2.75 E
2.75(wt)-.275 G 2.75(oa)-2.75 G(dd ne)-2.75 E 2.75(wt)-.275 G(ypes.)
-2.75 E F2(POSTGRES)108 265.6 Q F1 1.65(SQL pro)4.4 F 1.65(vides tw)
-.165 F 4.401(ot)-.11 G 1.651(ypes of functions:)-4.401 F/F3 11
/Times-Italic@0 SF 1.651(query langua)4.401 F 1.871 -.11(ge f)-.11 H
(unctions).11 E F1(\(functions)4.401 E 1.675(written in SQL and)108
278.8 R F3(pr)4.425 E -.11(og)-.495 G -.165(ra).11 G 1.675(mming langua)
.165 F 1.895 -.11(ge f)-.11 H(unctions).11 E F1 1.675
(\(functions written in a compiled)4.425 F .664
(programming language such as C.\))108 292 R .664
(Either kind of function can tak)6.164 F 3.415(eab)-.11 G .665
(ase type, a com-)-3.415 F 1.166(posite type or some combination as ar)
108 305.2 R 1.166(guments \(parameters\).)-.198 F 1.166
(In addition, both kinds of)6.666 F .371
(functions can return a base type or a composite type.)108 318.4 R(It')
5.871 E 3.121(se)-.605 G .371(asier to de\214ne SQL functions,)-3.121 F
(so we')108 331.6 Q(ll start with those.)-.11 E
(Examples in this section can also be found in)108 348.7 Q/F4 11
/Courier@0 SF(funcs.sql)2.75 E F1(and)2.75 E F4(C-code/funcs.c)2.75 E F1
(.)A/F5 12/Times-Bold@0 SF 3(7.1. Query)72 374.9 R
(Language \(SQL\) Functions)3 E 77.5 388.1 72 388.1 DL 80.5 388.1 75
388.1 DL 86 388.1 80.5 388.1 DL 91.5 388.1 86 388.1 DL 97 388.1 91.5
388.1 DL 102.5 388.1 97 388.1 DL 108 388.1 102.5 388.1 DL 113.5 388.1
108 388.1 DL 119 388.1 113.5 388.1 DL 124.5 388.1 119 388.1 DL 130 388.1
124.5 388.1 DL 135.5 388.1 130 388.1 DL 141 388.1 135.5 388.1 DL 146.5
388.1 141 388.1 DL 152 388.1 146.5 388.1 DL 157.5 388.1 152 388.1 DL 163
388.1 157.5 388.1 DL 168.5 388.1 163 388.1 DL 174 388.1 168.5 388.1 DL
179.5 388.1 174 388.1 DL 185 388.1 179.5 388.1 DL 190.5 388.1 185 388.1
DL 196 388.1 190.5 388.1 DL 201.5 388.1 196 388.1 DL 207 388.1 201.5
388.1 DL 212.5 388.1 207 388.1 DL 218 388.1 212.5 388.1 DL 223.5 388.1
218 388.1 DL 229 388.1 223.5 388.1 DL 234.5 388.1 229 388.1 DL 240 388.1
234.5 388.1 DL 245.5 388.1 240 388.1 DL 251 388.1 245.5 388.1 DL 256.5
388.1 251 388.1 DL 262 388.1 256.5 388.1 DL 267.5 388.1 262 388.1 DL 273
388.1 267.5 388.1 DL 278.5 388.1 273 388.1 DL 284 388.1 278.5 388.1 DL
289.5 388.1 284 388.1 DL 295 388.1 289.5 388.1 DL 300.5 388.1 295 388.1
DL 306 388.1 300.5 388.1 DL 311.5 388.1 306 388.1 DL 317 388.1 311.5
388.1 DL 322.5 388.1 317 388.1 DL 328 388.1 322.5 388.1 DL 333.5 388.1
328 388.1 DL 339 388.1 333.5 388.1 DL 344.5 388.1 339 388.1 DL 350 388.1
344.5 388.1 DL 355.5 388.1 350 388.1 DL 361 388.1 355.5 388.1 DL 366.5
388.1 361 388.1 DL 372 388.1 366.5 388.1 DL 377.5 388.1 372 388.1 DL 383
388.1 377.5 388.1 DL 388.5 388.1 383 388.1 DL 394 388.1 388.5 388.1 DL
399.5 388.1 394 388.1 DL 405 388.1 399.5 388.1 DL 410.5 388.1 405 388.1
DL 416 388.1 410.5 388.1 DL 421.5 388.1 416 388.1 DL 427 388.1 421.5
388.1 DL 432.5 388.1 427 388.1 DL 438 388.1 432.5 388.1 DL 443.5 388.1
438 388.1 DL 449 388.1 443.5 388.1 DL 454.5 388.1 449 388.1 DL 460 388.1
454.5 388.1 DL 465.5 388.1 460 388.1 DL 471 388.1 465.5 388.1 DL 476.5
388.1 471 388.1 DL 482 388.1 476.5 388.1 DL 487.5 388.1 482 388.1 DL 493
388.1 487.5 388.1 DL 498.5 388.1 493 388.1 DL 504 388.1 498.5 388.1 DL 3
(7.1.1. SQL)72 418.4 R(Functions on Base T)3 E(ypes)-.888 E F1 1.475
(The simplest possible SQL function has no ar)108 435.5 R 1.475
(guments and simply returns a base type,)-.198 F(such as)108 448.7 Q F4
(int4)2.75 E F1(:)A/F6 10/Courier@0 SF
(CREATE FUNCTION one\(\) RETURNS int4)148 473.9 Q
(AS 'SELECT 1 as RESULT' LANGUAGE 'sql';)178 486.1 Q
(SELECT one\(\) AS answer;)148 524.3 Q .4 LW 194 554.8 148 554.8 DL
(answer)153 564.5 Q 194 569 148 569 DL(1)153 578.7 Q 194 583.2 148 583.2
DL 194 554.8 194 583.2 DL 148 554.8 148 583.2 DL F1 .376
(Notice that we de\214ned a tar)108 604.9 R .376
(get list for the function \(with the name)-.198 F F4(RESULT)3.126 E F1
.376(\), b)B .376(ut the tar)-.22 F(-)-.22 E .773
(get list of the query that in)108 618.1 R -.22(vo)-.44 G -.11(ke).22 G
3.523(dt).11 G .773(he function o)-3.523 F -.165(ve)-.165 G .773
(rrode the function').165 F 3.523(st)-.605 G(ar)-3.523 E .774(get list.)
-.198 F(Hence,)6.274 E(the result is labelled)108 631.3 Q F4(answer)2.75
E F1(instead of)2.75 E F4(one)2.75 E F1(.)A(It')108 648.4 Q 4.424(sa)
-.605 G 1.674(lmost as easy to de\214ne SQL functions that tak)-4.424 F
4.423(eb)-.11 G 1.673(ase types as ar)-4.423 F 4.423(guments. In)-.198 F
(the)4.423 E -.165(ex)108 661.6 S(ample belo).165 E 1.43 -.715(w, n)
-.275 H(otice ho).715 E 2.75(ww)-.275 G 2.75(er)-2.75 G(efer to the ar)
-2.75 E(guments within the function as)-.198 E F4($1)2.75 E F1(and)2.75
E F4($2)2.75 E F1(.)A F6
(CREATE FUNCTION add_em\(int4, int4\) RETURNS int4)148 686.8 Q
(AS 'SELECT $1 + $2;' LANGUAGE 'sql';)178 699 Q/F7 11/Times-Bold@0 SF
(25)282.5 756 Q EP
%%Page: 26 26
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(SELECT add_em\(1, 2\) AS answer;)148 96.2 Q .4 LW
194 126.7 148 126.7 DL(answer)153 136.4 Q 194 140.9 148 140.9 DL(3)153
150.6 Q 194 155.1 148 155.1 DL 194 126.7 194 155.1 DL 148 126.7 148
155.1 DL/F1 12/Times-Bold@0 SF 3(7.1.2. SQL)72 189.8 R
(Functions on Composite T)3 E(ypes)-.888 E/F2 11/Times-Roman@0 SF 1.145
(When specifying functions with ar)108 206.9 R 1.146
(guments of composite types \(such as)-.198 F/F3 11/Courier@0 SF(EMP)
3.896 E F2 1.146(\), we must)B .317(not only specify which ar)108 220.1
R .317(gument we w)-.198 F .316(ant \(as we did abo)-.11 F .646 -.165
(ve w)-.165 H(ith).165 E F3($1)3.066 E F2(and)3.066 E F3($2)3.066 E F2
3.066(\)b)C .316(ut also the)-3.286 F(attrib)108 233.3 Q .393
(utes of that ar)-.22 F 3.143(gument. F)-.198 F .393(or e)-.165 F .393
(xample, tak)-.165 F 3.143(et)-.11 G .393(he function)-3.143 F F3
(double_salary)3.143 E F2 .393(that com-)3.143 F
(putes what your salary w)108 246.5 Q(ould be if it were doubled.)-.11 E
F0(CREATE FUNCTION double_salary\(EMP\) RETURNS int4)148 271.7 Q
(AS 'SELECT $1.salary * 2 AS salary;' LANGUAGE 'sql';)178 283.9 Q
(SELECT name, double_salary\(EMP\) AS dream)148 308.3 Q(FROM EMP)160
320.5 Q(WHERE EMP.dept = 'toy';)160 332.7 Q 227 363.2 148 363.2 DL 9
(name dream)153 372.9 R 227 377.4 148 377.4 DL 15(Sam 2400)153 387.1 R
227 391.6 148 391.6 DL 227 363.2 227 391.6 DL 148 363.2 148 391.6 DL
184.5 363.2 184.5 391.6 DL F2(Notice the use of the syntax)108 413.3 Q
F3($1.salary)2.75 E F2(.)A .755(Before launching into the subject of fu\
nctions that return composite types, we must \214rst)108 430.4 R .063
(introduce the)108 443.6 R/F4 11/Times-Italic@0 SF(function)2.813 E F2
.063(notation for projecting attrib)2.813 F 2.813(utes. The)-.22 F .064
(simple w)2.814 F .064(ay to e)-.11 F .064(xplain this is)-.165 F 1.137
(that we can usually use the notation)108 456.8 R F3(attribute\(class\))
3.886 E F2(and)3.886 E F3(class.attribute)3.886 E F2(interchang)108 470
Q(ably)-.055 E(.)-.715 E F0(--)148 495.2 Q(-- this is the same as:)148
507.4 Q 11(-- SELECT)148 519.6 R
(EMP.name AS youngster FROM EMP WHERE EMP.age < 30)6 E(--)148 531.8 Q
(SELECT name\(EMP\) AS youngster)148 544 Q(FROM EMP)148 556.2 Q
(WHERE age\(EMP\) < 30;)148 568.4 Q 212 598.9 148 598.9 DL(youngster)153
608.6 Q 212 613.1 148 613.1 DL(Sam)153 622.8 Q 212 627.3 148 627.3 DL
212 598.9 212 627.3 DL 148 598.9 148 627.3 DL F2(As we shall see, ho)108
649 Q(we)-.275 E -.165(ve)-.275 G .88 -.44(r, t).165 H(his is not al).44
E -.11(wa)-.11 G(ys the case.).11 E .763
(This function notation is important when we w)108 666.1 R .764
(ant to use a function that returns a single)-.11 F 3.825(instance. W)
108 679.3 R 3.825(ed)-.88 G 3.825(ot)-3.825 G 1.075
(his by assembling the entire instance within the function, attrib)
-3.825 F 1.074(ute by)-.22 F(attrib)108 692.5 Q 2.75(ute. This)-.22 F
(is an e)2.75 E(xample of a function that returns a single)-.165 E F3
(EMP)2.75 E F2(instance:)2.75 E/F5 11/Times-Bold@0 SF(26)282.5 756 Q EP
%%Page: 27 27
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(CREATE FUNCTION new_emp\(\) RETURNS EMP)148 96.2 Q
(AS 'SELECT \\'None\\'::text AS name,)166 108.4 Q(1000 AS salary,)232
120.6 Q(25 AS age,)232 132.8 Q(\\'none\\'::char16 AS dept;')232 145 Q
(LANGUAGE 'sql';)166 157.2 Q/F1 11/Times-Roman@0 SF .103
(In this case we ha)108 183.4 R .433 -.165(ve s)-.22 H .103
(peci\214ed each of the attrib).165 F .103(utes with a constant v)-.22 F
.103(alue, b)-.275 F .104(ut an)-.22 F 2.854(yc)-.165 G(ompu-)-2.854 E
(tation or e)108 196.6 Q(xpression could ha)-.165 E .33 -.165(ve b)-.22
H(een substituted for these constants.).165 E .014
(De\214ning a function lik)108 213.7 R 2.764(et)-.11 G .014
(his can be trick)-2.764 F 4.194 -.715(y. S)-.165 H .014
(ome of the more important ca).715 F -.165(ve)-.22 G .013
(ats are as fol-).165 F(lo)108 226.9 Q(ws:)-.275 E 5.5<8354>113.5 244 S
.286(he tar)-5.5 F .286(get list order must be)-.198 F/F2 11
/Times-Bold@0 SF(exactly)3.036 E F1 .286
(the same as that in which the attrib)3.036 F .286(utes appear in)-.22 F
(the)122.85 257.2 Q F2(CREA)2.75 E(TE T)-1.045 E(ABLE)-.99 E F1
(statement \(or when you e)2.75 E -.165(xe)-.165 G(cute a).165 E/F3 11
/Courier@0 SF(.*)2.75 E F1(query\).)5.5 E 5.5<8359>113.5 270.4 S .556
(ou must be careful to typecast the e)-6.71 F .555(xpressions \(using)
-.165 F F3(::)3.305 E F1 3.305(\)v)C .555(ery carefully or you will)
-3.47 F(see the follo)122.85 283.6 Q(wing error:)-.275 E F0
(WARN::function declared to return type EMP does not retrieve \(EMP.*\))
162.85 308.8 Q F1 5.5<8357>113.5 338.9 S 3.364
(hen calling a function that returns an instance, we cannot retrie)-5.5
F 3.695 -.165(ve t)-.275 H 3.365(he entire).165 F 4.436(instance. W)
122.85 352.1 R 4.436(em)-.88 G 1.686(ust either project an attrib)-4.436
F 1.685(ute out of the instance or pass the entire)-.22 F
(instance into another function.)122.85 365.3 Q F0
(SELECT name\(new_emp\(\)\) AS nobody;)162.85 390.5 Q .4 LW 208.85 421
162.85 421 DL(nobody)167.85 430.7 Q 208.85 435.2 162.85 435.2 DL(None)
167.85 444.9 Q 208.85 449.4 162.85 449.4 DL 208.85 421 208.85 449.4 DL
162.85 421 162.85 449.4 DL F1 5.5<8354>113.5 471.1 S .701(he reason wh)
-5.5 F 2.131 -.715(y, i)-.055 H 3.451(ng).715 G .702
(eneral, we must use the function syntax for projecting attrib)-3.451 F
(utes)-.22 E .418(of function return v)122.85 484.3 R .418
(alues is that the parser just doesn')-.275 F 3.168(tu)-.198 G .418
(nderstand the other \(dot\) syn-)-3.168 F
(tax for projection when combined with function calls.)122.85 497.5 Q F0
(SELECT new_emp\(\).name AS nobody;)162.85 522.7 Q
(WARN:parser: syntax error at or near ".")162.85 534.9 Q F1(An)108 565 Q
3.873(yc)-.165 G 1.124(ollection of commands in the SQL query language \
can be packaged together and)-3.873 F 2.551(de\214ned as a function.)108
578.2 R 2.551(The commands can include updates \(i.e.,)8.051 F F2
(insert)5.301 E F1(,)A F2(update)5.301 E F1(and)5.301 E F2(delete)108
591.4 Q F1 4.825(\)a)C 4.825(sw)-4.825 G 2.075(ell as)-4.825 F F2
(select)4.825 E F1 4.825(queries. Ho)4.825 F(we)-.275 E -.165(ve)-.275 G
2.955 -.44(r, t).165 H 2.075(he \214nal command must be a).44 F F2
(select)4.825 E F1(that)4.826 E(returns whate)108 604.6 Q -.165(ve)-.275
G 2.75(ri).165 G 2.75(ss)-2.75 G(peci\214ed as the function')-2.75 E(s)
-.605 E F3(returntype)2.75 E F1(.)A F0
(CREATE FUNCTION clean_EMP \(\) RETURNS int4)148 629.8 Q
(AS 'DELETE FROM EMP WHERE EMP.salary <= 0;)166 642 Q
(SELECT 1 AS ignore_this')190 654.2 Q(LANGUAGE 'sql';)166 666.4 Q
(SELECT clean_EMP\(\);)148 690.8 Q F2(27)282.5 756 Q EP
%%Page: 28 28
%%BeginPageSetup
BP
%%EndPageSetup
.4 LW 164 88.5 148 88.5 DL/F0 10/Courier@0 SF(x)153 98.2 Q 164 102.7 148
102.7 DL(1)153 112.4 Q 164 116.9 148 116.9 DL 164 88.5 164 116.9 DL 148
88.5 148 116.9 DL/F1 12/Times-Bold@0 SF 3(7.2. Pr)72 151.6 R
(ogramming Language Functions)-.216 E .44 LW 77.5 164.8 72 164.8 DL 80.5
164.8 75 164.8 DL 86 164.8 80.5 164.8 DL 91.5 164.8 86 164.8 DL 97 164.8
91.5 164.8 DL 102.5 164.8 97 164.8 DL 108 164.8 102.5 164.8 DL 113.5
164.8 108 164.8 DL 119 164.8 113.5 164.8 DL 124.5 164.8 119 164.8 DL 130
164.8 124.5 164.8 DL 135.5 164.8 130 164.8 DL 141 164.8 135.5 164.8 DL
146.5 164.8 141 164.8 DL 152 164.8 146.5 164.8 DL 157.5 164.8 152 164.8
DL 163 164.8 157.5 164.8 DL 168.5 164.8 163 164.8 DL 174 164.8 168.5
164.8 DL 179.5 164.8 174 164.8 DL 185 164.8 179.5 164.8 DL 190.5 164.8
185 164.8 DL 196 164.8 190.5 164.8 DL 201.5 164.8 196 164.8 DL 207 164.8
201.5 164.8 DL 212.5 164.8 207 164.8 DL 218 164.8 212.5 164.8 DL 223.5
164.8 218 164.8 DL 229 164.8 223.5 164.8 DL 234.5 164.8 229 164.8 DL 240
164.8 234.5 164.8 DL 245.5 164.8 240 164.8 DL 251 164.8 245.5 164.8 DL
256.5 164.8 251 164.8 DL 262 164.8 256.5 164.8 DL 267.5 164.8 262 164.8
DL 273 164.8 267.5 164.8 DL 278.5 164.8 273 164.8 DL 284 164.8 278.5
164.8 DL 289.5 164.8 284 164.8 DL 295 164.8 289.5 164.8 DL 300.5 164.8
295 164.8 DL 306 164.8 300.5 164.8 DL 311.5 164.8 306 164.8 DL 317 164.8
311.5 164.8 DL 322.5 164.8 317 164.8 DL 328 164.8 322.5 164.8 DL 333.5
164.8 328 164.8 DL 339 164.8 333.5 164.8 DL 344.5 164.8 339 164.8 DL 350
164.8 344.5 164.8 DL 355.5 164.8 350 164.8 DL 361 164.8 355.5 164.8 DL
366.5 164.8 361 164.8 DL 372 164.8 366.5 164.8 DL 377.5 164.8 372 164.8
DL 383 164.8 377.5 164.8 DL 388.5 164.8 383 164.8 DL 394 164.8 388.5
164.8 DL 399.5 164.8 394 164.8 DL 405 164.8 399.5 164.8 DL 410.5 164.8
405 164.8 DL 416 164.8 410.5 164.8 DL 421.5 164.8 416 164.8 DL 427 164.8
421.5 164.8 DL 432.5 164.8 427 164.8 DL 438 164.8 432.5 164.8 DL 443.5
164.8 438 164.8 DL 449 164.8 443.5 164.8 DL 454.5 164.8 449 164.8 DL 460
164.8 454.5 164.8 DL 465.5 164.8 460 164.8 DL 471 164.8 465.5 164.8 DL
476.5 164.8 471 164.8 DL 482 164.8 476.5 164.8 DL 487.5 164.8 482 164.8
DL 493 164.8 487.5 164.8 DL 498.5 164.8 493 164.8 DL 504 164.8 498.5
164.8 DL 3(7.2.1. Pr)72 204.2 R(ogramming Language Functions on Base T)
-.216 E(ypes)-.888 E/F2 11/Times-Roman@0 SF(Internally)108 221.3 Q(,)
-.715 E/F3 10/Times-Roman@0 SF(POSTGRES)2.921 E F2(re)2.921 E -.055(ga)
-.165 G .171(rds a base type as a \231blob of memory).055 F 4.462 -.77
(.\232 T)-.715 H .172(he user).77 F .172(-de\214ned func-)-.22 F .359
(tions that you de\214ne o)108 234.5 R -.165(ve)-.165 G 3.108(rat).165 G
.358(ype in turn de\214ne the w)-3.108 F .358(ay that)-.11 F F3
(POSTGRES)3.108 E F2 .358(can operate on it.)3.108 F 1.561(That is,)108
247.7 R F3(POSTGRES)4.311 E F2 1.562(will only store and retrie)4.311 F
1.892 -.165(ve t)-.275 H 1.562(he data from disk and use your user).165
F(-)-.22 E(de\214ned functions to input, process, and output the data.)
108 260.9 Q(Base types can ha)108 278 Q .33 -.165(ve o)-.22 H
(ne of three internal formats:).165 E 5.5<8370>113.5 295.1 S(ass by v)
-5.5 E(alue, \214x)-.275 E(ed-length)-.165 E 5.5<8370>113.5 308.3 S
(ass by reference, \214x)-5.5 E(ed-length)-.165 E 5.5<8370>113.5 321.5 S
(ass by reference, v)-5.5 E(ariable-length)-.275 E(By-v)108 338.6 Q .513
(alue types can only be 1, 2 or 4 bytes in length \(e)-.275 F -.165(ve)
-.275 G 3.262(ni).165 G 3.262(fy)-3.262 G .512
(our computer supports by-)-3.262 F -.275(va)108 351.8 S 1.546
(lue types of other sizes\).).275 F F3(POSTGRES)7.046 E F2 1.547
(itself only passes inte)4.296 F 1.547(ger types by v)-.165 F 4.297
(alue. Y)-.275 F(ou)-1.21 E .012
(should be careful to de\214ne your types such that the)108 365 R 2.762
(yw)-.165 G .012(ill be the same size \(in bytes\) on all)-2.762 F 4.056
(architectures. F)108 378.2 R 1.306(or e)-.165 F 1.306(xample, the)-.165
F/F4 11/Courier@0 SF(long)4.056 E F2 1.307
(type is dangerous because it is 4 bytes on some)4.056 F 1.213
(machines and 8 bytes on others, whereas)108 391.4 R F4(int)3.963 E F2
1.213(type is 4 bytes on most)3.963 F F3(UNIX)3.963 E F2(machines)3.963
E 1.798(\(though not on most personal computers\).)108 404.6 R 4.548(Ar)
7.298 G 1.798(easonable implementation of the)-4.548 F F4(int4)4.548 E
F2(type on)108 417.8 Q F3(UNIX)2.75 E F2(machines might be:)2.75 E F0
(/* 4-byte integer, passed by value */)148 443 Q(typedef int int4;)148
455.2 Q F2 .251(On the other hand, \214x)108 481.4 R .251
(ed-length types of an)-.165 F 3.001(ys)-.165 G .25
(ize may be passed by-reference.)-3.001 F -.165(Fo)5.75 G 3(re).165 G
(xam-)-3.165 E(ple, here is a sample implementation of the)108 494.6 Q
F3(POSTGRES)2.75 E F4(char16)2.75 E F2(type:)2.75 E F0
(/* 16-byte structure, passed by reference */)148 519.8 Q
(typedef struct {)148 532 Q(char data[16];)172 544.2 Q 6(}c)148 556.4 S
(har16;)-6 E F2 1.537(Only pointers to such types can be used when pass\
ing them in and out of)108 582.6 R F3(POSTGRES)4.287 E F2(functions.)108
595.8 Q(Finally)108 612.9 Q 4.149(,a)-.715 G 1.399(ll v)-4.149 F 1.399
(ariable-length types must also be passed by reference.)-.275 F 1.399
(All v)6.899 F(ariable-length)-.275 E 1.027(types must be)108 626.1 R
1.027(gin with a length \214eld of e)-.165 F 1.028
(xactly 4 bytes, and all data to be stored within)-.165 F 1.456
(that type must be located in the memory immediately follo)108 639.3 R
1.456(wing that length \214eld.)-.275 F(The)6.956 E .613(length \214eld\
is the total length of the structure \(i.e., it includes the size of t\
he length \214eld)108 652.5 R 2.75(itself\). W)108 665.7 R 2.75(ec)-.88
G(an de\214ne the)-2.75 E F4(text)2.75 E F2(type as follo)2.75 E(ws:)
-.275 E F0(typedef struct {)148 690.9 Q(int4 length;)172 703.1 Q/F5 11
/Times-Bold@0 SF(28)282.5 756 Q EP
%%Page: 29 29
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(char data[1];)172 96.2 Q 6(}t)148 108.4 S(ext;)-6 E
/F1 11/Times-Roman@0 SF(Ob)108 134.6 Q(viously)-.165 E 3.247(,t)-.715 G
(he)-3.247 E/F2 11/Courier@0 SF(data)3.247 E F1 .496
(\214eld is not long enough to hold all possible strings \212 it')3.247
F 3.246(si)-.605 G(mpossi-)-3.246 E .825
(ble to declare such a structure in C.)108 147.8 R .825
(When manipulating v)6.325 F .825(ariable-length types, we must)-.275 F
1.108(be careful to allocate the correct amount of memory and initializ\
e the length \214eld.)108 161 R -.165(Fo)6.607 G(r).165 E -.165(ex)108
174.2 S .75(ample, if we w).165 F .75(anted to store 40 bytes in a)-.11
F F2(text)3.501 E F1 .751(structure, we might use a code frag-)3.501 F
(ment lik)108 187.4 Q 2.75(et)-.11 G(his:)-2.75 E F0
(#include "postgres.h")148 212.6 Q(#include "utils/palloc.h")148 224.8 Q
(...)148 249.2 Q(char buffer[40]; /* our source data */)148 273.6 Q(...)
148 298 Q(text *destination = \(text *\) palloc\(VARHDRSZ + 40\);)148
322.4 Q(destination->length = VARHDRSZ + 40;)148 334.6 Q
(memmove\(destination->data, buffer, 40\);)148 346.8 Q(...)148 371.2 Q
F1(No)108 401.3 Q 2.913(wt)-.275 G .163(hat we')-2.913 F .493 -.165
(ve g)-.55 H .163(one o).165 F -.165(ve)-.165 G 2.912(ra).165 G .162
(ll of the possible structures for base types, we can sho)-2.912 F 2.912
(ws)-.275 G(ome)-2.912 E -.165(ex)108 414.5 S
(amples of real functions. Suppose).165 E F2(funcs.c)2.75 E F1(look lik)
2.75 E(e:)-.11 E F0(#include <string.h>)148 439.7 Q
(#include "postgres.h")148 451.9 Q(/* for char16, etc. */)12 E
(#include "utils/palloc.h" /* for palloc */)148 464.1 Q(int)148 488.5 Q
(add_one\(int arg\))148 500.7 Q({)148 512.9 Q(return\(arg + 1\);)172
525.1 Q(})148 537.3 Q(char16 *)148 561.7 Q
(concat16\(char16 *arg1, char16 *arg2\))148 573.9 Q({)148 586.1 Q
(char16 *new_c16 = \(char16 *\) palloc\(sizeof\(char16\)\);)172 598.3 Q
(memset\(\(void *\) new_c16, 0, sizeof\(char16\)\);)172 622.7 Q
(\(void\) strncpy\(new_c16, arg1, 16\);)172 634.9 Q
(return \(char16 *\)\(strncat\(new_c16, arg2, 16\)\);)172 647.1 Q(})148
659.3 Q(text *)148 683.7 Q(copytext\(text *t\))148 695.9 Q({)148 708.1 Q
(/*)172 720.3 Q/F3 11/Times-Bold@0 SF(29)282.5 756 Q EP
%%Page: 30 30
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF 6(*V)178 96.2 S
(ARSIZE is the total size of the struct in bytes.)-6 E(*/)178 108.4 Q
(text *new_t = \(text *\) palloc\(VARSIZE\(t\)\);)172 120.6 Q
(memset\(new_t, 0, VARSIZE\(t\)\);)172 145 Q
(VARSIZE\(new_t\) = VARSIZE\(t\);)172 169.4 Q(/*)172 181.6 Q 6(*V)178
193.8 S(ARDATA is a pointer to the data region of the struct.)-6 E(*/)
178 206 Q(memcpy\(\(void *\) VARDATA\(new_t\), /* destination */)172
218.2 Q(\(void *\) VARDATA\(t\),)214 230.4 Q(/* source */)30 E 78
(VARSIZE\(t\)-VARHDRSZ\); /*)214 242.6 R(how many bytes */)6 E
(return\(new_t\);)172 267 Q(})148 279.2 Q/F1 11/Times-Roman@0 SF(On)108
305.4 Q/F2 10/Times-Roman@0 SF(OSF/1)2.75 E F1(we w)2.75 E(ould type:)
-.11 E F0(CREATE FUNCTION add_one\(int4\) RETURNS int4)148 330.6 Q
(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)178
342.8 Q(CREATE FUNCTION concat16\(char16, char16\) RETURNS char16)148
367.2 Q(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)
178 379.4 Q(CREATE FUNCTION copytext\(text\) RETURNS text)148 403.8 Q
(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)178 416
Q F1 .412(On other systems, we might ha)108 442.2 R .742 -.165(ve t)-.22
H 3.162(om).165 G(ak)-3.162 E 3.162(et)-.11 G .412(he \214lename end in)
-3.162 F/F3 11/Courier@0 SF(.sl)3.162 E F1 .413(\(to indicate that it')
3.162 F 3.163(sa)-.605 G(shared library\).)108 455.4 Q/F4 12
/Times-Bold@0 SF 3(7.2.2. Pr)72 481.6 R
(ogramming Language Functions on Composite T)-.216 E(ypes)-.888 E F1
1.054(Composite types do not ha)108 498.7 R 1.384 -.165(ve a \214)-.22 H
-.165(xe).165 G 3.804(dl).165 G 1.054(ayout lik)-3.804 F 3.804(eC)-.11 G
3.803(structures. Instances)-.001 F 1.053(of a composite)3.803 F .636
(type may contain null \214elds.)108 511.9 R .637
(In addition, composite types that are part of an inheritance)6.136 F
(hierarch)108 525.1 Q 2.858(ym)-.055 G .108(ay ha)-2.858 F .438 -.165
(ve d)-.22 H(if).165 E .107
(ferent \214elds than other members of the same inheritance hierarch)
-.275 F -.715(y.)-.055 G(Therefore,)108 538.3 Q F2(POSTGRES)3.867 E F1
(pro)3.867 E 1.117(vides a procedural interf)-.165 F 1.117
(ace for accessing \214elds of composite)-.11 F(types from C.)108 551.5
Q(As)108 568.6 Q F2(POSTGRES)3.483 E F1 .733(processes a set of instanc\
es, each instance will be passed into your func-)3.483 F
(tion as an opaque structure of type TUPLE.)108 581.8 Q(Suppose we w)108
598.9 Q(ant to write a function to answer the query)-.11 E F0 6(*S)148
624.1 S(ELECT name, c_overpaid\(EMP, 1500\) AS overpaid)-6 E(FROM EMP)
160 636.3 Q(WHERE name = 'Bill' or name = 'Sam';)160 648.5 Q F1
(In the query abo)108 674.7 Q -.165(ve)-.165 G 2.75(,w).165 G 2.75(ec)
-2.75 G(an de\214ne)-2.75 E F3(c_overpaid)2.75 E F1(as:)2.75 E F0
(#include "postgres.h")148 699.9 Q(/* for char16, etc. */)12 E
(#include "libpq-fe.h" /* for TUPLE */)148 712.1 Q/F5 11/Times-Bold@0 SF
(30)282.5 756 Q EP
%%Page: 31 31
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(bool)148 96.2 Q
(c_overpaid\(TUPLE t,/* the current instance of EMP */)148 108.4 Q
(int4 limit\))214 120.6 Q({)148 132.8 Q(bool isnull = false;)172 145 Q
(int4 salary;)172 157.2 Q
(salary = \(int4\) GetAttributeByName\(t, "salary", &isnull\);)172 181.6
Q(if \(isnull\))172 206 Q(return \(false\);)196 218.2 Q
(return\(salary > limit\);)172 230.4 Q(})148 242.6 Q/F1 11/Courier@0 SF
(GetAttributeByName)108 268.8 Q/F2 11/Times-Roman@0 SF .07(is the)2.82 F
/F3 10/Times-Roman@0 SF(POSTGRES)2.82 E F2 .07
(system function that returns attrib)2.82 F .07(utes out of)-.22 F .165
(the current instance.)108 282 R .164(It has three ar)5.665 F .164
(guments: the ar)-.198 F .164(gument of type TUPLE passed into the)-.198
F .471(function, the name of the desired attrib)108 295.2 R .472
(ute, and a return parameter that describes whether)-.22 F .917
(the attrib)108 308.4 R .917(ute is null.)-.22 F F1(GetAttributeByName)
6.417 E F2 .916(will align data properly so you can cast)3.667 F .472
(its return v)108 321.6 R .472(alue to the desired type.)-.275 F -.165
(Fo)5.972 G 3.222(re).165 G .472(xample, if you ha)-3.387 F .803 -.165
(ve a)-.22 H 3.223(na).165 G(ttrib)-3.223 E(ute)-.22 E F1(name)3.223 E
F2 .473(which is)3.223 F(of the type)108 334.8 Q F1(char16)2.75 E F2
2.75(,t)C(he)-2.75 E F1(GetAttributeByName)2.75 E F2(call w)2.75 E
(ould look lik)-.11 E(e:)-.11 E F0(char *str;)148 360 Q(...)148 372.2 Q
(str = \(char *\) GetAttributeByName\(t, "name", &isnull\))148 384.4 Q
F2(The follo)108 414.5 Q(wing query lets)-.275 E F3(POSTGRES)2.75 E F2
(kno)2.75 E 2.75(wa)-.275 G(bout the)-2.75 E F1(c_overpaid)2.75 E F2
(function:)2.75 E F0 6(*C)148 439.7 S
(REATE FUNCTION c_overpaid\(EMP, int4\) RETURNS bool)-6 E
(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)178
451.9 Q F2 .212(While there are w)108 482 R .212(ays to construct ne)
-.11 F 2.962(wi)-.275 G .211(nstances or modify e)-2.962 F .211
(xisting instances from within)-.165 F 2.75(aCf)108 495.2 S
(unction, these are f)-2.75 E(ar too comple)-.11 E 2.75(xt)-.165 G 2.75
(od)-2.75 G(iscuss in this manual.)-2.75 E/F4 12/Times-Bold@0 SF 3
(7.2.3. Ca)72 521.4 R -.12(ve)-.3 G(ats).12 E F2 2.789 -.88(We n)108
538.5 T 1.579 -.275(ow t).88 H 1.03(urn to the more dif).275 F 1.03
(\214cult task of writing programming language functions.)-.275 F(Be)
6.53 E -.11(wa)108 551.7 S 1.163
(rned: this section of the manual will not mak).11 F 3.913(ey)-.11 G
1.163(ou a programmer)-3.913 F 6.663(.Y)-.605 G 1.163(ou must ha)-7.873
F 1.493 -.165(ve a)-.22 H 1.023
(good understanding of C \(including the use of pointers and the)108
564.9 R F1(malloc)3.773 E F2 1.023(memory man-)3.773 F
(ager\) before trying to write C functions for use with)108 578.1 Q F3
(POSTGRES)2.75 E F2(.)A .757(While it may be possible to load functions\
written in languages other than C into)108 595.2 R F3(POST)3.506 E(-)
-.92 E(GRES)108 608.4 Q F2 3.613(,t)C .863(his is often dif)-3.613 F
.864(\214cult \(when it is possible at all\) because other languages, s\
uch as)-.275 F F3(FOR)108 621.6 Q(TRAN)-.6 E F2 1.087(and P)3.837 F
1.087(ascal often do not follo)-.165 F 3.837(wt)-.275 G 1.086
(he same \231calling con)-3.837 F -.165(ve)-.44 G 1.086(ntion\232 as C.)
.165 F 1.086(That is,)6.586 F 1.24(other languages do not pass ar)108
634.8 R 1.24(gument and return v)-.198 F 1.241
(alues between functions in the same)-.275 F -.11(wa)108 648 S 4.214
-.715(y. F).11 H .034(or this reason, we will assume that your programm\
ing language functions are writ-).55 F(ten in C.)108 661.2 Q
(The basic rules for b)108 678.3 Q(uilding C functions are as follo)-.22
E(ws:)-.275 E 13.75(\(1\) Most)113.5 695.4 R 1.235
(of the header \(include\) \214les for)3.985 F F3(POSTGRES)3.985 E F2
1.236(should already be installed in)3.985 F F1
(/usr/local/postgres95/include)142.826 708.6 Q F2 2.464
(\(see Figure 2\).)5.214 F -1.21(Yo)7.964 G 5.214(us)1.21 G 2.464
(hould al)-5.214 F -.11(wa)-.11 G(ys).11 E(include)142.826 721.8 Q/F5 11
/Times-Bold@0 SF(31)282.5 756 Q EP
%%Page: 32 32
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(-I/usr/local/postgres95/include)182.826 96.2 Q/F1 11
/Times-Roman@0 SF 1.373(on your)142.826 122.4 R/F2 11/Courier@0 SF(cc)
4.123 E F1 1.373(command lines.)4.123 F 1.373
(Sometimes, you may \214nd that you require header)6.873 F .198
(\214les that are in the serv)142.826 135.6 R .197
(er source itself \(i.e., you need a \214le we ne)-.165 F .197
(glected to install)-.165 F(in)142.826 148.8 Q F2(include)2.75 E F1 2.75
(\). In)B(those cases you may need to add one or more of)2.75 E F0
(-I/usr/local/postgres95/src/backend)182.826 174 Q
(-I/usr/local/postgres95/src/backend/include)182.826 186.2 Q
(-I/usr/local/postgres95/src/backend/port/<PORTNAME>)182.826 198.4 Q
(-I/usr/local/postgres95/src/backend/obj)182.826 210.6 Q F1(\(where)
142.826 236.8 Q F2(<PORTNAME>)2.75 E F1(is the name of the port, e.g.,)
2.75 E F2(alpha)2.75 E F1(or)2.75 E F2(sparc\).)2.75 E F1 13.75
(\(2\) When)113.5 253.9 R 2.892(allocating memory)5.642 F 5.642(,u)-.715
G 2.892(se the)-5.642 F/F3 10/Times-Roman@0 SF(POSTGRES)5.643 E F1
(routines)5.643 E F2(palloc)5.643 E F1(and)5.643 E F2(pfree)5.643 E F1
.088(instead of the corresponding C library routines)142.826 267.1 R F2
(malloc)2.838 E F1(and)2.838 E F2(free)2.838 E F1 5.588(.T)C .088
(he memory)-5.588 F .857(allocated by)142.826 280.3 R F2(palloc)3.607 E
F1 .857(will be freed automatically at the end of each transaction,)
3.607 F(pre)142.826 293.5 Q -.165(ve)-.275 G(nting memory leaks.).165 E
13.75(\(3\) Al)113.5 310.6 R -.11(wa)-.11 G .427
(ys zero the bytes of your structures using).11 F F2(memset)3.177 E F1
(or)3.177 E F2(bzero)3.177 E F1 5.927(.S)C -2.365 -.275(ev e)-5.927 H
.427(ral rou-).275 F .521(tines \(such as the hash access method, hash \
join and the sort algorithm\) compute)142.826 323.8 R 1.463
(functions of the ra)142.826 337 R 4.213(wb)-.165 G 1.463
(its contained in your structure.)-4.213 F(Ev)6.963 E 1.463
(en if you initialize all)-.165 F .133
(\214elds of your structure, there may be se)142.826 350.2 R -.165(ve)
-.275 G .133(ral bytes of alignment padding \(holes in).165 F
(the structure\) that may contain g)142.826 363.4 Q(arbage v)-.055 E
(alues.)-.275 E 13.75(\(4\) Most)113.5 380.5 R .496(of the internal)
3.246 F F3(POSTGRES)3.246 E F1 .496(types are declared in)3.246 F F2
(postgres.h)3.245 E F1 3.245(,s)C 3.245(oi)-3.245 G(t')-3.245 E 3.245
(su)-.605 G(su-)-3.245 E
(ally a good idea to include that \214le as well.)142.826 393.7 Q 13.75
(\(5\) Compiling)113.5 410.8 R .214
(and loading your object code so that it can be dynamically loaded into)
2.964 F F3(POSTGRES)142.826 424 Q F1(al)2.83 E -.11(wa)-.11 G .08
(ys requires special \215ags.).11 F .079
(See Appendix A for a detailed e)5.58 F(xplana-)-.165 E(tion of ho)
142.826 437.2 Q 2.75(wt)-.275 G 2.75(od)-2.75 G 2.75(oi)-2.75 G 2.75(tf)
-2.75 G(or your particular operating system.)-2.75 E/F4 11/Times-Bold@0
SF(32)282.5 756 Q EP
%%Page: 33 33
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(8. EXTENDING)72 165.4 R(SQL: TYPES)
4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6
DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL
108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6
DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130
178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6
146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5
178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185
178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL
201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6
DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5
178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6
240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6
256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5
178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295
178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL
311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6
DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5
178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6
350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6
366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5
178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405
178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL
421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6
DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5
178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6
460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6
476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5
178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF .275
(As pre)108 208.9 R .275(viously mentioned, there are tw)-.275 F 3.025
(ok)-.11 G .276(inds of types in)-3.025 F/F2 10/Times-Roman@0 SF
(POSTGRES)3.026 E F1(:)A/F3 11/Times-Italic@0 SF(base)3.026 E F1 .276
(types \(de\214ned)3.026 F(in a programming language\) and)108 222.1 Q
F3(composite)2.75 E F1(types \(instances\).)2.75 E 1.449
(Examples in this section up to interf)108 239.2 R 1.448
(acing indices can be found in)-.11 F/F4 11/Courier@0 SF(complex.sql)
4.198 E F1(and)A F4(complex.c)108 252.4 Q F1 5.5(.C)C(omposite e)-5.5 E
(xamples are in)-.165 E F4(funcs.sql)2.75 E F1(.)A/F5 12/Times-Bold@0 SF
3(8.1. User)72 278.6 R(-De\214ned T)-.444 E(ypes)-.888 E 77.5 291.8 72
291.8 DL 80.5 291.8 75 291.8 DL 86 291.8 80.5 291.8 DL 91.5 291.8 86
291.8 DL 97 291.8 91.5 291.8 DL 102.5 291.8 97 291.8 DL 108 291.8 102.5
291.8 DL 113.5 291.8 108 291.8 DL 119 291.8 113.5 291.8 DL 124.5 291.8
119 291.8 DL 130 291.8 124.5 291.8 DL 135.5 291.8 130 291.8 DL 141 291.8
135.5 291.8 DL 146.5 291.8 141 291.8 DL 152 291.8 146.5 291.8 DL 157.5
291.8 152 291.8 DL 163 291.8 157.5 291.8 DL 168.5 291.8 163 291.8 DL 174
291.8 168.5 291.8 DL 179.5 291.8 174 291.8 DL 185 291.8 179.5 291.8 DL
190.5 291.8 185 291.8 DL 196 291.8 190.5 291.8 DL 201.5 291.8 196 291.8
DL 207 291.8 201.5 291.8 DL 212.5 291.8 207 291.8 DL 218 291.8 212.5
291.8 DL 223.5 291.8 218 291.8 DL 229 291.8 223.5 291.8 DL 234.5 291.8
229 291.8 DL 240 291.8 234.5 291.8 DL 245.5 291.8 240 291.8 DL 251 291.8
245.5 291.8 DL 256.5 291.8 251 291.8 DL 262 291.8 256.5 291.8 DL 267.5
291.8 262 291.8 DL 273 291.8 267.5 291.8 DL 278.5 291.8 273 291.8 DL 284
291.8 278.5 291.8 DL 289.5 291.8 284 291.8 DL 295 291.8 289.5 291.8 DL
300.5 291.8 295 291.8 DL 306 291.8 300.5 291.8 DL 311.5 291.8 306 291.8
DL 317 291.8 311.5 291.8 DL 322.5 291.8 317 291.8 DL 328 291.8 322.5
291.8 DL 333.5 291.8 328 291.8 DL 339 291.8 333.5 291.8 DL 344.5 291.8
339 291.8 DL 350 291.8 344.5 291.8 DL 355.5 291.8 350 291.8 DL 361 291.8
355.5 291.8 DL 366.5 291.8 361 291.8 DL 372 291.8 366.5 291.8 DL 377.5
291.8 372 291.8 DL 383 291.8 377.5 291.8 DL 388.5 291.8 383 291.8 DL 394
291.8 388.5 291.8 DL 399.5 291.8 394 291.8 DL 405 291.8 399.5 291.8 DL
410.5 291.8 405 291.8 DL 416 291.8 410.5 291.8 DL 421.5 291.8 416 291.8
DL 427 291.8 421.5 291.8 DL 432.5 291.8 427 291.8 DL 438 291.8 432.5
291.8 DL 443.5 291.8 438 291.8 DL 449 291.8 443.5 291.8 DL 454.5 291.8
449 291.8 DL 460 291.8 454.5 291.8 DL 465.5 291.8 460 291.8 DL 471 291.8
465.5 291.8 DL 476.5 291.8 471 291.8 DL 482 291.8 476.5 291.8 DL 487.5
291.8 482 291.8 DL 493 291.8 487.5 291.8 DL 498.5 291.8 493 291.8 DL 504
291.8 498.5 291.8 DL 3(8.1.1. Functions)72 322.1 R(Needed f)3 E
(or a User)-.3 E(-De\214ned T)-.444 E(ype)-.888 E F1 3.097(Au)108 339.2
S(ser)-3.097 E .347(-de\214ned type must al)-.22 F -.11(wa)-.11 G .347
(ys ha).11 F -.165(ve)-.22 G F3(input)3.262 E F1(and)3.096 E F3(output)
3.096 E F1 3.096(functions. These)3.096 F .346(functions deter)3.096 F
(-)-.22 E 1.115(mine ho)108 352.4 R 3.865(wt)-.275 G 1.116(he type appe\
ars in strings \(for input by the user and output to the user\) and)
-3.865 F(ho)108 365.6 Q 2.93(wt)-.275 G .18(he type is or)-2.93 F -.055
(ga)-.198 G .18(nized in memory).055 F 5.679(.T)-.715 G .179
(he input function tak)-5.679 F .179(es a null-delimited character)-.11
F 1.27(string as its input and returns the internal \(in memory\) repre\
sentation of the type.)108 378.8 R(The)6.77 E .931(output function tak)
108 392 R .93(es the internal representation of the type and returns a \
null-delimited)-.11 F(character string.)108 405.2 Q .939(Suppose we w)
108 422.3 R .939(ant to de\214ne a)-.11 F F4(complex)3.69 E F1 .94
(type which represents comple)3.69 F 3.69(xn)-.165 G .94(umbers. Natu-)
-3.69 F(rally)108 435.5 Q 2.75(,w)-.715 G 2.75(ec)-2.75 G
(hoose to represent a comple)-2.75 E 2.75(xi)-.165 G 2.75(nm)-2.75 G
(emory as the follo)-2.75 E(wing C structure:)-.275 E/F6 10/Courier@0 SF
(typedef struct Complex {)148 460.7 Q 30(double x;)172 472.9 R 30
(double y;)172 485.1 R 6(}C)148 497.3 S(omplex;)-6 E F1
(and a string of the form)108 523.5 Q F4(\(x,y\))2.75 E F1(as the e)2.75
E(xternal string representation.)-.165 E 1.12(These functions are usual\
ly not hard to write, especially the output function.)108 540.6 R(Ho)
6.62 E(we)-.275 E -.165(ve)-.275 G -.44(r,).165 G
(there are a number of points to remember)108 553.8 Q(.)-.605 E 13.75
(\(1\) When)113.5 570.9 R 2.47(de\214ning your e)5.22 F 2.47
(xternal \(string\) representation, remember that you must)-.165 F
-2.365 -.275(ev e)142.826 584.1 T .113(ntually write a complete and rob)
.275 F .113(ust parser for that representation as your input)-.22 F
(function!)142.826 597.3 Q F6(Complex *)182.826 622.5 Q
(complex_in\(char *str\))182.826 634.7 Q({)182.826 646.9 Q(double x, y;)
206.826 659.1 Q(Complex *result;)206.826 671.3 Q
(if \(sscanf\(str, " \( %lf , %lf \)", &x, &y\) != 2\) {)206.826 695.7 Q
(elog\(WARN, "complex_in: error in parsing)230.826 707.9 Q(return NULL;)
230.826 720.1 Q/F7 11/Times-Bold@0 SF(33)282.5 756 Q EP
%%Page: 34 34
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(})206.826 96.2 Q
(result = \(Complex *\)palloc\(sizeof\(Complex\)\);)206.826 108.4 Q
(result->x = x;)206.826 120.6 Q(result->y = y;)206.826 132.8 Q
(return \(result\);)206.826 145 Q(})182.826 157.2 Q/F1 11/Times-Roman@0
SF(The output function can simply be:)142.826 183.4 Q F0(char *)182.826
208.6 Q(complex_out\(Complex *complex\))182.826 220.8 Q({)182.826 233 Q
(char *result;)206.826 245.2 Q(if \(complex == NULL\))206.826 269.6 Q
(return\(NULL\);)230.826 281.8 Q(result = \(char *\) palloc\(60\);)
206.826 306.2 Q(sprintf\(result, "\(%g,%g\)", complex->x, complex->y\);)
206.826 318.4 Q(return\(result\);)206.826 330.6 Q(})182.826 342.8 Q F1
13.75(\(2\) Y)113.5 372.9 R .752(ou should try to mak)-1.21 F 3.502(et)
-.11 G .752(he input and output functions in)-3.502 F -.165(ve)-.44 G
.752(rses of each other).165 F 6.252(.I)-.605 G(f)-6.252 E .181
(you do not, you will ha)142.826 386.1 R .511 -.165(ve s)-.22 H -2.365
-.275(ev e).165 H .18(re problems when you need to dump your data into)
.275 F 3.169<618c>142.826 399.3 S .419
(le and then read it back in \(say)-3.169 F 3.17(,i)-.715 G .42
(nto someone else')-3.17 F 3.17(sd)-.605 G .42(atabase on another com-)
-3.17 F 3.672(puter\). This)142.826 412.5 R .922
(is a particularly common problem when \215oating-point numbers are)
3.672 F(in)142.826 425.7 Q -.22(vo)-.44 G(lv).22 E(ed.)-.165 E 3.371
-.88(To d)108 442.8 T 1.612(e\214ne the).88 F/F2 11/Courier@0 SF
(complex)4.362 E F1 1.612(type, we need to create the tw)4.362 F 4.362
(ou)-.11 G(ser)-4.362 E 1.612(-de\214ned functions)-.22 F F2(com-)4.362
E(plex_in)108 456 Q F1(and)2.75 E F2(complex_out)2.75 E F1
(before creating the type:)2.75 E F0
(CREATE FUNCTION complex_in\(opaque\))148 481.2 Q(RETURNS complex)166
493.4 Q(AS '/usr/local/postgres95/tutorial/obj/complex.so')166 505.6 Q
(LANGUAGE 'c';)166 517.8 Q(CREATE FUNCTION complex_out\(opaque\))148
542.2 Q(RETURNS opaque)166 554.4 Q
(AS '/usr/local/postgres95/tutorial/obj/complex.so')166 566.6 Q
(LANGUAGE 'c';)166 578.8 Q(CREATE TYPE complex \()148 603.2 Q
(internallength = 16,)166 615.4 Q(input = complex_in,)166 627.6 Q
(output = complex_out)166 639.8 Q(\);)148 652 Q F1 .371
(As discussed earlier)108 682.1 R(,)-.44 E/F3 10/Times-Roman@0 SF
(POSTGRES)3.121 E F1 .371(fully supports arrays of base types.)3.121 F
(Additionally)5.87 E(,)-.715 E F3(POST)3.12 E(-)-.92 E(GRES)108 695.3 Q
F1 .32(supports arrays of user)3.069 F .32(-de\214ned types as well.)
-.22 F .32(When you de\214ne a type,)5.82 F F3(POSTGRES)3.07 E F1 1.231
(automatically pro)108 708.5 R 1.23
(vides support for arrays of that type.)-.165 F -.165(Fo)6.73 G 3.98(rh)
.165 G 1.23(istorical reasons, the array)-3.98 F 3.301
(type has the same name as the user)108 721.7 R 3.301
(-de\214ned type with the underscore character)-.22 F F2(_)6.051 E/F4 11
/Times-Bold@0 SF(34)282.5 756 Q EP
%%Page: 35 35
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF(prepended.)108 97.2 Q 1.849
(Composite types do not need an)108 114.3 R 4.599(yf)-.165 G 1.849
(unction de\214ned on them, since the system already)-4.599 F
(understands what the)108 127.5 Q 2.75(yl)-.165 G(ook lik)-2.75 E 2.75
(ei)-.11 G(nside.)-2.75 E/F1 12/Times-Bold@0 SF 3(8.1.2. Lar)72 153.7 R
(ge Objects)-.12 E F0 .758(The types discussed to this point are all \
\231small\232 objects \212 that is, the)108 170.8 R 3.508(ya)-.165 G
.758(re smaller than)-3.508 F(8KB)108 186.2 Q/F2 8/Times-Roman@0 SF(7)
-4.4 I F0 .304(in size.)3.054 4.4 N .304(If you require a lar)5.804 F
.305(ger type for something lik)-.198 F 3.055(ead)-.11 G .305
(ocument retrie)-3.055 F -.275(va)-.275 G 3.055(ls).275 G(ystem)-3.055 E
(or for storing bitmaps, you will need to use the)108 199.4 Q/F3 10
/Times-Roman@0 SF(POSTGRES)2.75 E/F4 11/Times-Italic@0 SF(lar)2.75 E .22
-.11(ge o)-.407 H(bject).11 E F0(interf)2.75 E(ace.)-.11 E .32 LW 76
667.4 72 667.4 DL 80 667.4 76 667.4 DL 84 667.4 80 667.4 DL 88 667.4 84
667.4 DL 92 667.4 88 667.4 DL 96 667.4 92 667.4 DL 100 667.4 96 667.4 DL
104 667.4 100 667.4 DL 108 667.4 104 667.4 DL 112 667.4 108 667.4 DL 116
667.4 112 667.4 DL 120 667.4 116 667.4 DL 124 667.4 120 667.4 DL 128
667.4 124 667.4 DL 132 667.4 128 667.4 DL 136 667.4 132 667.4 DL 140
667.4 136 667.4 DL 144 667.4 140 667.4 DL 148 667.4 144 667.4 DL 152
667.4 148 667.4 DL 156 667.4 152 667.4 DL 160 667.4 156 667.4 DL 164
667.4 160 667.4 DL 168 667.4 164 667.4 DL 172 667.4 168 667.4 DL 176
667.4 172 667.4 DL 180 667.4 176 667.4 DL 184 667.4 180 667.4 DL 188
667.4 184 667.4 DL 192 667.4 188 667.4 DL 196 667.4 192 667.4 DL 200
667.4 196 667.4 DL 204 667.4 200 667.4 DL 208 667.4 204 667.4 DL 212
667.4 208 667.4 DL 216 667.4 212 667.4 DL/F5 5/Times-Roman@0 SF(7)93.6
677.8 Q F2 2.338(8*1)2.338 3.2 O .338(024 == 8192 bytes.)-2.338 F .338
(In f)4.338 F .338
(act, the type must be considerably smaller than 8192 bytes, since the)
-.08 F/F6 7/Times-Roman@0 SF(POSTGRES)2.338 E F2 .338(tuple and page)
2.338 F -.12(ove)72 690.6 S
(rhead must also \214t into this 8KB limitation.).12 E(The actual v)4 E
(alue that \214ts depends on the machine architecture.)-.2 E/F7 11
/Times-Bold@0 SF(35)282.5 756 Q EP
%%Page: 36 36
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(9. EXTENDING)72 165.4 R(SQL: OPERA)
4.75 E -.342(TO)-1.805 G(RS).342 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
/F1 10/Times-Roman@0 SF(POSTGRES)108 208.9 Q/F2 11/Times-Roman@0 SF .485
(supports left unary)3.235 F 3.235(,r)-.715 G .485
(ight unary and binary operators.)-3.235 F .484(Operators can be)5.984 F
/F3 11/Times-Italic@0 SF -.11(ov)3.234 G(er).11 E(-)-.22 E(loaded)108
222.1 Q F2 3.116(,o)C 3.117(rr)-3.116 G .367(e-used with dif)-3.117 F
.367(ferent numbers and types of ar)-.275 F 3.117(guments. If)-.198 F
.367(there is an ambigu-)3.117 F .126(ous situation and the system cann\
ot determine the correct operator to use, it will return an)108 235.3 R
1.232(error and you may ha)108 248.5 R 1.562 -.165(ve t)-.22 H 3.982(ot)
.165 G 1.232
(ypecast the left and/or right operands to help it understand)-3.982 F
(which operator you meant to use.)108 261.7 Q 2.289 -.88(To c)108 278.8
T .529(reate an operator for adding tw).88 F 3.279(oc)-.11 G(omple)
-3.279 E 3.279(xn)-.165 G .529(umbers can be done as follo)-3.279 F
3.278(ws. First)-.275 F(we)3.278 E .436
(need to create a function to add the ne)108 292 R 3.186(wt)-.275 G .436
(ypes. Then, we can create the operator with the)-3.186 F(function.)108
305.2 Q/F4 10/Courier@0 SF
(CREATE FUNCTION complex_add\(complex, complex\))148 330.4 Q
(RETURNS complex)166 342.6 Q(AS '$PWD/obj/complex.so')166 354.8 Q
(LANGUAGE 'c';)166 367 Q(CREATE OPERATOR + \()148 403.6 Q
(leftarg = complex,)166 415.8 Q(rightarg = complex,)166 428 Q
(procedure = complex_add,)166 440.2 Q(commutator = +)166 452.4 Q(\);)148
464.6 Q F2 -.88(We)108 506.9 S -1.815 -.55('v e).88 H(sho)4.31 E 1.01
(wn ho)-.275 F 3.76(wt)-.275 G 3.76(oc)-3.76 G 1.01
(reate a binary operator here. T)-3.76 F 3.759(oc)-.88 G 1.009
(reate unary operators, just omit)-3.759 F(one of)108 520.1 Q/F5 11
/Courier@0 SF(leftarg)2.75 E F2(\(for left unary\) or)2.75 E F5
(rightarg)2.75 E F2(\(for right unary\).)2.75 E 1.823(If we gi)108 537.2
R 2.153 -.165(ve t)-.275 H 1.824(he system enough type information, it \
can automatically \214gure out which).165 F(operators to use.)108 550.4
Q F4(SELECT \(a + b\) AS c FROM test_complex;)148 575.6 Q .4 LW 248
606.1 148 606.1 DL(c)153 615.8 Q 248 620.3 148 620.3 DL(\(5.2,6.05\))153
630 Q 248 634.5 148 634.5 DL(\(133.42,144.95\))153 644.2 Q 248 648.7 148
648.7 DL 248 606.1 248 648.7 DL 148 606.1 148 648.7 DL/F6 11
/Times-Bold@0 SF(36)282.5 756 Q EP
%%Page: 37 37
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(10. EXTENDING)72 165.4 R(SQL: A)4.75
E(GGREGA)-1.045 E(TES)-1.805 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
/F1 11/Times-Roman@0 SF(Aggre)108 208.9 Q -.055(ga)-.165 G .241(tes in)
.055 F/F2 10/Times-Roman@0 SF(POSTGRES)2.991 E F1 .241(are e)2.991 F
.241(xpressed in terms of)-.165 F/F3 11/Times-Italic@0 SF .241(state tr)
2.991 F .241(ansition functions)-.165 F F1 5.741(.T)C .24(hat is, an)
-5.741 F(aggre)108 222.1 Q -.055(ga)-.165 G .924
(te can be de\214ned in terms of).055 F F3(state)3.675 E F1 .925
(that is modi\214ed whene)3.675 F -.165(ve)-.275 G 3.675(ra).165 G 3.675
(ni)-3.675 G .925(nstance is pro-)-3.675 F 3.74(cessed. Some)108 235.3 R
.989(state functions look at a particular v)3.74 F .989
(alue in the instance when computing)-.275 F 1.59(the ne)108 248.5 R
4.34(ws)-.275 G 1.59(tate \()-4.34 F F3(sfunc1)A F1 1.59(in the)4.34 F
/F4 11/Times-Bold@0 SF(cr)4.34 E 1.59(eate aggr)-.198 F(egate)-.198 E F1
1.59(syntax\) while others only k)4.34 F 1.591(eep track of)-.11 F
(their o)108 261.7 Q(wn internal state \()-.275 E F3(sfunc2)A F1(\).)A
.085(If we de\214ne an aggre)108 278.8 R -.055(ga)-.165 G .084
(te that uses only).055 F/F5 11/Courier@0 SF(sfunc1)2.834 E F1 2.834(,w)
C 2.834(ed)-2.834 G .084(e\214ne an aggre)-2.834 F -.055(ga)-.165 G .084
(te that computes a).055 F .488(running function of the attrib)108 292 R
.488(ute v)-.22 F .488(alues from each instance.)-.275 F .488
(\231Sum\232 is an e)5.988 F .488(xample of this)-.165 F .074
(kind of aggre)108 305.2 R -.055(ga)-.165 G 2.824(te. \231Sum\232).055 F
.073(starts at zero and al)2.824 F -.11(wa)-.11 G .073
(ys adds the current instance').11 F 2.823(sv)-.605 G .073(alue to its)
-3.098 F .19(running total.)108 318.4 R 1.95 -.88(We w)5.69 H .19
(ill use the).88 F F5(int4pl)2.94 E F1 .19(that is b)2.94 F .191
(uilt into)-.22 F F2(POSTGRES)2.941 E F1 .191(to perform this addi-)
2.941 F(tion.)108 331.6 Q/F6 10/Courier@0 SF
(CREATE AGGREGATE complex_sum \()148 356.8 Q(sfunc1 = complex_add,)178
369 Q(basetype = complex,)178 381.2 Q(stype1 = complex,)178 393.4 Q
(initcond1 = '\(0,0\)')178 405.6 Q(\);)160 417.8 Q
(SELECT complex_sum\(a\) FROM test_complex;)148 454.4 Q .4 LW 224 484.9
148 484.9 DL(complex_sum)153 494.6 Q 224 499.1 148 499.1 DL(\(34,53.9\))
153 508.8 Q 224 513.3 148 513.3 DL 224 484.9 224 513.3 DL 148 484.9 148
513.3 DL F1 .184(If we de\214ne only)108 535 R F5(sfunc2)2.934 E F1
2.934(,w)C 2.934(ea)-2.934 G .184(re specifying an aggre)-2.934 F -.055
(ga)-.165 G .184(te that computes a running func-).055 F .998
(tion that is independent of the attrib)108 548.2 R .999(ute v)-.22 F
.999(alues from each instance.)-.275 F .999(\231Count\232 is the most)
6.499 F 1.313(common e)108 561.4 R 1.313(xample of this kind of aggre)
-.165 F -.055(ga)-.165 G 4.063(te. \231Count\232).055 F 1.312
(starts at zero and adds one to its)4.063 F 1.665
(running total for each instance, ignoring the instance v)108 574.6 R
4.415(alue. Here,)-.275 F 1.666(we use the b)4.415 F(uilt-in)-.22 E F5
(int4inc)108 587.8 Q F1 .631(routine to do the w)3.381 F .631
(ork for us.)-.11 F .63(This routine increments \(adds one to\) its ar)
6.131 F(gu-)-.198 E(ment.)108 601 Q F6
(CREATE AGGREGATE my_count \(sfunc2 = int4inc, -- add one)148 626.2 Q
(basetype = int4, stype2 = int4,)322 638.4 Q(initcond2 = '0'\))322 650.6
Q(SELECT my_count\(*\) as emp_count from EMP;)148 675 Q F4(37)282.5 756
Q EP
%%Page: 38 38
%%BeginPageSetup
BP
%%EndPageSetup
.4 LW 212 88.5 148 88.5 DL/F0 10/Courier@0 SF(emp_count)153 98.2 Q 212
102.7 148 102.7 DL(5)153 112.4 Q 212 116.9 148 116.9 DL 212 88.5 212
116.9 DL 148 88.5 148 116.9 DL/F1 11/Times-Roman@0 SF -1.804 -.88
(\231A v)108 138.6 T .095(erage\232 is an e).715 F .095
(xample of an aggre)-.165 F -.055(ga)-.165 G .096
(te that requires both a function to compute the run-).055 F .987
(ning sum and a function to compute the running count.)108 151.8 R .986
(When all of the instances ha)6.486 F -.165(ve)-.22 G .405
(been processed, the \214nal answer for the aggre)108 165 R -.055(ga)
-.165 G .405(te is the running sum di).055 F .405(vided by the run-)
-.275 F .923(ning count.)108 178.2 R 2.683 -.88(We u)6.423 H .923
(se the).88 F/F2 11/Courier@0 SF(int4pl)3.673 E F1(and)3.673 E F2
(int4inc)3.673 E F1 .922(routines we used before as well as the)3.673 F
/F3 10/Times-Roman@0 SF(POSTGRES)108 191.4 Q F1(inte)2.855 E .105
(ger di)-.165 F .105(vision routine,)-.275 F F2(int4div)2.855 E F1 2.855
(,t)C 2.855(oc)-2.855 G .105(ompute the di)-2.855 F .106
(vision of the sum by the)-.275 F(count.)108 204.6 Q F0
(CREATE AGGREGATE my_average \(sfunc1 = int4pl, --)148 229.8 Q(sum)12 E
(basetype = int4,)334 242 Q(stype1 = int4,)334 254.2 Q
(sfunc2 = int4inc, -- count)334 266.4 Q(stype2 = int4,)334 278.6 Q
(finalfunc = int4div, -- division)334 290.8 Q(initcond1 = '0',)334 303 Q
(initcond2 = '0'\))334 315.2 Q
(SELECT my_average\(salary\) as emp_average FROM EMP;)148 339.6 Q 224
370.1 148 370.1 DL(emp_average)153 379.8 Q 224 384.3 148 384.3 DL(1640)
153 394 Q 224 398.5 148 398.5 DL 224 370.1 224 398.5 DL 148 370.1 148
398.5 DL/F4 11/Times-Bold@0 SF(38)282.5 756 Q EP
%%Page: 39 39
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(11. INTERF)72 165.4 R -1.045(AC)-1.71
G(ING EXTENSIONS T)1.045 E 4.75(OI)-.342 G(NDICES)-4.75 E 77.5 178.6 72
178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86
178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5
178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6
119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6
135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5
178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174
178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL
190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6
DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5
178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6
229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6
245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5
178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284
178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL
300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6
DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5
178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6
339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6
355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5
178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394
178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL
410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6
DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5
178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6
449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6
465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5
178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504
178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF .125
(The procedures described thus f)108 208.9 R .125
(ar let you de\214ne a ne)-.11 F 2.875(wt)-.275 G .124(ype, ne)-2.875 F
2.874(wf)-.275 G .124(unctions and ne)-2.874 F 2.874(wo)-.275 G(per)
-2.874 E(-)-.22 E 3.069(ators. Ho)108 222.1 R(we)-.275 E -.165(ve)-.275
G 1.199 -.44(r, w).165 H 3.069(ec).44 G .32
(annot yet de\214ne a secondary inde)-3.069 F 3.07(x\()-.165 G .32
(such as a B-tree, R-tree or hash)-3.07 F(access method\) o)108 235.3 Q
-.165(ve)-.165 G 2.75(ran).165 G .55 -.275(ew t)-2.75 H
(ype or its operators.).275 E .181(Look back at Figure 3.)108 252.4 R
.181(The right half sho)5.681 F .18
(ws the catalogs that we must modify in order to)-.275 F(tell)108 265.6
Q/F2 10/Times-Roman@0 SF(POSTGRES)4.911 E F1(ho)4.911 E 4.911(wt)-.275 G
4.911(ou)-4.911 G 2.161(se a user)-4.911 F 2.161
(-de\214ned type and/or user)-.22 F 2.162(-de\214ned operators with an)
-.22 F(inde)108 278.8 Q 3.874(x\()-.165 G(i.e.,)-3.874 E/F3 11/Courier@0
SF(pg_am)3.874 E F1(,)A F3(pg_amop)3.874 E F1(,)A F3(pg_amproc)3.873 E
F1(and)3.873 E F3(pg_opclass)3.873 E F1 3.873(\). Unfortunately)B 3.873
(,t)-.715 G(here)-3.873 E 1.611(is no simple command to do this.)108 292
R 3.372 -.88(We w)7.111 H 1.612(ill demonstrate ho).88 F 4.362(wt)-.275
G 4.362(om)-4.362 G 1.612(odify these catalogs)-4.362 F .78
(through a running e)108 305.2 R .78(xample: a ne)-.165 F 3.53(wo)-.275
G .779(perator class for the B-tree access method that sorts)-3.53 F
(inte)108 318.4 Q(gers in ascending absolute v)-.165 E(alue order)-.275
E(.)-.605 E(The)108 335.5 Q F3(pg_am)3.956 E F1 1.206
(class contains one instance for e)3.956 F -.165(ve)-.275 G 1.206
(ry user).165 F 1.206(-de\214ned access method.)-.22 F(Support)6.706 E
1.667(for the heap access method is b)108 348.7 R 1.667(uilt into)-.22 F
F2(POSTGRES)4.417 E F1 4.417(,b)C 1.667(ut e)-4.637 F -.165(ve)-.275 G
1.667(ry other access method is).165 F(described here.)108 361.9 Q
(The schema is)5.5 E 496.228 379.65 115.771 379.65 DL F3(amname)121.271
390.1 Q F1(name of the access method)56.1 E 496.228 394.85 115.771
394.85 DL F3(amowner)121.271 405.3 Q F1(object id of the o)49.5 E(wner')
-.275 E 2.75(si)-.605 G(nstance in pg_user)-2.75 E 496.228 410.05
115.771 410.05 DL F3(amkind)121.271 420.5 Q F1(not used at present, b)
56.1 E(ut set to 'o' as a place holder)-.22 E 496.228 425.25 115.771
425.25 DL F3(amstrategies)121.271 435.7 Q F1(number of strate)16.5 E
(gies for this access method \(see belo)-.165 E(w\))-.275 E 496.228
440.45 115.771 440.45 DL F3(amsupport)121.271 450.9 Q F1
(number of support routines for this access method \(see belo)36.3 E
(w\))-.275 E 496.228 455.65 115.771 455.65 DL F3(amgettuple)121.271
466.1 Q(aminsert)121.271 479.3 Q(...)121.271 492.5 Q F1 4.257
(procedure identi\214ers for interf)216.971 466.1 R 4.257
(ace routines to the access)-.11 F 5.101(method. F)216.971 479.3 R 2.351
(or e)-.165 F(xample,)-.165 E F3(regproc)5.101 E F1 2.351
(ids for opening, closing,)5.101 F
(and getting instances from the access method appear here.)216.971 492.5
Q 496.228 497.25 115.771 497.25 DL 208.721 379.65 208.721 497.25 DL
496.228 379.65 496.228 497.25 DL 115.771 379.65 115.771 497.25 DL .68
(The object ID of the instance in)108 518.7 R F3(pg_am)3.431 E F1 .681
(is used as a foreign k)3.431 F 1.011 -.165(ey i)-.11 H 3.431(nl).165 G
.681(ots of other classes.)-3.431 F -1.21(Yo)108 531.9 S 2.912(ud)1.21 G
(on')-2.912 E 2.912(tn)-.198 G .162(eed to add a ne)-2.912 F 2.911(wi)
-.275 G .161(nstance to this class; all you')-2.911 F .161
(re interested in is the object ID)-.55 F
(of the access method instance you w)108 545.1 Q(ant to e)-.11 E(xtend:)
-.165 E/F4 10/Courier@0 SF(SELECT oid FROM pg_am WHERE amname = 'btree')
148 570.3 Q .4 LW 176 587.8 148 587.8 DL(oid)153 597.5 Q 176 602 148 602
DL(403)153 611.7 Q 176 616.2 148 616.2 DL 176 587.8 176 616.2 DL 148
587.8 148 616.2 DL F1(The)108 650.9 Q F3(amstrategies)3.445 E F1(attrib)
3.445 E .695(ute e)-.22 F .695
(xists to standardize comparisons across data types.)-.165 F -.165(Fo)
6.196 G(r).165 E -.165(ex)108 664.1 S 1.527
(ample, B-trees impose a strict ordering on k).165 F -.165(ey)-.11 G
1.527(s, lesser to greater).165 F 7.026(.S)-.605 G(ince)-7.026 E F2
(POSTGRES)4.276 E F1(allo)108 677.3 Q 1.144
(ws the user to de\214ne operators,)-.275 F F2(POSTGRES)3.894 E F1 1.145
(cannot look at the)3.894 F/F5 11/Times-Bold@0 SF(name)3.895 E F1 1.145
(of an operator)3.895 F(\(e)108 690.5 Q(g,)-.165 E F3(>)3.713 E F1(or)
3.713 E F3(<)3.713 E F1 3.712(\)a)C .962
(nd tell what kind of comparison it is.)-3.712 F .962(In f)6.462 F .962
(act, some access methods don')-.11 F(t)-.198 E 3.648(impose an)108
703.7 R 6.398(yo)-.165 G 3.648(rdering at all.)-6.398 F -.165(Fo)9.149 G
6.399(re).165 G 3.649(xample, R-trees e)-6.564 F 3.649
(xpress a rectangle-containment)-.165 F F5(39)282.5 756 Q EP
%%Page: 40 40
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF 1.021
(relationship, whereas a hashed data structure e)108 97.2 R 1.021
(xpresses only bitwise similarity based on)-.165 F .039(the v)108 110.4
R .039(alue of a hash function.)-.275 F/F1 10/Times-Roman@0 SF(POSTGRES)
5.539 E F0 .039(needs some consistent w)2.789 F .039
(ay of taking a quali\214ca-)-.11 F .049(tion in your query)108 123.6 R
2.799(,l)-.715 G .049
(ooking at the operator and then deciding if a usable inde)-2.799 F
2.798(xe)-.165 G 2.798(xists. This)-2.963 F .162(implies that)108 136.8
R F1(POSTGRES)2.912 E F0 .162(needs to kno)2.912 F 1.592 -.715(w, f)
-.275 H .162(or e).715 F .162(xample, that the)-.165 F/F2 11/Courier@0
SF(<=)2.913 E F0(and)2.913 E F2(>)2.913 E F0 .163(operators partition)
2.913 F 3.102(aB)108 150 S(-tree.)-3.102 E F1(POSTGRES)5.852 E F0 .352
(uses strate)3.102 F .352(gies to e)-.165 F .351
(xpress these relationships between operators and)-.165 F(the w)108
163.2 Q(ay the)-.11 E 2.75(yc)-.165 G(an be used to scan indices.)-2.75
E .687(De\214ning a ne)108 180.3 R 3.437(ws)-.275 G .687(et of strate)
-3.437 F .687(gies is be)-.165 F .687
(yond the scope of this discussion, b)-.165 F .688(ut we')-.22 F .688
(ll e)-.11 F(xplain)-.165 E(ho)108 193.5 Q 3.122(wB)-.275 G .372
(-tree strate)-3.122 F .372(gies w)-.165 F .372(ork because you')-.11 F
.372(ll need to kno)-.11 F 3.122(wt)-.275 G .372(hat to add a ne)-3.122
F 3.121(wo)-.275 G .371(perator class.)-3.121 F .099(In the)108 206.7 R
F2(pg_am)2.849 E F0 .099(class, the)2.849 F F2(amstrategies)2.849 E F0
(attrib)2.849 E .099(ute is the number of strate)-.22 F .099
(gies de\214ned for)-.165 F(this access method.)108 219.9 Q -.165(Fo)5.5
G 2.75(rB).165 G(-trees, this number is 5.)-2.75 E(These strate)5.5 E
(gies correspond to)-.165 E .44 LW 367.858 237.65 244.141 237.65 DL
(less than)249.641 248.1 Q(1)69.025 E 367.858 252.85 244.141 252.85 DL
(less than or equal)249.641 263.3 Q(2)30.536 E 367.858 268.05 244.141
268.05 DL 80.641(equal 3)249.641 278.5 R 367.858 283.25 244.141 283.25
DL(greater than or equal)249.641 293.7 Q(4)16.5 E 367.858 298.45 244.141
298.45 DL(greater than)249.641 308.9 Q(5)54.989 E 367.858 313.65 244.141
313.65 DL 367.858 237.65 367.858 313.65 DL 244.141 237.65 244.141 313.65
DL 348.608 237.65 348.608 313.65 DL .255(The idea is that you')108 335.1
R .254(ll need to add procedures corresponding to the comparisons abo)
-.11 F .584 -.165(ve t)-.165 H(o).165 E(the)108 348.3 Q F2(pg_amop)3.068
E F0 .318(relation \(see belo)3.068 F 3.068(w\). The)-.275 F .318
(access method code can use these strate)3.068 F .319(gy num-)-.165 F
.11(bers, re)108 361.5 R -.055(ga)-.165 G .11
(rdless of data type, to \214gure out ho).055 F 2.86(wt)-.275 G 2.86(op)
-2.86 G .11(artition the B-tree, compute selecti)-2.86 F(vity)-.275 E(,)
-.715 E .898(and so on.)108 374.7 R(Don')6.399 E 3.649(tw)-.198 G .899
(orry about the details of adding procedures yet; just understand that)
-3.759 F .48(there must be a set of these procedures for)108 387.9 R F2
(int2)3.23 E F0(,)A F2(int4)3.23 E F0(,)A F2(oid)3.23 E F0 3.23(,a)C .48
(nd e)-3.23 F -.165(ve)-.275 G .479(ry other data type).165 F
(on which a B-tree can operate.)108 401.1 Q .803(Sometimes, strate)108
418.2 R .803(gies aren')-.165 F 3.554(te)-.198 G .804
(nough information for the system to \214gure out ho)-3.554 F 3.554(wt)
-.275 G 3.554(ou)-3.554 G(se)-3.554 E 1.848(an inde)108 431.4 R 4.598
(x. Some)-.165 F 1.848
(access methods require other support routines in order to w)4.598 F
4.598(ork. F)-.11 F(or)-.165 E -.165(ex)108 444.6 S 1.976
(ample, the B-tree access method must be able to compare tw).165 F 4.726
(ok)-.11 G -.165(ey)-4.836 G 4.726(sa).165 G 1.976(nd determine)-4.726 F
.745(whether one is greater than, equal to, or less than the other)108
457.8 R 6.245(.S)-.605 G(imilarly)-6.245 E 3.495(,t)-.715 G .745
(he R-tree access)-3.495 F 1.685(method must be able to compute interse\
ctions, unions, and sizes of rectangles.)108 471 R(These)7.185 E .884(o\
perations do not correspond to user quali\214cations in SQL queries; th\
e)108 484.2 R 3.633(ya)-.165 G .883(re administra-)-3.633 F(ti)108 497.4
Q .33 -.165(ve r)-.275 H(outines used by the access methods, internally)
.165 E(.)-.715 E 1.971(In order to manage di)108 514.5 R -.165(ve)-.275
G 1.972(rse support routines consistently across all).165 F F1(POSTGRES)
4.722 E F0(access)4.722 E(methods,)108 527.7 Q F2(pg_am)4.65 E F0 1.9
(includes an attrib)4.65 F 1.9(ute called)-.22 F F2(amsupport)4.65 E F0
7.4(.T)C 1.899(his attrib)-7.4 F 1.899(ute records the)-.22 F .136
(number of support routines used by an access method.)108 540.9 R -.165
(Fo)5.636 G 2.887(rB).165 G .137(-trees, this number is one \212)-2.887
F .173(the routine to tak)108 554.1 R 2.923(et)-.11 G .393 -.11(wo ke)
-2.923 H .173(ys and return)-.055 F/F3 11/Symbol SF(-)2.923 E F0 .173
(1, 0, or).916 F F3(+)2.923 E F0 .172
(1, depending on whether the \214rst k).916 F .502 -.165(ey i)-.11 H(s)
.165 E(less than, equal to, or greater than the second.)108 569.5 Q/F4 8
/Times-Roman@0 SF(8)-4.4 I F0(The)108 586.6 Q F2(amstrategies)4.312 E F0
1.562(entry in)4.312 F F2(pg_am)4.312 E F0 1.562(is just the)4.312 F/F5
11/Times-Italic@0 SF(number)4.312 E F0 1.562(of strate)4.312 F 1.562
(gies de\214ned for the)-.165 F 1.852(access method in question.)108
599.8 R 1.852(The procedures for less than, less equal, and so on don')
7.352 F(t)-.198 E 3.555(appear in)108 613 R F2(pg_am)6.305 E F0 9.055
(.S)C(imilarly)-9.055 E(,)-.715 E F2(amsupport)6.305 E F0 3.555
(is just the number of support routines)6.305 F
(required by the access method.)108 626.2 Q
(The actual routines are listed else)5.5 E(where.)-.275 E .974(The ne)
108 643.3 R .974(xt class of interest is)-.165 F F2(pg_opclass.)3.724 E
F0 .973(This class e)6.474 F .973(xists only to associate a name)-.165 F
1.914(with an)108 656.5 R F2(oid)4.664 E F0 7.414(.I)C(n)-7.414 E F2
(pg_amop)4.665 E F0 4.665(,e)C -.165(ve)-4.94 G 1.915
(ry B-tree operator class has a set of procedures, one).165 F 4.98
(through \214v)108 669.7 R 4.98(e, abo)-.165 F -.165(ve)-.165 G 10.48
(.S).165 G 4.979(ome e)-10.48 F 4.979(xisting opclasses are)-.165 F F2
(int2_ops)7.729 E F0(,)A F2(int4_ops)7.729 E F0 7.729(,a)C(nd)-7.729 E
.32 LW 76 679.3 72 679.3 DL 80 679.3 76 679.3 DL 84 679.3 80 679.3 DL 88
679.3 84 679.3 DL 92 679.3 88 679.3 DL 96 679.3 92 679.3 DL 100 679.3 96
679.3 DL 104 679.3 100 679.3 DL 108 679.3 104 679.3 DL 112 679.3 108
679.3 DL 116 679.3 112 679.3 DL 120 679.3 116 679.3 DL 124 679.3 120
679.3 DL 128 679.3 124 679.3 DL 132 679.3 128 679.3 DL 136 679.3 132
679.3 DL 140 679.3 136 679.3 DL 144 679.3 140 679.3 DL 148 679.3 144
679.3 DL 152 679.3 148 679.3 DL 156 679.3 152 679.3 DL 160 679.3 156
679.3 DL 164 679.3 160 679.3 DL 168 679.3 164 679.3 DL 172 679.3 168
679.3 DL 176 679.3 172 679.3 DL 180 679.3 176 679.3 DL 184 679.3 180
679.3 DL 188 679.3 184 679.3 DL 192 679.3 188 679.3 DL 196 679.3 192
679.3 DL 200 679.3 196 679.3 DL 204 679.3 200 679.3 DL 208 679.3 204
679.3 DL 212 679.3 208 679.3 DL 216 679.3 212 679.3 DL/F6 5
/Times-Roman@0 SF(8)93.6 689.7 Q F4
(Strictly speaking, this routine can return a ne)2 3.2 M -.04(ga)-.12 G
(ti).04 E .24 -.12(ve n)-.2 H(umber \(< 0\), 0, or a non-zero positi).12
E .24 -.12(ve n)-.2 H(umber \(> 0\).).12 E/F7 11/Times-Bold@0 SF(40)
282.5 756 Q EP
%%Page: 41 41
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Courier@0 SF(oid_ops)108 97.2 Q/F1 11/Times-Roman@0 SF 7.077(.Y)C
1.577(ou need to add an instance with your opclass name \(for e)-8.287 F
(xample,)-.165 E F0(com-)4.328 E(plex_abs_ops)108 110.4 Q F1 3.409(\)t)C
(o)-3.409 E F0(pg_opclass)3.409 E F1 6.159(.T)C(he)-6.159 E F0(oid)3.409
E F1 .658(of this instance is a foreign k)3.408 F .988 -.165(ey i)-.11 H
3.408(no).165 G(ther)-3.408 E(classes.)108 123.6 Q/F2 10/Courier@0 SF
(INSERT INTO pg_opclass \(opcname\) VALUES \('complex_abs_ops'\);)148
148.8 Q(SELECT oid, opcname)148 173.2 Q(FROM pg_opclass)160 185.4 Q
(WHERE opcname = 'complex_abs_ops';)160 197.6 Q .4 LW 275 215.1 148
215.1 DL 21(oid opcname)153 224.8 R 275 229.3 148 229.3 DL 9
(17314 int4_abs_ops)153 239 R 275 243.5 148 243.5 DL 275 215.1 275 243.5
DL 148 215.1 148 243.5 DL 190.5 215.1 190.5 243.5 DL F1 .186
(Note that the)108 278.2 R F0(oid)2.936 E F1 .186(for your)2.936 F F0
(pg_opclass)2.936 E F1(instance)2.936 E/F3 11/Times-Bold@0 SF .186
(will be differ)2.936 F(ent)-.198 E F1 5.686(!Y)C .187
(ou should substi-)-6.896 F(tute your v)108 291.4 Q
(alue for 17314 where)-.275 E -.165(ve)-.275 G 2.75(ri).165 G 2.75(ta)
-2.75 G(ppears in this discussion.)-2.75 E .151(So no)108 308.5 R 2.901
(ww)-.275 G 2.9(eh)-2.901 G -2.475 -.22(av e)-2.9 H .15
(an access method and an operator class.)3.12 F 1.91 -.88(We s)5.65 H
.15(till need a set of operators;).88 F .651
(the procedure for de\214ning operators w)108 321.7 R .652
(as discussed earlier in this manual.)-.11 F -.165(Fo)6.152 G 3.402(rt)
.165 G(he)-3.402 E F0(com-)3.402 E(plex_abs_ops)108 334.9 Q F1
(operator class on B-trees, the operators we require are:)2.75 E
(absolute v)148 361.1 Q(alue less-than)-.275 E(absolute v)148 374.3 Q
(alue less-than-or)-.275 E(-equal)-.22 E(absolute v)148 387.5 Q
(alue equal)-.275 E(absolute v)148 400.7 Q(alue greater)-.275 E
(-than-or)-.22 E(-equal)-.22 E(absolute v)148 413.9 Q(alue greater)-.275
E(-than)-.22 E(Suppose the code that implements the functions de\214ned\
is stored in the \214le)108 440.1 Q F2
(/usr/local/postgres95/src/tutorial/complex.c)148 465.3 Q F1 -.165(Pa)
108 491.5 S .592(rt of the code look lik).165 F 3.342(et)-.11 G .592
(his: \(note that we will only sho)-3.342 F 3.342(wt)-.275 G .592
(he equality operator for the)-3.342 F .631(rest of the e)108 504.7 R
.632(xamples. The other four operators are v)-.165 F .632(ery similar)
-.165 F 3.382(.R)-.605 G .632(efer to)-3.382 F F0(complex.c)3.382 E F1
(or)3.382 E F0(complex.sql)108 517.9 Q F1(for the details.\))2.75 E F2
(#define Mag\(c\))148 543.1 Q(\(\(c\)->x*\(c\)->x + \(c\)->y*\(c\)->y\))
24 E(bool)148 567.5 Q(complex_abs_eq\(Complex *a, Complex *b\))148 579.7
Q({)148 591.9 Q(double amag = Mag\(a\), bmag = Mag\(b\);)172 604.1 Q
(return \(amag==bmag\);)172 616.3 Q(})148 628.5 Q F1
(There are a couple of important things that are happening belo)108
654.7 Q -.715(w.)-.275 G 1.966
(First, note that operators for less-than, less-than-or)108 671.8 R
1.966(-equal, equal, greater)-.22 F(-than-or)-.22 E(-equal,)-.22 E .885
(and greater)108 685 R .886(-than for)-.22 F F0(int4)3.636 E F1 .886
(are being de\214ned.)3.636 F .886
(All of these operators are already de\214ned)6.386 F(for)108 698.2 Q F0
(int4)2.962 E F1 .212(under the names)2.962 F F0(<)2.962 E F1(,)A F0(<=)
2.962 E F1(,)A F0(=)2.962 E F1(,)A F0(>=)2.962 E F1 2.962(,a)C(nd)-2.962
E F0(>)2.962 E F1 5.712(.T)C .212(he ne)-5.712 F 2.961(wo)-.275 G .211
(perators beha)-2.961 F .541 -.165(ve d)-.22 H(if).165 E(ferently)-.275
E 2.961(,o)-.715 G(f)-2.961 E 2.783(course. In)108 711.4 R .033
(order to guarantee that)2.783 F/F4 10/Times-Roman@0 SF(POSTGRES)2.783 E
F1 .034(uses these ne)2.783 F 2.784(wo)-.275 G .034
(perators rather than the old)-2.784 F F3(41)282.5 756 Q EP
%%Page: 42 42
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF .765(ones, the)108 97.2 R 3.515(yn)-.165 G .764
(eed to be named dif)-3.515 F .764(ferently from the old ones.)-.275 F
.764(This is a k)6.264 F 1.094 -.165(ey p)-.11 H .764(oint: you can).165
F -.165(ove)108 110.4 S 1.48(rload operators in).165 F/F1 10
/Times-Roman@0 SF(POSTGRES)4.23 E F0 4.23(,b)C 1.48
(ut only if the operator isn')-4.45 F 4.231(ta)-.198 G 1.481
(lready de\214ned for the)-4.231 F(ar)108 123.6 Q 1.474(gument types.)
-.198 F 1.474(That is, if you ha)6.974 F -.165(ve)-.22 G/F2 11/Courier@0
SF(<)4.388 E F0 1.473(de\214ned for \()4.223 F F2(int4)A F0(,)A F2(int4)
4.223 E F0 1.473(\), you can')B 4.223(td)-.198 G 1.473(e\214ne it)-4.223
F(ag)108 136.8 Q(ain.)-.055 E F1(POSTGRES)5.893 E/F3 11/Times-Bold@0 SF
.393(does not check)3.143 F F0 .393
(this when you de\214ne your operator)3.143 F 3.144(,s)-.44 G 3.144(ob)
-3.144 G 3.144(ec)-3.144 G 3.144(areful. T)-3.144 F(o)-.88 E -.22(avo)
108 150 S .642
(id this problem, odd names will be used for the operators.).22 F .641
(If you get this wrong, the)6.141 F(access methods are lik)108 163.2 Q
(ely to crash when you try to do scans.)-.11 E 1.223
(The other important point is that all the operator functions return)108
180.3 R/F4 11/Times-Italic@0 SF(Boolean)3.974 E F0 -.275(va)3.974 G
3.974(lues. The).275 F .733(access methods rely on this f)108 193.5 R
3.483(act. \(On)-.11 F .733
(the other hand, the support function returns what-)3.483 F -2.365 -.275
(ev e)108 206.7 T 2.75(rt).275 G(he particular access method e)-2.75 E
(xpects \212 in this case, a signed inte)-.165 E(ger)-.165 E(.\))-.605 E
1.443(The \214nal routine in the \214le is the \231support routine\232 \
mentioned when we discussed the)108 223.8 R F2(amsupport)108 237 Q F0
(attrib)2.75 E(ute of the)-.22 E F2(pg_am)2.75 E F0 2.75(class. W)2.75 F
2.75(ew)-.88 G(ill use this later on.)-2.75 E -.165(Fo)5.5 G 2.75(rn)
.165 G -.275(ow)-2.75 G 2.75(,i)-.44 G(gnore it.)-2.75 E/F5 10/Courier@0
SF(CREATE FUNCTION complex_abs_eq\(complex, complex\))148 262.2 Q
(RETURNS bool)178 274.4 Q
(AS '/usr/local/postgres95/tutorial/obj/complex.so')178 286.6 Q
(LANGUAGE 'c';)178 298.8 Q F0(No)108 337.2 Q 3.975(wd)-.275 G 1.224
(e\214ne the operators that use them.)-3.975 F 1.224
(As noted, the operator names must be unique)6.724 F .684
(among all operators that tak)108 350.4 R 3.434(et)-.11 G -.11(wo)-3.434
G F2(int4)3.544 E F0 3.434(operands. In)3.434 F .684
(order to see if the operator names)3.434 F(listed belo)108 363.6 Q 2.75
(wa)-.275 G(re tak)-2.75 E(en, we can do a query on)-.11 E F2
(pg_operator)2.75 E F0(:)A F5(/*)148 388.8 Q 6(*t)154 401 S
(his query uses the regular expression operator \(~\))-6 E 6(*t)154
413.2 S 6(of)-6 G(ind three-character operator names that end in)-6 E 6
(*t)154 425.4 S(he character &)-6 E(*/)154 437.6 Q(SELECT *)148 449.8 Q
(FROM pg_operator)148 462 Q(WHERE oprname ~ '^..&$'::text;)148 474.2 Q
F0 1.15(to see if your name is tak)108 500.4 R 1.149
(en for the types you w)-.11 F 3.899(ant. The)-.11 F 1.149
(important things here are the)3.899 F .359
(procedure \(which are the C functions de\214ned abo)108 513.6 R -.165
(ve)-.165 G 3.109(\)a).165 G .359(nd the restriction and join selecti)
-3.109 F(v-)-.275 E .13(ity functions.)108 526.8 R -1.21(Yo)5.63 G 2.88
(us)1.21 G .13(hould just use the ones used belo)-2.88 F .129
(w\212note that there are dif)-.275 F .129(ferent such)-.275 F .54
(functions for the less-than, equal, and greater)108 540 R .541
(-than cases.)-.22 F(These)6.041 E F4(must)3.291 E F0 .541
(be supplied, or the)3.291 F .048
(access method will crash when it tries to use the operator)108 553.2 R
5.548(.Y)-.605 G .048(ou should cop)-6.758 F 2.798(yt)-.11 G .048
(he names for)-2.798 F F2(restrict)108 566.4 Q F0(and)2.75 E F2(join)
2.75 E F0 2.75(,b)C
(ut use the procedure names you de\214ned in the last step.)-2.97 E F5
(CREATE OPERATOR = \()148 591.6 Q
(leftarg = complex, rightarg = complex, procedure = complex_abs_eq,)166
603.8 Q(restrict = eqsel, join = eqjoinsel)166 616 Q(\))148 628.2 Q F0
1.687(Notice that \214v)108 654.4 R 4.437(eo)-.165 G 1.688
(perators corresponding to less, less equal, equal, greater)-4.437 F
4.438(,a)-.44 G 1.688(nd greater)-4.438 F(equal are de\214ned.)108 667.6
Q -.88(We)108 684.7 S -.55('r).88 G 2.896(ej).55 G .145
(ust about \214nished. the last thing we need to do is to update the)
-2.896 F F2(pg_amop)2.895 E F0(relation.)2.895 E 1.76 -.88(To d)108
697.9 T 2.75(ot).88 G(his, we need the follo)-2.75 E(wing attrib)-.275 E
(utes:)-.22 E F3(42)282.5 756 Q EP
%%Page: 43 43
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 428.05 88.75 183.95 88.75 DL/F0 11/Courier@0 SF(amopid)189.45
99.2 Q/F1 11/Times-Roman@0 SF(the)278.55 99.2 Q F0(oid)3.821 E F1 1.071
(of the)3.821 F F0(pg_am)3.821 E F1(instance)3.822 E
(for B-tree \(== 403, see abo)278.55 112.4 Q -.165(ve)-.165 G(\)).165 E
428.05 117.15 183.95 117.15 DL F0(amopclaid)189.45 127.6 Q F1(the)278.55
127.6 Q F0(oid)5.539 E F1 2.788(of the)5.538 F F0(pg_opclass)5.538 E F1
5.213(instance for)278.55 140.8 R F0(int4_abs_ops)7.964 E F1 .684
(\(== whate)278.55 154 R -.165(ve)-.275 G 3.434(ry).165 G .684
(ou got instead of)-3.434 F(17314, see abo)278.55 167.2 Q -.165(ve)-.165
G(\)).165 E 428.05 171.95 183.95 171.95 DL F0(amopopr)189.45 182.4 Q F1
(the)278.55 182.4 Q F0(oid)2.779 E F1 2.779(so)C 2.779(ft)-2.779 G .029
(he operators for the)-2.779 F 1.386(opclass \(which we')278.55 195.6 R
1.386(ll get in just)-.11 F 2.75(am)278.55 208.8 S(inute\))-2.75 E
428.05 213.55 183.95 213.55 DL(cost functions.)278.55 224 Q F0
(amopselect,)189.45 224 Q(amopnpages)189.45 237.2 Q 428.05 241.95 183.95
241.95 DL 428.05 88.75 428.05 241.95 DL 183.95 88.75 183.95 241.95 DL
270.3 88.75 270.3 241.95 DL F1 .012(The cost functions are used by the \
query optimizer to decide whether or not to use a gi)108 263.4 R -.165
(ve)-.275 G(n).165 E(inde)108 276.6 Q 5.733(xi)-.165 G 5.733(nas)-5.733
G 5.733(can. F)-5.733 F(ortunately)-.165 E 5.733(,t)-.715 G 2.983
(hese already e)-5.733 F 5.733(xist. The)-.165 F(tw)5.733 E 5.732(of)
-.11 G 2.982(unctions we')-5.732 F 2.982(ll use are)-.11 F F0(btreesel,)
108 289.8 Q F1 1.467(which estimates the selecti)4.217 F 1.467
(vity of the B-tree, and)-.275 F F0(btreenpage,)4.218 E F1(which)4.218 E
(estimates the number of pages a search will touch in the tree.)108 303
Q .215(So we need the)108 320.1 R F0(oid)2.965 E F1 2.965(so)C 2.965(ft)
-2.965 G .215(he operators we just de\214ned.)-2.965 F -.88(We)5.714 G
-.11('l).88 G 2.964(ll).11 G .214(ook up the names of all the)-2.964 F
(operators that tak)108 333.3 Q 2.75(et)-.11 G -.11(wo)-2.75 G F0(int4)
2.86 E F1(s, and pick ours out:)A/F2 10/Courier@0 SF
(SELECT o.oid AS opoid, o.oprname)148 358.5 Q
(INTO TABLE complex_ops_tmp)148 370.7 Q(FROM pg_operator o, pg_type t)
148 382.9 Q(WHERE o.oprleft = t.oid and o.oprright = t.oid)148 395.1 Q
(and t.typname = 'complex';)178 407.3 Q F1(which returns:)108 432.5 Q .4
LW 245 450 148 450 DL F2 21(oid oprname)153 459.7 R 245 464.2 148 464.2
DL 9(17321 <)153 473.9 R 245 478.4 148 478.4 DL 9(17322 <=)153 488.1 R
245 492.6 148 492.6 DL 15(17323 =)153 502.3 R 245 506.8 148 506.8 DL 9
(17324 >=)153 516.5 R 245 521 148 521 DL 9(17325 >)153 530.7 R 245 535.2
148 535.2 DL 245 450 245 535.2 DL 148 450 148 535.2 DL 190.5 450 190.5
535.2 DL F1(\(Ag)108 556.9 Q .294(ain, some of your)-.055 F F0(oid)3.044
E F1 .295(numbers will almost certainly be dif)3.044 F 3.045
(ferent.\) The)-.275 F .295(operators we)3.045 F 1.839
(are interested in are those with)108 570.1 R F0(oid)4.589 E F1 4.589
(s1)C 1.839(7321 through 17325.)-4.589 F 1.838(The v)7.338 F 1.838
(alues you get will)-.275 F .504(probably be dif)108 583.3 R .504
(ferent, and you should substitute them for the v)-.275 F .505
(alues belo)-.275 F 4.685 -.715(w. W)-.275 H 3.255(ec)-.165 G .505
(an look)-3.255 F
(at the operator names and pick out the ones we just added.)108 596.5 Q
(No)108 613.6 Q 3.447(ww)-.275 G(e')-3.447 E .697(re ready to update)
-.55 F F0(pg_amop)3.447 E F1 .696(with our ne)3.446 F 3.446(wo)-.275 G
.696(perator class.)-3.446 F .696(The most important)6.196 F 1.116(thin\
g in this entire discussion is that the operators are ordered, from les\
s equal through)108 626.8 R(greater equal, in)108 640 Q F0(pg_amop)2.75
E F1 5.5(.W)C 2.75(ea)-6.38 G(dd the instances we need:)-2.75 E F2
(INSERT INTO pg_amop \(amopid, amopclaid, amopopr, amopstrategy,)154
665.2 Q(amopselect, amopnpages\))274 677.4 Q
(SELECT am.oid, opcl.oid, c.opoid, 3,)178 689.6 Q
('btreesel'::regproc, 'btreenpage'::regproc)195 701.8 Q/F3 11
/Times-Bold@0 SF(43)282.5 756 Q EP
%%Page: 44 44
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(FROM pg_am am, pg_opclass opcl, complex_ops_tmp c)
178 96.2 Q(WHERE amname = 'btree' and opcname = 'complex_abs_ops')178
108.4 Q(and c.oprname = '=';)196 120.6 Q/F1 11/Times-Roman@0 SF 1.007(N\
ote the order: \231less than\232 is 1, \231less than or equal\232 is 2,\
\231equal\232 is 3, \231greater than or)108 159 R
(equal\232 is 4, and \231greater than\232 is 5.)108 172.2 Q .437
(The last step \(\214nally!\) is re)108 189.3 R .438
(gistration of the \231support routine\232 pre)-.165 F .438
(viously described in our)-.275 F 1.924(discussion of)108 202.5 R/F2 11
/Courier@0 SF(pg_am)4.674 E F1 7.424(.T)C(he)-7.424 E F2(oid)4.674 E F1
1.923(of this support routine is stored in the)4.673 F F2(pg_amproc)
4.673 E F1 .078(class, k)108 215.7 R -.165(ey)-.11 G .078
(ed by the access method).165 F F2(oid)2.828 E F1 .078
(and the operator class)2.828 F F2(oid)2.829 E F1 5.579(.F)C .079
(irst, we need to re)-5.579 F(g-)-.165 E .804(ister the function in)108
228.9 R/F3 10/Times-Roman@0 SF(POSTGRES)3.554 E F1 .803
(\(recall that we put the C code that implements this rou-)3.554 F(tine\
in the bottom of the \214le in which we implemented the operator routi\
nes\):)108 242.1 Q F0(CREATE FUNCTION int4_abs_cmp\(int4, int4\))148
267.3 Q(RETURNS int4)184 279.5 Q
(AS '/usr/local/postgres95/tutorial/obj/complex.so')184 291.7 Q
(LANGUAGE 'c';)184 303.9 Q
(SELECT oid, proname FROM pg_proc WHERE prname = 'int4_abs_cmp';)148
340.5 Q .4 LW 275 358 148 358 DL 21(oid proname)153 367.7 R 275 372.2
148 372.2 DL 9(17328 int4_abs_cmp)153 381.9 R 275 386.4 148 386.4 DL 275
358 275 386.4 DL 148 358 148 386.4 DL 190.5 358 190.5 386.4 DL F1(\(Ag)
108 421.1 Q .642(ain, your)-.055 F F2(oid)3.392 E F1 .642
(number will probably be dif)3.392 F .642
(ferent and you should substitute the v)-.275 F(alue)-.275 E .526
(you see for the v)108 434.3 R .526(alue belo)-.275 F -.715(w.)-.275 G
6.026(\)R).715 G .526(ecalling that the B-tree instance')-6.026 F(s)
-.605 E F2(oid)3.276 E F1 .526(is 403 and that of)3.276 F F2
(int4_abs_ops)108 447.5 Q F1(is 17314, we can add the ne)2.75 E 2.75(wi)
-.275 G(nstance as follo)-2.75 E(ws:)-.275 E F0
(INSERT INTO pg_amproc \(amid, amopclaid, amproc, amprocnum\))148 472.7
Q(VALUES \('403'::oid,)178 484.9 Q(-- btree oid)48 E 30
('17314'::oid, --)226 497.1 R(pg_opclass tuple)12 E 30('17328'::oid, --)
226 509.3 R(new pg_proc oid)6 E('1'::int2\);)226 521.5 Q/F4 11
/Times-Bold@0 SF(44)282.5 756 Q EP
%%Page: 45 45
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(12. LIBPQ)72 165.4 R 77.5 178.6 72
178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86
178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5
178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6
119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6
135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5
178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174
178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL
190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6
DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5
178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6
229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6
245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5
178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284
178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL
300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6
DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5
178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6
339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6
355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5
178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394
178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL
410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6
DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5
178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6
449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6
465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5
178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504
178.6 498.5 178.6 DL/F1 10/Times-Roman@0 SF(LIBPQ)108 208.9 Q/F2 11
/Times-Roman@0 SF .581(is the application programming interf)3.331 F
.581(ace to)-.11 F F1(POSTGRES)3.331 E F2(.)A F1(LIBPQ)6.081 E F2 .582
(is a set of library)3.331 F .976(routines which allo)108 222.1 R .976
(ws client programs to pass queries to the)-.275 F F1(POSTGRES)3.726 E
F2(back)3.726 E .975(end serv)-.11 F(er)-.165 E(and to recei)108 235.3 Q
.33 -.165(ve t)-.275 H(he results of these queries.).165 E 1.922(This v)
108 252.4 R 1.922(ersion of the documentation describes the C interf)
-.165 F 1.922(ace library)-.11 F 7.423(.T)-.715 G 1.923(hree short pro-)
-7.423 F 1.642(grams are included at the end of this section to sho)108
265.6 R 4.392(wh)-.275 G 2.192 -.275(ow t)-4.392 H 4.391(ow).275 G 1.641
(rite programs that use)-4.391 F F1(LIBPQ)108 278.8 Q F2(.)A
(There are se)108 295.9 Q -.165(ve)-.275 G(ral e).165 E(xamples of)-.165
E F1(LIBPQ)2.75 E F2(applications in the follo)2.75 E(wing directories:)
-.275 E/F3 10/Courier@0 SF(../src/test/regress)148 321.1 Q
(../src/test/examples)148 333.3 Q(../src/bin/psql)148 345.5 Q F2 1.96
(Frontend programs which use)108 375.6 R F1(LIBPQ)4.71 E F2 1.961
(must include the header \214le)4.711 F/F4 11/Courier@0 SF(libpq-fe.h)
4.711 E F2(and)4.711 E(must link with the)108 388.8 Q F4(libpq)2.75 E F2
(library)2.75 E(.)-.715 E/F5 12/Times-Bold@0 SF 3(12.1. Contr)72 428.2 R
(ol and Initialization)-.216 E F2 .497(The follo)108 445.3 R .497
(wing en)-.275 F .497(vironment v)-.44 F .497
(ariables can be used to set up def)-.275 F .496(ault en)-.11 F .496
(vironment v)-.44 F .496(alues to)-.275 F -.22(avo)108 458.5 S
(id hard-coding database names into an application program:).22 E<83>
113.5 475.6 Q/F6 11/Times-Bold@0 SF(PGHOST)5.5 E F2(sets the def)2.75 E
(ault serv)-.11 E(er name.)-.165 E<83>113.5 488.8 Q F6(PGOPTIONS)5.5 E
F2(sets additional runtime options for the)2.75 E F1(POSTGRES)2.75 E F2
(back)2.75 E(end.)-.11 E<83>113.5 502 Q F6(PGPOR)5.5 E(T)-.44 E F2
(sets the def)2.75 E(ault port for communicating with the)-.11 E F1
(POSTGRES)2.75 E F2(back)2.75 E(end.)-.11 E<83>113.5 515.2 Q F6(PGTTY)
5.5 E F2 .201(sets the \214le or tty on which deb)2.951 F .201
(ugging messages from the back)-.22 F .202(end serv)-.11 F .202(er are)
-.165 F(displayed.)122.85 528.4 Q<83>113.5 541.6 Q F6(PGD)5.5 E -1.65
-1.045(AT A)-.385 H -.33(BA)1.045 G(SE).33 E F2(sets the def)2.75 E
(ault)-.11 E F1(POSTGRES)2.75 E F2(database name.)2.75 E<83>113.5 554.8
Q F6(PGREALM)5.5 E F2 .232(sets the)2.982 F/F7 11/Times-Italic@0 SF
-.385(Ke)2.982 G(rber).385 E(os)-.495 E F2 .232(realm to use with)2.982
F F1(POSTGRES)2.981 E F2 2.981(,i)C 2.981(fi)-2.981 G 2.981(ti)-2.981 G
2.981(sd)-2.981 G(if)-2.981 E .231(ferent from the)-.275 F 1.027
(local realm.)122.85 568 R(If)6.527 E F4(PGREALM)3.777 E F2 1.027
(is set,)3.777 F F1(POSTGRES)3.777 E F2 1.027
(applications will attempt authentication)3.777 F 1.308(with serv)122.85
581.2 R 1.308(ers for this realm and use separate tick)-.165 F 1.307
(et \214les to a)-.11 F -.22(vo)-.22 G 1.307(id con\215icts with local)
.22 F(tick)122.85 594.4 Q 2.668(et \214les.)-.11 F 2.668(This en)8.168 F
2.668(vironment v)-.44 F 2.668(ariable is only used if)-.275 F F7 -.385
(Ke)5.418 G(rber).385 E(os)-.495 E F2 2.668(authentication is)5.418 F
(enabled.)122.85 607.6 Q F5 3(12.2. Database)72 633.8 R
(Connection Functions)3 E F2(The follo)108 650.9 Q
(wing routines deal with making a connection to a back)-.275 E
(end from a C program.)-.11 E F6(PQsetdb)108 668 Q F2(Mak)133 685.1 Q
(es a ne)-.11 E 2.75(wc)-.275 G(onnection to a back)-2.75 E(end.)-.11 E
F3(PGconn *PQsetdb\(char *pghost,)173 710.3 Q(char *pgport,)269 722.5 Q
F6(45)282.5 756 Q EP
%%Page: 46 46
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(char *pgoptions,)269 96.2 Q(char *pgtty,)269 108.4 Q
(char *dbName\);)269 120.6 Q/F1 11/Times-Roman@0 SF .482(If an)133 146.8
R 3.232(ya)-.165 G -.198(rg)-3.232 G .481
(ument is NULL, then the corresponding en).198 F .481(vironment v)-.44 F
.481(ariable is check)-.275 F(ed.)-.11 E(If the en)133 160 Q
(vironment v)-.44 E(ariable is also not set, then hardwired def)-.275 E
(aults are used.)-.11 E/F2 11/Times-Italic@0 SF(PQsetdb)133 177.1 Q F1
(al)4.191 E -.11(wa)-.11 G 1.441(ys returns a v).11 F 1.441
(alid PGconn pointer)-.275 F 6.941(.T)-.605 G(he)-6.941 E F2(PQstatus)
4.191 E F1 1.442(\(see belo)4.192 F 1.442(w\) com-)-.275 F 2.872
(mand should be called to ensure that a connection w)133 190.3 R 2.872
(as properly made before)-.11 F .2(queries are sent via the connection.)
133 203.5 R/F3 10/Times-Roman@0 SF(LIBPQ)5.701 E F1 .201
(programmers should be careful to main-)2.951 F .054
(tain the PGconn abstraction.)133 216.7 R .054
(Use the accessor functions belo)5.554 F 2.803(wt)-.275 G 2.803(og)
-2.803 G .053(et at the contents)-2.803 F 1.332(of PGconn.)133 229.9 R
-1.342 -.814(Av o)6.832 H 1.332
(id directly referencing the \214elds of the PGconn structure as the)
.814 F(y)-.165 E(are subject to change in the future.)133 243.1 Q/F4 11
/Times-Bold@0 SF(PQdb)133 260.2 Q F1
(returns the database name of the connection.)2.75 E F0
(char *PQdb\(PGconn *conn\))173 285.4 Q F4(PQhost)133 311.6 Q F1
(returns the host name of the connection.)2.75 E F0
(char *PQhost\(PGconn *conn\))173 336.8 Q F4(PQoptions)133 363 Q F1
(returns the pgoptions used in the connection.)2.75 E F0
(char *PQoptions\(PGconn *conn\))173 388.2 Q F4(PQport)133 414.4 Q F1
(returns the pgport of the connection.)2.75 E F0
(char *PQport\(PGconn *conn\))173 439.6 Q F4(PQtty)133 465.8 Q F1
(returns the pgtty of the connection.)2.75 E F0
(char *PQtty\(PGconn *conn\))173 491 Q F4(PQstatus)133 517.2 Q F1 3.175
(Returns the status of the connection. The status can be CONNEC-)5.926 F
(TION_OK or CONNECTION_B)133 530.4 Q(AD.)-.385 E F0
(ConnStatusType *PQstatus\(PGconn *conn\))173 555.6 Q F4(PQerr)133 581.8
Q(orMessage)-.198 E F1
(returns the error message associated with the connection)2.75 E F0
(char *PQerrorMessage\(PGconn* conn\);)173 607 Q F4(PQ\214nish)108 637.1
Q F1 .041(Close the connection to the back)133 654.2 R 2.791(end. Also)
-.11 F .041(frees memory used by the PGconn struc-)2.791 F 2.75
(ture. The)133 667.4 R
(PGconn pointer should not be used after PQ\214nish has been called.)
2.75 E F0(void PQfinish\(PGconn *conn\))173 692.6 Q F4(46)282.5 756 Q EP
%%Page: 47 47
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Bold@0 SF(PQr)108 97.2 Q(eset)-.198 E/F1 11/Times-Roman@0
SF 1.035(Reset the communication port with the back)133 114.3 R 3.784
(end. This)-.11 F 1.034(function will close the IPC)3.784 F(sock)133
127.5 Q .211(et connection to the back)-.11 F .212
(end and attempt to reestablish a ne)-.11 F 2.962(wc)-.275 G .212
(onnection to the)-2.962 F(same back)133 140.7 Q(end.)-.11 E/F2 10
/Courier@0 SF(void PQreset\(PGconn *conn\))173 165.9 Q F0(PQtrace)108
196 Q F1 1.773
(Enables tracing of messages passed between the frontend and the back)
133 213.1 R 4.523(end. The)-.11 F(messages are echoed to the deb)133
226.3 Q(ug_port \214le stream.)-.22 E F2(void PQtrace\(PGconn *conn,)173
251.5 Q(FILE* debug_port\);)251 263.7 Q F0(PQuntrace)108 293.8 Q F1
(Disables tracing of messages passed between the frontend and the back)
133 310.9 Q(end.)-.11 E F2(void PQuntrace\(PGconn *conn\);)173 336.1 Q
/F3 12/Times-Bold@0 SF 3(12.3. Query)72 366.2 R(Execution Functions)3 E
F0(PQexec)108 383.3 Q F1 .141(Submit a query to)133 400.4 R/F4 10
/Times-Roman@0 SF(POSTGRES)2.891 E F1 5.641(.R)C .141
(eturns a PGresult pointer if the query w)-5.641 F .142(as success-)-.11
F .738(ful or a NULL otherwise.)133 413.6 R .738(If a NULL is returned,)
6.238 F/F5 11/Times-Italic@0 SF(PQerr)3.488 E(orMessa)-.495 E -.11(ge)
-.11 G F1 .738(can be used to)3.598 F
(get more information about the error)133 426.8 Q(.)-.605 E F2
(PGresult *PQexec\(PGconn *conn,)173 452 Q(char *query\);)275 464.2 Q F1
3.049(The PGresult structure encapsulates the query result returned by \
the back)133 490.4 R(end.)-.11 E F4(LIBPQ)133 503.6 Q F1 .217(programme\
rs should be careful to maintain the PGresult abstraction. Use the)2.967
F 2.819(accessor functions described belo)133 516.8 R 5.569(wt)-.275 G
5.569(or)-5.569 G(etrie)-5.569 E 3.149 -.165(ve t)-.275 H 2.819
(he results of the query).165 F 8.32(.A)-.715 G -.22(vo)-9.134 G(id).22
E .188
(directly referencing the \214elds of the PGresult structure as the)133
530 R 2.938(ya)-.165 G .188(re subject to change)-2.938 F
(in the future.)133 543.2 Q F0(PQr)108 560.3 Q(esultStatus)-.198 E F1
.562(Returns the result status of the query)133 577.4 R(.)-.715 E F5
(PQr)6.062 E(esultStatus)-.407 E F1 .562(can return one of the follo)
3.312 F(w-)-.275 E(ing v)133 590.6 Q(alues:)-.275 E F2
(PGRES_EMPTY_QUERY,)173 615.8 Q 6(PGRES_COMMAND_OK, /*)173 628 R
(the query was a command */)6 E 6(PGRES_TUPLES_OK, /*)173 640.2 R
(the query successfully returned tuples */)6 E(PGRES_COPY_OUT,)173 652.4
Q(PGRES_COPY_IN,)173 664.6 Q
(PGRES_BAD_RESPONSE, /* an unexpected response was received */)173 676.8
Q(PGRES_NONFATAL_ERROR,)173 689 Q(PGRES_FATAL_ERROR)173 701.2 Q F0(47)
282.5 756 Q EP
%%Page: 48 48
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF .004
(If the result status is PGRES_TUPLES_OK, then the follo)133 97.2 R .004
(wing routines can be used)-.275 F(to retrie)133 110.4 Q .33 -.165(ve t)
-.275 H(he tuples returned by the query).165 E(.)-.715 E/F1 11
/Times-Bold@0 SF(PQntuples)133 127.5 Q F0
(returns the number of tuples \(instances\) in the query result.)2.75 E
/F2 10/Courier@0 SF(int PQntuples\(PGresult *res\);)173 152.7 Q F1
(PQn\214elds)133 178.9 Q F0(returns the number of \214elds \(attrib)2.75
E(utes\) in the query result.)-.22 E F2(int PQnfields\(PGresult *res\);)
173 204.1 Q F1(PQfname)133 230.3 Q F0 1.473
(returns the \214eld \(attrib)4.223 F 1.473
(ute\) name associated with the gi)-.22 F -.165(ve)-.275 G 4.224<6e8c>
.165 G 1.474(eld inde)-4.224 F(x.)-.165 E(Field indices start at 0.)133
243.5 Q F2(char *PQfname\(PGresult *res,)173 268.7 Q(int field_index\);)
251 280.9 Q F1(PQfnumber)133 307.1 Q F0 .418
(returns the \214eld \(attrib)3.168 F .417(ute\) inde)-.22 F 3.167(xa)
-.165 G .417(ssociated with the gi)-3.167 F -.165(ve)-.275 G 3.167<6e8c>
.165 G .417(eld name.)-3.167 F F2(int PQfnumber\(PGresult *res,)173
332.3 Q(char* field_name\);)251 344.5 Q F1(PQftype)133 370.7 Q F0 1.677
(returns the \214eld type associated with the gi)4.426 F -.165(ve)-.275
G 4.427<6e8c>.165 G 1.677(eld inde)-4.427 F 1.677(x. The inte)-.165 F
(ger)-.165 E(returned is an internal coding of the type.)133 383.9 Q
(Field indices start at 0.)5.5 E F2(Oid PQftype\(PGresult *res,)173
409.1 Q(int field_num\);)245 421.3 Q F1(PQfsize)133 447.5 Q F0 .17
(returns the size in bytes of the \214eld associated with the gi)2.92 F
-.165(ve)-.275 G 2.919<6e8c>.165 G .169(eld inde)-2.919 F .169(x. If)
-.165 F(the size returned is -1, the \214eld is a v)133 460.7 Q
(ariable length \214eld.)-.275 E(Field indices start at 0.)5.5 E F2
(int2 PQfsize\(PGresult *res,)173 485.9 Q(int field_index\);)251 498.1 Q
F1(PQgetv)133 524.3 Q(alue)-.11 E F0 .494(returns the \214eld \(attrib)
3.244 F .494(ute\) v)-.22 F 3.244(alue. F)-.275 F .494
(or most queries, the v)-.165 F .495(alue returned)-.275 F(by)133 537.5
Q/F3 11/Times-Italic@0 SF(PQg)5.299 E(etvalue)-.11 E F0 2.549
(is a null-terminated ASCII string representation of the attrib)5.299 F
(ute)-.22 E -.275(va)133 550.7 S 3.973(lue. If).275 F 1.223(the query w)
3.973 F 1.223(as a result of a)-.11 F F1(BIN)3.973 E(AR)-.22 E(Y)-.385 E
F0(cursor)3.974 E 3.974(,t)-.44 G 1.224(hen the v)-3.974 F 1.224
(alue returned by)-.275 F F3(PQg)133 563.9 Q(etvalue)-.11 E F0 1.781
(is the binary representation of the type in the internal format of the)
4.531 F(back)133 577.1 Q .287(end serv)-.11 F(er)-.165 E 5.788(.I)-.605
G 3.038(ti)-5.788 G 3.038(st)-3.038 G .288(he programmer')-3.038 F 3.038
(sr)-.605 G .288(esponsibility to cast and con)-3.038 F -.165(ve)-.44 G
.288(rt the data to).165 F .604(the correct C type.)133 590.3 R .604
(The v)6.104 F .604(alue returned by)-.275 F F3(PQg)3.354 E(etvalue)-.11
E F0 .603(points to storage that is part)3.354 F .264
(of the PGresult structure.)133 603.5 R .264(One must e)5.764 F .264
(xplicitly cop)-.165 F 3.014(yt)-.11 G .264(he v)-3.014 F .265
(alue into other storage if it)-.275 F
(is to be used past the lifetime of the PGresult structure itself.)133
616.7 Q F2(char* PQgetvalue\(PGresult *res,)173 641.9 Q(int tup_num,)275
654.1 Q(int field_num\);)275 666.3 Q F1(PQgetlength)133 692.5 Q F0 .49
(returns the length of a \214eld \(attrib)3.24 F .489(ute\) in bytes.)
-.22 F .489(If the \214eld is a)5.989 F F3(struct)3.239 E(varlena)133
705.7 Q F0 3.324(,t)C .574(he length returned here does)-3.324 F F1(not)
3.324 E F0 .575(include the size \214eld of the v)3.325 F .575
(arlena, i.e.,)-.275 F(it is 4 bytes less.)133 718.9 Q F1(48)282.5 756 Q
EP
%%Page: 49 49
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(int PQgetlength\(PGresult *res,)173 96.2 Q
(int tup_num,)269 108.4 Q(int field_num\);)269 120.6 Q/F1 11
/Times-Bold@0 SF(PQcmdStatus)108 150.7 Q/F2 11/Times-Roman@0 SF
(Returns the command status associated with the last query command.)133
167.8 Q F0(char *PQcmdStatus\(PGresult *res\);)173 193 Q F1(PQoidStatus)
108 223.1 Q F2 2.297(Returns a string with the object id of the tuple i\
nserted if the last query is an)133 240.2 R(INSER)133 253.4 Q 2.75(Tc)
-.66 G 2.75(ommand. Otherwise,)-2.75 F(returns an empty string.)2.75 E
F0(char* PQoidStatus\(PGresult *res\);)173 278.6 Q F1(PQdisplayT)108
308.7 Q(uples)-1.012 E F2 .946
(Prints out all the tuples and, optionally)133 325.8 R 3.696(,t)-.715 G
.946(he attrib)-3.696 F .947(ute names to the speci\214ed output)-.22 F
2.75(stream. The)133 339 R(programs)2.75 E F1(psql)2.75 E F2(and)2.75 E
F1(monitor)2.75 E F2(both use)2.75 E/F3 11/Times-Italic@0 SF(PQdisplayT)
2.75 E(uples)-.605 E F2(for output.)2.75 E F0(void PQdisplayTuples\()173
364.2 Q(PGresult* res,)215 376.4 Q(FILE* fout,)215 388.6 Q
(/* output stream */)36 E(int fillAlign,)215 400.8 Q
(/* pad the fields with spaces? */)18 E(char *fieldSep,)215 413 Q
(/* string to use as the field separator */)12 E
(int printHeader, /* display attribute headers */)215 425.2 Q
(int quiet,)215 437.4 Q(/* print the number of rows returned ? */)42 E
(\);)215 449.6 Q F1(PQclear)108 479.7 Q F2 .635
(Frees the storage associated with the PGresult.)133 496.8 R(Ev)6.135 E
.634(ery query result should be prop-)-.165 F .588
(erly freed when it is no longer used.)133 510 R -.165(Fa)6.089 G .589
(ilure to do this will result in memory leaks).165 F
(in the frontend application.)133 523.2 Q F0
(void PQclear\(PQresult *res\);)173 548.4 Q/F4 12/Times-Bold@0 SF 3
(12.4. F)72 578.5 R(ast P)-.3 E(ath)-.12 E/F5 10/Times-Roman@0 SF
(POSTGRES)108 595.6 Q F2(pro)3.011 E .26(vides a)-.165 F F1 .26
(fast path)3.01 F F2(interf)3.01 E .26
(ace to send function calls to the back)-.11 F 3.01(end. This)-.11 F .26
(is a)3.01 F 1.006
(trapdoor into system internals and can be a potential security hole.)
108 608.8 R 1.007(Most users will not)6.507 F(need this feature.)108 622
Q F0(PGresult* PQfn\(PGconn* conn,)148 647.2 Q(int fnid,)226 659.4 Q
(int *result_buf,)226 671.6 Q(int *result_len,)226 683.8 Q
(int result_is_int,)226 696 Q(PQArgBlock *args,)226 708.2 Q
(int nargs\);)226 720.4 Q F1(49)282.5 756 Q EP
%%Page: 50 50
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF(The)108 97.2 Q/F1 11/Times-Italic@0 SF(fnid)
3.054 E F0(ar)3.054 E .304
(gument is the object identi\214er of the function to be e)-.198 F -.165
(xe)-.165 G(cuted.).165 E F1 -.407(re)5.803 G(sult_b).407 E(uf)-.22 E F0
.303(is the)3.053 F -.22(bu)108 110.4 S -.275(ff).22 G .807
(er in which to load the return v).275 F 3.557(alue. The)-.275 F .807
(caller must ha)3.557 F 1.137 -.165(ve a)-.22 H .807(llocated suf).165 F
.807(\214cient space)-.275 F .861(to store the return v)108 123.6 R
3.611(alue. The)-.275 F .861
(result length will be returned in the storage pointed to by)3.611 F F1
-.407(re)108 136.8 S(sult_len.).407 E F0 .075
(If the result is to be an inte)5.575 F .075(ger v)-.165 F .075
(alue, than)-.275 F F1 -.407(re)2.825 G(sult_is_int).407 E F0 .075
(should be set to 1; oth-)2.825 F(erwise it should be set to 0.)108 150
Q F1(ar)5.5 E(gs)-.407 E F0(and)2.75 E F1(nar)2.75 E(gs)-.407 E F0
(specify the ar)2.75 E(guments to the function.)-.198 E/F2 10/Courier@0
SF(typedef struct {)148 175.2 Q(int len;)172 187.4 Q(int isint;)172
199.6 Q(union {)172 211.8 Q(int *ptr;)196 224 Q(int integer;)184 236.2 Q
6(}u)172 248.4 S(;)-6 E 6(}P)148 260.6 S(QArgBlock;)-6 E F1(PQfn)108
290.7 Q F0(al)4.181 E -.11(wa)-.11 G 1.431(ys returns a v).11 F 1.431
(alid PGresult*.)-.275 F 1.431(The resultStatus should be check)6.931 F
1.431(ed before the)-.11 F .37(result is used.)108 303.9 R .37
(The caller is responsible for freeing the PGresult with)8.62 F F1
(PQclear)3.121 E F0 .371(when it is)3.121 F(not longer needed.)108 317.1
Q/F3 12/Times-Bold@0 SF 3(12.5. Asynchr)72 334.2 R(onous Noti\214cation)
-.216 E/F4 10/Times-Roman@0 SF(POSTGRES)108 351.3 Q F0 .808
(supports asynchronous noti\214cation via the)3.558 F F1(LISTEN)3.557 E
F0(and)3.557 E F1(NO)3.557 E(TIFY)-.44 E F0(commands.)3.557 E 3.739(Ab)
108 364.5 S(ack)-3.739 E .989(end re)-.11 F .989
(gisters its interest in a particular relation with the LISTEN command.)
-.165 F(All)6.49 E(back)108 377.7 Q 3.32(ends listening on a particular\
relation will be noti\214ed asynchronously when a)-.11 F(NO)108 390.9 Q
.996(TIFY of that relation name is e)-.44 F -.165(xe)-.165 G .997
(cuted by another back).165 F 3.747(end. No)-.11 F .997
(additional informa-)3.747 F .53
(tion is passed from the noti\214er to the listener)108 404.1 R 6.029
(.T)-.605 G .529(hus, typically)-6.029 F 3.279(,a)-.715 G .859 -.165
(ny a)-3.279 H .529(ctual data that needs).165 F
(to be communicated is transferred through the relation.)108 417.3 Q F4
(LIBPQ)108 434.4 Q F0 2.056(applications are noti\214ed whene)4.806 F
-.165(ve)-.275 G 4.807(rac).165 G 2.057(onnected back)-4.807 F 2.057
(end has recei)-.11 F -.165(ve)-.275 G 4.807(da).165 G 4.807(na)-4.807 G
(syn-)-4.807 E .731(chronous noti\214cation.)108 447.6 R(Ho)6.231 E(we)
-.275 E -.165(ve)-.275 G 1.611 -.44(r, t).165 H .731
(he communication from the back).44 F .731(end to the frontend is)-.11 F
2.002(not asynchronous.)108 460.8 R 2.002
(Noti\214cation comes piggy-back)7.502 F 2.002
(ed on other query results.)-.11 F 2.002(Thus, an)7.502 F .81
(application must submit queries, e)108 474 R -.165(ve)-.275 G 3.56(ne)
.165 G .81(mpty ones, in order to recei)-3.56 F 1.139 -.165(ve n)-.275 H
.809(otice of back).165 F(end)-.11 E 3.308(noti\214cation. In)108 487.2
R(ef)3.308 E .558(fect, the)-.275 F F4(LIBPQ)3.308 E F0 .558
(application must poll the back)3.308 F .559(end to see if there is an)
-.11 F(y)-.165 E 1.901(pending noti\214cation information.)108 500.4 R
1.9(After the e)7.401 F -.165(xe)-.165 G 1.9(cution of a query).165 F
4.65(,af)-.715 G 1.9(rontend may call)-4.65 F F1(PQNoti\214es)108 513.6
Q F0(to see if an)2.75 E 2.75(yn)-.165 G(oti\214cation data is a)-2.75 E
-.275(va)-.22 G(ilable from the back).275 E(end.)-.11 E/F5 11
/Times-Bold@0 SF(PQNoti\214es)108 530.7 Q F0 2.129(returns the noti\214\
cation from a list of unhandled noti\214cations from the back)133 547.8
R(end.)-.11 E .825
(Returns NULL if there are no pending noti\214cations from the back)133
561 R(end.)-.11 E F1(PQNoti\214es)6.325 E F0(beha)133 574.2 Q -.165(ve)
-.22 G 3.76(sl).165 G(ik)-3.76 E 3.76(et)-.11 G 1.01
(he popping of a stack.)-3.76 F 1.011
(Once a noti\214cation is returned from)6.511 F F1(PQnoti-)3.761 E
(\214es,)133 587.4 Q F0(it is considered handled and will be remo)2.75 E
-.165(ve)-.165 G 2.75(df).165 G(rom the list of noti\214cations.)-2.75 E
F2(PGnotify* PQNotifies\(PGconn *conn\);)173 612.6 Q F0
(The second sample program gi)108 642.7 Q -.165(ve)-.275 G 2.75(sa).165
G 2.75(ne)-2.75 G(xample of the use of asynchronous noti\214cation.)
-2.915 E F3 3(12.6. Functions)72 659.8 R
(Associated with the COPY Command)3 E F0(The)108 676.9 Q F1(copy)3.4 E
F0 .65(command in)3.4 F F4(POSTGRES)3.4 E F0 .649
(has options to read from or write to the netw)3.4 F .649(ork con-)-.11
F 1.149(nection used by)108 690.1 R F4(LIBPQ)3.899 E F0 6.649(.T)C 1.149
(herefore, functions are necessary to access this netw)-6.649 F 1.15
(ork con-)-.11 F(nection directly so applications may tak)108 703.3 Q
2.75(ef)-.11 G(ull adv)-2.75 E(antage of this capability)-.275 E(.)-.715
E F5(50)282.5 756 Q EP
%%Page: 51 51
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Bold@0 SF(PQgetline)108 97.2 Q/F1 11/Times-Roman@0 SF 1.171
(Reads a ne)133 114.3 R 1.171
(wline-terminated line of characters \(transmitted by the back)-.275 F
1.17(end serv)-.11 F(er\))-.165 E .821(into a b)133 127.5 R(uf)-.22 E
(fer)-.275 E/F2 11/Times-Italic@0 SF(string)3.571 E F1 .821(of size)
3.571 F F2(length)3.571 E F1 6.321(.L)C(ik)-6.321 E(e)-.11 E F2(fg)3.571
E(ets)-.11 E F1 .822(\(3\), this routine copies up to)B F2(length)3.572
E F1(-1)A .56(characters into)133 140.7 R F2(string)3.31 E F1 6.06(.I)C
3.31(ti)-6.06 G 3.31(sl)-3.31 G(ik)-3.31 E(e)-.11 E F2 -.11(ge)3.31 G
(ts).11 E F1 .56(\(3\), ho)B(we)-.275 E -.165(ve)-.275 G 1.439 -.44
(r, i).165 H 3.309(nt).44 G .559(hat it con)-3.309 F -.165(ve)-.44 G
.559(rts the terminating).165 F(ne)133 153.9 Q
(wline into a null character)-.275 E(.)-.605 E F2(PQg)133 171 Q(etline)
-.11 E F1 .329(returns EOF at EOF)3.078 F 3.079(,0i)-.88 G 3.079(ft)
-3.079 G .329(he entire line has been read, and 1 if the b)-3.079 F(uf)
-.22 E(fer)-.275 E(is full b)133 184.2 Q(ut the terminating ne)-.22 E
(wline has not yet been read.)-.275 E 1.471
(Notice that the application must check to see if a ne)133 201.3 R 4.221
(wl)-.275 G 1.471(ine consists of the single)-4.221 F 2.691
(character \231.)133 214.5 R 2.691(\232, which indicates that the back)
-.77 F 2.691(end serv)-.11 F 2.692(er has \214nished sending the)-.165 F
.89(results of the)133 227.7 R F2(copy)3.64 E F1 3.64
(command. Therefore,)3.64 F .889(if the application e)3.639 F -.165(ve)
-.275 G 3.639(re).165 G .889(xpects to recei)-3.804 F -.165(ve)-.275 G
1.419(lines that are more than)133 240.9 R F2(length)4.169 E F1 1.419
(-1 characters long, the application must be sure to)B
(check the return v)133 254.1 Q(alue of)-.275 E F2(PQg)2.75 E(etline)
-.11 E F1 -.165(ve)2.75 G(ry carefully).165 E(.)-.715 E(The code in)133
271.2 Q/F3 10/Courier@0 SF(../src/bin/psql/psql.c)173 296.4 Q F1
(contains routines that correctly handle the cop)133 322.6 Q 2.75(yp)
-.11 G(rotocol.)-2.75 E F3(int PQgetline\(PGconn *conn,)173 347.8 Q
(char *string,)257 360 Q(int length\))257 372.2 Q F0(PQputline)108 402.3
Q F1(Sends a null-terminated)133 419.4 Q F2(string)2.75 E F1
(to the back)2.75 E(end serv)-.11 E(er)-.165 E(.)-.605 E .152
(The application must e)133 436.5 R .152
(xplicitly send the single character \231.)-.165 F 5.652<9a74>-.77 G
2.901(oi)-5.652 G .151(ndicate to the back-)-2.901 F
(end that it has \214nished sending its data.)133 449.7 Q F3
(void PQputline\(PGconn *conn,)173 474.9 Q(char *string\);)263 487.1 Q
F0(PQendcopy)108 517.2 Q F1 2.02(Syncs with the back)133 534.3 R 4.77
(end. This)-.11 F 2.021(function w)4.77 F 2.021(aits until the back)-.11
F 2.021(end has \214nished the)-.11 F(cop)133 547.5 Q 5.207 -.715(y. I)
-.11 H 3.777(ts).715 G 1.027
(hould either be issued when the last string has been sent to the back)
-3.777 F(end)-.11 E(using)133 560.7 Q F2(PQputline)3.67 E F1 .921
(or when the last string has been recei)3.67 F -.165(ve)-.275 G 3.671
(df).165 G .921(rom the back)-3.671 F .921(end using)-.11 F F2(PGg)133
573.9 Q(etline)-.11 E F1 6.439(.I)C 3.689(tm)-6.439 G .939
(ust be issued or the back)-3.689 F .939
(end may get \231out of sync\232 with the fron-)-.11 F 5.023(tend. Upon)
133 587.1 R 2.274(return from this function, the back)5.023 F 2.274
(end is ready to recei)-.11 F 2.604 -.165(ve t)-.275 H 2.274(he ne).165
F(xt)-.165 E(query)133 600.3 Q(.)-.715 E(The return v)133 617.4 Q
(alue is 0 on successful completion, nonzero otherwise.)-.275 E F3
(int PQendcopy\(PGconn *conn\);)173 642.6 Q F1(As an e)133 668.8 Q
(xample:)-.165 E F3
(PQexec\(conn, "create table foo \(a int4, b char16, d float8\)"\);)173
694 Q(PQexec\(conn, "copy foo from stdin"\);)173 706.2 Q
(PQputline\(conn, "3<TAB>hello world<TAB>4.5\\n"\);)173 718.4 Q F0(51)
282.5 756 Q EP
%%Page: 52 52
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF
(PQputline\(conn,"4<TAB>goodbye world<TAB>7.11\\n"\);)173 96.2 Q(...)173
108.4 Q(PQputline\(conn,".\\n"\);)173 120.6 Q(PQendcopy\(conn\);)173
132.8 Q/F1 12/Times-Bold@0 SF 3(12.7. LIBPQ)72 162.9 R -.888(Tr)3 G
(acing Functions).888 E/F2 11/Times-Bold@0 SF(PQtrace)108 180 Q/F3 11
/Times-Roman@0 SF(Enable tracing of the frontend/back)133 197.1 Q
(end communication to a deb)-.11 E(ugging \214le stream.)-.22 E F0
(void PQtrace\(PGconn *conn)173 222.3 Q(FILE *debug_port\))251 234.5 Q
F2(PQuntrace)108 264.6 Q F3(Disable tracing started by)133 281.7 Q/F4 11
/Times-Italic@0 SF(PQtr)2.75 E(ace)-.165 E F0
(void PQuntrace\(PGconn *conn\))173 306.9 Q F1 3(12.8. User)72 337 R -.6
(Au)3 G(thentication Functions).6 E F3 1.119(If the user has generated \
the appropriate authentication credentials \(e.g., obtaining)108 354.1 R
F4 -.385(Ke)3.869 G -.22(r-).385 G(ber)108 367.3 Q(os)-.495 E F3(tick)
3.064 E .314(ets\), the frontend/back)-.11 F .315
(end authentication process is handled by)-.11 F F4(PQe)3.065 E(xec)-.22
E F3(without)3.065 E(an)108 380.5 Q 2.812(yf)-.165 G .062(urther interv)
-2.812 F 2.812(ention. The)-.165 F(follo)2.812 E .061
(wing routines may be called by)-.275 F/F5 10/Times-Roman@0 SF(LIBPQ)
2.811 E F3 .061(programs to tai-)2.811 F(lor the beha)108 393.7 Q
(vior of the authentication process.)-.22 E F2(fe_getauthname)108 410.8
Q F3 1.32(Returns a pointer to static space containing whate)133 427.9 R
-.165(ve)-.275 G 4.07(rn).165 G 1.321(ame the user has authenti-)-4.07 F
3.549(cated. Use)133 441.1 R .799(of this routine in place of calls to)
3.549 F F4 -.11(ge)3.548 G(ten).11 E(v)-.44 E F3 .798(\(3\) or)B F4 -.11
(ge)3.548 G(tpwuid).11 E F3 .798(\(3\) by applica-)B 1.407(tions is hig\
hly recommended, as it is entirely possible that the authenticated user)
133 454.3 R .29(name is)133 467.5 R F2(not)3.04 E F3 .29(the same as v)
3.04 F .29(alue of the)-.275 F/F6 11/Courier@0 SF(USER)3.04 E F3(en)3.04
E .29(vironment v)-.44 F .29(ariable or the user')-.275 F 3.039(se)-.605
G(ntry)-3.039 E(in)133 480.7 Q F4(/etc/passwd)2.75 E F3(.)A F0
(char *fe_getauthname\(char* errorMessage\))173 505.9 Q F2
(fe_setauthsvc)108 536 Q F3 1.521(Speci\214es that)133 553.1 R F5(LIBPQ)
4.272 E F3 1.522(should use authentication service)4.272 F F4(name)4.272
E F3 1.522(rather than its com-)4.272 F(piled-in def)133 566.3 Q 2.75
(ault. This)-.11 F -.275(va)2.75 G(lue is typically tak).275 E
(en from a command-line switch.)-.11 E F0
(void fe_setauthsvc\(char *name,)173 591.5 Q(char* errorMessage\))287
603.7 Q F3(An)133 629.9 Q 3.529(ye)-.165 G .778(rror messages from the \
authentication attempts are returned in the errorMes-)-3.529 F(sage ar)
133 643.1 Q(gument.)-.198 E F1 3(12.9. B)72 660.2 R(UGS)-.12 E F3 1.28
(The query b)108 677.3 R(uf)-.22 E 1.28
(fer is 8192 bytes long, and queries o)-.275 F -.165(ve)-.165 G 4.031
(rt).165 G 1.281(hat length will be silently trun-)-4.031 F(cated.)108
690.5 Q F2(52)282.5 756 Q EP
%%Page: 53 53
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(12.10. Sample)72 97.2 R(Pr)3 E(ograms)-.216 E
/F1 11/Times-Bold@0 SF(53)282.5 756 Q EP
%%Page: 54 54
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(12.10.1. Sample)72 97.2 R(Pr)3 E(ogram 1)-.216
E/F1 10/Courier@0 SF(/*)148 113.3 Q 6(*t)154 125.5 S(estlibpq.c)-6 E 24
(*T)154 137.7 S(est the C version of)-24 E/F2 9/Courier@0 SF(LIBPQ)6 E
F1 6(,t)C(he)-6 E F2(POSTGRES)6 E F1(frontend library.)6 E(*)154 149.9 Q
(*)154 162.1 Q(*/)154 174.3 Q(#include <stdio.h>)148 186.5 Q
(#include "libpq-fe.h")148 198.7 Q(void)148 223.1 Q
(exit_nicely\(PGconn* conn\))148 235.3 Q({)148 247.5 Q
(PQfinish\(conn\);)160 259.7 Q(exit\(1\);)160 271.9 Q(})148 284.1 Q
(main\(\))148 308.5 Q({)148 320.7 Q
(char *pghost, *pgport, *pgoptions, *pgtty;)160 332.9 Q(char* dbName;)
160 345.1 Q(int nFields;)160 357.3 Q(int i,j;)160 369.5 Q 6(/* FILE)148
393.9 R(*debug; */)6 E(PGconn* conn;)160 418.3 Q(PGresult* res;)160
430.5 Q(/* begin, by setting the parameters for a backend connection)160
454.9 Q(if the parameters are null, then the system will try to use)178
467.1 Q(reasonable defaults by looking up environment variables)178
479.3 Q(or, failing that, using hardwired constants */)178 491.5 Q
(pghost = NULL;)160 503.7 Q(/* host name of the backend server */)12 E
(pgport = NULL;)160 515.9 Q(/* port of the backend server */)12 E
(pgoptions = NULL; /* special options to start up the backend server */)
160 528.1 Q(pgtty = NULL;)160 540.3 Q
(/* debugging tty for the backend server */)30 E(dbName = "template1";)
160 552.5 Q(/* make a connection to the database */)160 576.9 Q
(conn = PQsetdb\(pghost, pgport, pgoptions, pgtty, dbName\);)160 589.1 Q
(/* check to see that the backend connection was successfully made */)
160 613.5 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)160 625.7 Q
(fprintf\(stderr,"Connection to database '%s' failed.0, dbName\);)172
637.9 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)172 650.1 Q
(exit_nicely\(conn\);)172 662.3 Q(})160 674.5 Q 6(/* debug)148 698.9 R 6
(=f)6 G 6(open\("/tmp/trace.out","w"\); */)-6 F 12(/* PQtrace\(conn,)148
711.1 R 6(debug\); */)6 F/F3 11/Times-Bold@0 SF(54)282.5 756 Q EP
%%Page: 55 55
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(/* start a transaction block */)160 96.2 Q
(res = PQexec\(conn,"BEGIN"\);)160 108.4 Q
(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 120.6 Q
(fprintf\(stderr,"BEGIN command failed0\);)172 132.8 Q(PQclear\(res\);)
172 145 Q(exit_nicely\(conn\);)172 157.2 Q(})160 169.4 Q
(/* should PQclear PGresult whenever it is no longer needed to avoid)160
181.6 Q(memory leaks */)178 193.8 Q(PQclear\(res\);)160 206 Q(/* fetch \
instances from the pg_database, the system catalog of databases*/)160
230.4 Q(res = PQexec\(conn,"DECLARE myportal CURSOR FOR select * from p\
g_database"\);)160 242.6 Q
(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 254.8 Q
(fprintf\(stderr,"DECLARE CURSOR command failed0\);)172 267 Q
(PQclear\(res\);)172 279.2 Q(exit_nicely\(conn\);)172 291.4 Q(})160
303.6 Q(PQclear\(res\);)160 315.8 Q
(res = PQexec\(conn,"FETCH ALL in myportal"\);)160 340.2 Q
(if \(PQresultStatus\(res\) != PGRES_TUPLES_OK\) {)160 352.4 Q
(fprintf\(stderr,"FETCH ALL command didn't return tuples properly0\);)
172 364.6 Q(PQclear\(res\);)172 376.8 Q(exit_nicely\(conn\);)172 389 Q
(})160 401.2 Q(/* first, print out the attribute names */)160 425.6 Q
(nFields = PQnfields\(res\);)160 437.8 Q
(for \(i=0; i < nFields; i++\) {)160 450 Q
(printf\("%-15s",PQfname\(res,i\)\);)172 462.2 Q(})160 474.4 Q
(printf\("0\);)160 486.6 Q(/* next, print out the instances */)160 511 Q
(for \(i=0; i < PQntuples\(res\); i++\) {)160 523.2 Q(for \(j=0)172
535.4 Q 6(;j<n)12 G(Fields; j++\) {)-6 E
(printf\("%-15s", PQgetvalue\(res,i,j\)\);)184 547.6 Q(})172 559.8 Q
(printf\("0\);)172 572 Q(})160 584.2 Q(PQclear\(res\);)160 608.6 Q
(/* close the portal */)160 633 Q
(res = PQexec\(conn, "CLOSE myportal"\);)160 645.2 Q(PQclear\(res\);)160
657.4 Q(/* end the transaction */)160 681.8 Q
(res = PQexec\(conn, "END"\);)160 694 Q(PQclear\(res\);)160 706.2 Q/F1
11/Times-Bold@0 SF(55)282.5 756 Q EP
%%Page: 56 56
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF
(/* close the connection to the database and cleanup */)160 96.2 Q
(PQfinish\(conn\);)160 108.4 Q 12(/* fclose\(debug\);)148 132.8 R(*/)6 E
(})148 145 Q/F1 11/Times-Bold@0 SF(56)282.5 756 Q EP
%%Page: 57 57
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(12.10.2. Sample)72 97.2 R(Pr)3 E(ogram 2)-.216
E/F1 10/Courier@0 SF(/*)148 113.3 Q 6(*t)154 125.5 S(estlibpq2.c)-6 E 24
(*T)154 137.7 S(est of the asynchronous notification interface)-24 E(*)
154 149.9 Q(populate a database with the following:)166 162.1 Q
(CREATE TABLE TBL1 \(i int4\);)148 186.5 Q
(CREATE TABLE TBL2 \(i int4\);)148 210.9 Q(CREATE RULE r1 AS ON INSERT \
TO TBL1 DO [INSERT INTO TBL2 values \(new.i\); NOTIFY TBL2];)148 235.3 Q
6(*T)154 259.7 S(hen start up this program)-6 E 6(*A)154 271.9 S
(fter the program has begun, do)-6 E(INSERT INTO TBL1 values \(10\);)148
296.3 Q(*)154 320.7 Q(*)154 332.9 Q(*/)154 345.1 Q(#include <stdio.h>)
148 357.3 Q(#include "libpq-fe.h")148 369.5 Q
(void exit_nicely\(PGconn* conn\))148 393.9 Q({)148 406.1 Q
(PQfinish\(conn\);)160 418.3 Q(exit\(1\);)160 430.5 Q(})148 442.7 Q
(main\(\))148 467.1 Q({)148 479.3 Q
(char *pghost, *pgport, *pgoptions, *pgtty;)160 491.5 Q(char* dbName;)
160 503.7 Q(int nFields;)160 515.9 Q(int i,j;)160 528.1 Q(PGconn* conn;)
160 552.5 Q(PGresult* res;)160 564.7 Q(PGnotify* notify;)160 576.9 Q
(/* begin, by setting the parameters for a backend connection)160 601.3
Q(if the parameters are null, then the system will try to use)178 613.5
Q(reasonable defaults by looking up environment variables)178 625.7 Q
(or, failing that, using hardwired constants */)178 637.9 Q
(pghost = NULL;)160 650.1 Q(/* host name of the backend server */)12 E
(pgport = NULL;)160 662.3 Q(/* port of the backend server */)12 E
(pgoptions = NULL; /* special options to start up the backend server */)
160 674.5 Q(pgtty = NULL;)160 686.7 Q
(/* debugging tty for the backend server */)30 E(dbName = getenv\("USER\
"\); /* change this to the name of your test database*/)160 698.9 Q
(/* make a connection to the database */)160 723.3 Q/F2 11/Times-Bold@0
SF(57)282.5 756 Q EP
%%Page: 58 58
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF
(conn = PQsetdb\(pghost, pgport, pgoptions, pgtty, dbName\);)160 96.2 Q
(/* check to see that the backend connection was successfully made */)
160 120.6 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)160 132.8 Q
(fprintf\(stderr,"Connection to database '%s' failed.0, dbName\);)172
145 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)172 157.2 Q
(exit_nicely\(conn\);)172 169.4 Q(})160 181.6 Q
(res = PQexec\(conn, "LISTEN TBL2"\);)160 206 Q
(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 218.2 Q
(fprintf\(stderr,"LISTEN command failed0\);)172 230.4 Q(PQclear\(res\);)
172 242.6 Q(exit_nicely\(conn\);)172 254.8 Q(})160 267 Q
(/* should PQclear PGresult whenever it is no longer needed to avoid)160
279.2 Q(memory leaks */)178 291.4 Q(PQclear\(res\);)160 303.6 Q
(while \(1\) {)160 328 Q
(/* async notification only come back as a result of a query*/)184 340.2
Q(/* we can send empty queries */)184 352.4 Q
(res = PQexec\(conn, " "\);)184 364.6 Q 30(/* printf\("res->status)148
376.8 R 6(=%)6 G(s0, pgresStatus[PQresultStatus\(res\)]\); */)-6 E
(/* check for asynchronous returns */)184 389 Q
(notify = PQnotifies\(conn\);)184 401.2 Q(if \(notify\) {)184 413.4 Q
(fprintf\(stderr,)196 425.6 Q
("ASYNC NOTIFY of '%s' from backend pid '%d' received0,)232 437.8 Q
(notify->relname, notify->be_pid\);)232 450 Q(free\(notify\);)196 462.2
Q(break;)196 474.4 Q(})184 486.6 Q(PQclear\(res\);)184 498.8 Q(})160 511
Q(/* close the connection to the database and cleanup */)160 535.4 Q
(PQfinish\(conn\);)160 547.6 Q(})148 572 Q/F1 11/Times-Bold@0 SF(58)
282.5 756 Q EP
%%Page: 59 59
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(12.10.3. Sample)72 97.2 R(Pr)3 E(ogram 3)-.216
E/F1 10/Courier@0 SF(/*)148 113.3 Q 6(*t)154 125.5 S(estlibpq3.c)-6 E 24
(*T)154 137.7 S(est the C version of)-24 E/F2 9/Courier@0 SF(LIBPQ)6 E
F1 6(,t)C(he)-6 E F2(POSTGRES)6 E F1(frontend library.)6 E 18(*t)154
149.9 S(ests the binary cursor interface)-18 E(*)154 162.1 Q(*)154 174.3
Q(*)154 186.5 Q(populate a database by doing the following:)154 198.7 Q
(CREATE TABLE test1 \(i int4, d float4, p polygon\);)148 223.1 Q(INSERT\
INTO test1 values \(1, 3.567, '\(3.0, 4.0, 1.0, 2.0\)'::polygon\);)148
247.5 Q(INSERT INTO test1 values \(2, 89.05, '\(4.0, 3.0, 2.0, 1.0\)'::\
polygon\);)148 271.9 Q(the expected output is:)154 296.3 Q(tuple 0: got)
148 320.7 Q 6(i=\()154 332.9 S 6(4b)-6 G(ytes\) 1,)-6 E 6(d=\()154 345.1
S 6(4b)-6 G(ytes\) 3.567000,)-6 E 6(p=\()154 357.3 S 6(4b)-6 G
(ytes\) 2 points)-6 E
(boundbox = \(hi=3.000000/4.000000, lo = 1.000000,2.000000\))54 E
(tuple 1: got)148 369.5 Q 6(i=\()154 381.7 S 6(4b)-6 G(ytes\) 2,)-6 E 6
(d=\()154 393.9 S 6(4b)-6 G(ytes\) 89.050003,)-6 E 6(p=\()154 406.1 S 6
(4b)-6 G(ytes\) 2 points)-6 E
(boundbox = \(hi=4.000000/3.000000, lo = 2.000000,1.000000\))54 E(*)154
430.5 Q(*/)154 442.7 Q(#include <stdio.h>)148 454.9 Q
(#include "libpq-fe.h")148 467.1 Q
(#include "utils/geo-decls.h" /* for the POLYGON type */)148 479.3 Q
(void exit_nicely\(PGconn* conn\))148 503.7 Q({)148 515.9 Q
(PQfinish\(conn\);)160 528.1 Q(exit\(1\);)160 540.3 Q(})148 552.5 Q
(main\(\))148 576.9 Q({)148 589.1 Q
(char *pghost, *pgport, *pgoptions, *pgtty;)160 601.3 Q(char* dbName;)
160 613.5 Q(int nFields;)160 625.7 Q(int i,j;)160 637.9 Q
(int i_fnum, d_fnum, p_fnum;)160 650.1 Q(PGconn* conn;)160 674.5 Q
(PGresult* res;)160 686.7 Q
(/* begin, by setting the parameters for a backend connection)160 711.1
Q(if the parameters are null, then the system will try to use)178 723.3
Q/F3 11/Times-Bold@0 SF(59)282.5 756 Q EP
%%Page: 60 60
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF
(reasonable defaults by looking up environment variables)178 96.2 Q
(or, failing that, using hardwired constants */)178 108.4 Q
(pghost = NULL;)160 120.6 Q(/* host name of the backend server */)12 E
(pgport = NULL;)160 132.8 Q(/* port of the backend server */)12 E
(pgoptions = NULL; /* special options to start up the backend server */)
160 145 Q(pgtty = NULL;)160 157.2 Q
(/* debugging tty for the backend server */)30 E
(dbName = getenv\("USER"\);)160 181.6 Q
(/* change this to the name of your test database*/)12 E
(/* make a connection to the database */)160 206 Q
(conn = PQsetdb\(pghost, pgport, pgoptions, pgtty, dbName\);)160 218.2 Q
(/* check to see that the backend connection was successfully made */)
160 242.6 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)160 254.8 Q
(fprintf\(stderr,"Connection to database '%s' failed.0, dbName\);)172
267 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)172 279.2 Q
(exit_nicely\(conn\);)172 291.4 Q(})160 303.6 Q
(/* start a transaction block */)160 328 Q
(res = PQexec\(conn,"BEGIN"\);)160 340.2 Q
(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 352.4 Q
(fprintf\(stderr,"BEGIN command failed0\);)172 364.6 Q(PQclear\(res\);)
172 376.8 Q(exit_nicely\(conn\);)172 389 Q(})160 401.2 Q
(/* should PQclear PGresult whenever it is no longer needed to avoid)160
413.4 Q(memory leaks */)178 425.6 Q(PQclear\(res\);)160 437.8 Q(/* fetc\
h instances from the pg_database, the system catalog of databases*/)160
462.2 Q(res = PQexec\(conn,"DECLARE mycursor BINARY CURSOR FOR select *\
from test1"\);)160 474.4 Q
(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 486.6 Q
(fprintf\(stderr,"DECLARE CURSOR command failed0\);)172 498.8 Q
(PQclear\(res\);)172 511 Q(exit_nicely\(conn\);)172 523.2 Q(})160 535.4
Q(PQclear\(res\);)160 547.6 Q
(res = PQexec\(conn,"FETCH ALL in mycursor"\);)160 572 Q
(if \(PQresultStatus\(res\) != PGRES_TUPLES_OK\) {)160 584.2 Q
(fprintf\(stderr,"FETCH ALL command didn't return tuples properly0\);)
172 596.4 Q(PQclear\(res\);)172 608.6 Q(exit_nicely\(conn\);)172 620.8 Q
(})160 633 Q(i_fnum = PQfnumber\(res,"i"\);)160 657.4 Q
(d_fnum = PQfnumber\(res,"d"\);)160 669.6 Q
(p_fnum = PQfnumber\(res,"p"\);)160 681.8 Q(for \(i=0;i<3;i++\) {)160
706.2 Q(printf\("type[%d] = %d, size[%d] = %d0,)184 718.4 Q/F1 11
/Times-Bold@0 SF(60)282.5 756 Q EP
%%Page: 61 61
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(i, PQftype\(res,i\),)214 96.2 Q
(i, PQfsize\(res,i\)\);)214 108.4 Q(})160 120.6 Q
(for \(i=0; i < PQntuples\(res\); i++\) {)160 132.8 Q(int *ival;)172 145
Q(float *dval;)172 157.2 Q(int plen;)172 169.4 Q(POLYGON* pval;)172
181.6 Q(/* we hard-wire this to the 3 fields we know about */)172 193.8
Q(ival =)172 206 Q(\(int*\)PQgetvalue\(res,i,i_fnum\);)12 E(dval =)172
218.2 Q(\(float*\)PQgetvalue\(res,i,d_fnum\);)12 E
(plen = PQgetlength\(res,i,p_fnum\);)172 230.4 Q(/* plen doesn't includ\
e the length field so need to increment by VARHDSZ*/)172 254.8 Q
(pval = \(POLYGON*\) malloc\(plen + VARHDRSZ\);)172 267 Q
(pval->size = plen;)172 279.2 Q
(memmove\(\(char*\)&pval->npts, PQgetvalue\(res,i,p_fnum\), plen\);)172
291.4 Q(printf\("tuple %d: got0, i\);)172 303.6 Q
(printf\(" i = \(%d bytes\) %d,0,)172 315.8 Q
(PQgetlength\(res,i,i_fnum\), *ival\);)202 328 Q
(printf\(" d = \(%d bytes\) %f,0,)172 340.2 Q
(PQgetlength\(res,i,d_fnum\), *dval\);)202 352.4 Q(printf\(" p = \(%d b\
ytes\) %d points boundbox = \(hi=%f/%f, lo = %f,%f\)0,)172 364.6 Q
(PQgetlength\(res,i,d_fnum\),)202 376.8 Q(pval->npts,)202 389 Q
(pval->boundbox.xh,)202 401.2 Q(pval->boundbox.yh,)202 413.4 Q
(pval->boundbox.xl,)202 425.6 Q(pval->boundbox.yl\);)202 437.8 Q(})160
450 Q(PQclear\(res\);)160 474.4 Q(/* close the portal */)160 498.8 Q
(res = PQexec\(conn, "CLOSE mycursor"\);)160 511 Q(PQclear\(res\);)160
523.2 Q(/* end the transaction */)160 547.6 Q
(res = PQexec\(conn, "END"\);)160 559.8 Q(PQclear\(res\);)160 572 Q
(/* close the connection to the database and cleanup */)160 596.4 Q
(PQfinish\(conn\);)160 608.6 Q(})148 633 Q/F1 11/Times-Bold@0 SF(61)
282.5 756 Q EP
%%Page: 62 62
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(13. LARGE)72 165.4 R(OBJECTS)4.75 E
77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL
91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL
108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6
DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130
178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6
146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5
178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185
178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL
201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6
DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5
178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6
240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6
256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5
178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295
178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL
311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6
DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5
178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6
350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6
366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5
178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405
178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL
421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6
DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5
178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6
460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6
476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5
178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF(In)
108 208.9 Q/F2 10/Times-Roman@0 SF(POSTGRES)4.497 E F1 4.497(,d)C 1.746
(ata v)-4.497 F 1.746(alues are stored in tuples and indi)-.275 F 1.746
(vidual tuples cannot span data)-.275 F 1.017(pages. Since the size of \
a data page is 8192 bytes, the upper limit on the size of a data)108
222.1 R -.275(va)108 235.3 S 1.306(lue is relati).275 F -.165(ve)-.275 G
1.306(ly lo).165 F 2.736 -.715(w. T)-.275 H 4.055(os)-.165 G 1.305
(upport the storage of lar)-4.055 F 1.305(ger atomic v)-.198 F(alues,)
-.275 E F2(POSTGRES)4.055 E F1(pro-)4.055 E .029(vides a lar)108 248.5 R
.029(ge object interf)-.198 F 2.779(ace. This)-.11 F(interf)2.78 E .03
(ace pro)-.11 F .03(vides \214le-oriented access to user data that)-.165
F(has been declared to be a lar)108 261.7 Q(ge type.)-.198 E 2.267(This\
section describes the implementation and the programmatic and query la\
nguage)108 278.8 R(interf)108 292 Q(aces to)-.11 E F2(POSTGRES)2.75 E F1
(lar)2.75 E(ge object data.)-.198 E/F3 12/Times-Bold@0 SF 3
(13.1. Historical)72 309.1 R(Note)3 E F1(Originally)108 326.2 Q(,)-.715
E F2(POSTGRES)4.077 E F1 1.327
(4.2 supports three standard implementations of lar)4.077 F 1.328
(ge objects: as)-.198 F 1.471(\214les e)108 339.4 R 1.471(xternal to)
-.165 F F2(POSTGRES)4.22 E F1 4.22(,a)C(s)-4.22 E F2(UNIX)4.22 E F1 1.47
(\214les managed by)4.22 F F2(POSTGRES)4.22 E F1 4.22(,a)C 1.47
(nd as data stored)-4.22 F 2.431(within the)108 352.6 R F2(POSTGRES)
5.181 E F1 2.432
(database. It causes considerable confusion among users. As a)5.181 F
1.719(result, we only support lar)108 365.8 R 1.719
(ge objects as data stored within the)-.198 F F2(POSTGRES)4.469 E F1
1.719(database in)4.469 F F2(POSTGRES)108 379 Q F1 1.127(95. Ev)B 1.127
(en though is is slo)-.165 F 1.128(wer to access, it pro)-.275 F 1.128
(vides stricter data inte)-.165 F 1.128(grity and)-.165 F 1.272
(time tra)108 392.2 R -.165(ve)-.22 G 1.272(l. F).165 F 1.272
(or historical reasons, the)-.165 F 4.022(ya)-.165 G 1.272(re called In)
-4.022 F -.165(ve)-.44 G 1.272(rsion lar).165 F 1.272(ge objects. \(W)
-.198 F 4.021(ew)-.88 G 1.271(ill use)-4.021 F(In)108 405.4 Q -.165(ve)
-.44 G(rsion and lar).165 E
(ge objects interchangeably to mean the same thing in this section.\))
-.198 E F3 3(13.2. In)72 431.6 R -.12(ve)-.48 G(rsion Lar).12 E
(ge Objects)-.12 E F1 2.125(The In)108 448.7 R -.165(ve)-.44 G 2.125
(rsion lar).165 F 2.125(ge object implementation breaks lar)-.198 F
2.125(ge objects up into \231chunks\232 and)-.198 F 1.03
(stores the chunks in tuples in the database.)108 461.9 R 3.78(AB)6.53 G
1.03(-tree inde)-3.78 F 3.78(xg)-.165 G 1.03(uarantees f)-3.78 F 1.03
(ast searches for)-.11 F
(the correct chunk number when doing random access reads and writes.)108
475.1 Q F3 3(13.3. Lar)72 501.3 R(ge Object Interfaces)-.12 E F1 .643
(The f)108 518.4 R(acilities)-.11 E F2(POSTGRES)3.393 E F1(pro)3.393 E
.643(vides to access lar)-.165 F .643(ge objects, both in the back)-.198
F .644(end as part of)-.11 F(user)108 531.6 Q .947(-de\214ned functions\
or the front end as part of an application using the)-.22 F(interf)
6.446 E .946(ace, are)-.11 F .561(described belo)108 544.8 R 1.991 -.715
(w. \()-.275 H -.165(Fo).715 G 3.311(ru).165 G .561(sers f)-3.311 F .561
(amiliar with)-.11 F F2(POSTGRES)3.311 E F1(4.2,)3.311 E F2(POSTGRES)
3.311 E F1 .561(95 has a ne)B 3.312(ws)-.275 G .562(et of)-3.312 F .27
(functions pro)108 558 R .27(viding a more coherent interf)-.165 F .27
(ace. The interf)-.11 F .269(ace is the same for dynamically-)-.11 F
(loaded C functions as well as for .)108 571.2 Q(The)108 588.3 Q F2
(POSTGRES)4.358 E F1(lar)4.358 E 1.608(ge object interf)-.198 F 1.609
(ace is modeled after the)-.11 F F2(UNIX)4.359 E F1 1.609
(\214le system interf)4.359 F(ace,)-.11 E .45(with analogues of)108
601.5 R/F4 11/Times-Italic@0 SF(open)3.199 E F1(\(2\),)A F4 -.407(re)
3.199 G(ad).407 E F1(\(2\),)A F4(write)3.199 E F1(\(2\),)A F4(lseek)
3.199 E F1 .449(\(2\), etc.)B .449(User functions call these rou-)5.949
F 1.739(tines to retrie)108 614.7 R 2.069 -.165(ve o)-.275 H 1.739
(nly the data of interest from a lar).165 F 1.74(ge object.)-.198 F
-.165(Fo)7.24 G 4.49(re).165 G 1.74(xample, if a lar)-4.655 F(ge)-.198 E
.074(object type called)108 627.9 R F4(mugshot)2.824 E F1 -.165(ex)2.824
G .074(isted that stored photographs of f).165 F .073
(aces, then a function called)-.11 F F4(bear)108 641.1 Q(d)-.407 E F1
.148(could be declared on)2.898 F F4(mugshot)2.898 E F1(data.)2.898 E F4
(Bear)5.648 E(d)-.407 E F1 .149(could look at the lo)2.898 F .149
(wer third of a photo-)-.275 F .793
(graph, and determine the color of the beard that appeared there, if an)
108 654.3 R 4.972 -.715(y. T)-.165 H .792(he entire lar).715 F(ge)-.198
E(object v)108 667.5 Q(alue need not be b)-.275 E(uf)-.22 E(fered, or e)
-.275 E -.165(ve)-.275 G 2.75(ne).165 G(xamined, by the)-2.915 E F4
(bear)2.75 E(d)-.407 E F1(function.)2.75 E(Lar)108 684.6 Q 1.165(ge obj\
ects may be accessed from dynamically-loaded C functions or database cl\
ient)-.198 F .831(programs that link the)108 697.8 R(library)6.331 E(.)
-.715 E F2(POSTGRES)6.331 E F1(pro)3.581 E .83
(vides a set of routines that support open-)-.165 F
(ing, reading, writing, closing, and seeking on lar)108 711 Q
(ge objects.)-.198 E/F5 11/Times-Bold@0 SF(62)282.5 756 Q EP
%%Page: 63 63
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(13.3.1. Cr)72 97.2 R(eating a Lar)-.216 E
(ge Object)-.12 E/F1 11/Times-Roman@0 SF(The routine)108 114.3 Q/F2 10
/Courier@0 SF(Oid lo_creat\(PGconn *conn, int mode\))148 139.5 Q F1 .042
(creates a ne)108 165.7 R 2.792(wl)-.275 G(ar)-2.792 E .042
(ge object. The)-.198 F/F3 11/Times-Italic@0 SF(mode)2.792 E F1 .043
(is a bitmask describing se)2.792 F -.165(ve)-.275 G .043(ral dif).165 F
.043(ferent attrib)-.275 F .043(utes of)-.22 F(the ne)108 178.9 Q 2.75
(wo)-.275 G 2.75(bject. The)-2.75 F
(symbolic constants listed here are de\214ned in)2.75 E F2
(/usr/local/postgres95/src/backend/libpq/libpq-fs.h)148 204.1 Q F1 .084
(The access type \(read, write, or both\) is controlled by)108 230.3 R
/F4 10/Times-Roman@0 SF(OR)2.834 E F1 .084(ing together the bits)2.834 F
F4(INV_READ)2.834 E F1(and)108 243.5 Q F4(INV_WRITE)2.845 E F1 5.595(.I)
C 2.845(ft)-5.595 G .095(he lar)-2.845 F .095(ge object should be archi)
-.198 F -.165(ve)-.275 G 2.845(d\212t).165 G .095
(hat is, if historical v)-2.845 F .096(ersions of)-.165 F .934
(it should be mo)108 256.7 R -.165(ve)-.165 G 3.684(dp).165 G .933
(eriodically to a special archi)-3.684 F 1.263 -.165(ve r)-.275 H .933
(elation \212 then the).165 F F4(INV_ARCHIVE)3.683 E F1 .369
(bit should be set.)108 269.9 R .369(The lo)5.869 F .37
(w-order sixteen bits of)-.275 F F3(mask)3.12 E F1 .37
(are the storage manager number on)3.12 F 1.894(which the lar)108 283.1
R 1.894(ge object should reside.)-.198 F -.165(Fo)7.394 G 4.644(rs).165
G 1.894(ites other than Berk)-4.644 F(ele)-.11 E 3.323 -.715(y, t)-.165
H 1.893(hese bits should).715 F(al)108 296.3 Q -.11(wa)-.11 G
(ys be zero.).11 E(The commands belo)108 313.4 Q 2.75(wc)-.275 G
(reate an \(In)-2.75 E -.165(ve)-.44 G(rsion\) lar).165 E(ge object:)
-.198 E F2(inv_oid = lo_creat\(INV_READ|INV_WRITE|INV_ARCHIVE\);)148
338.6 Q F0 3(13.3.2. Importing)72 377.8 R 3(aL)3 G(ar)-3 E(ge Object)
-.12 E F1 1.76 -.88(To i)9 H(mport a UNIX \214le as a lar).88 E
(ge object, call)-.198 E F2(Oid)148 403 Q
(lo_import\(PGconn *conn, text *filename\))148 415.2 Q F1(The)108 441.4
Q F3(\214lename)3.168 E F1(ar)3.168 E .419(gument speci\214es the UNIX \
pathname of the \214le to be imported as a lar)-.198 F(ge)-.198 E
(object.)108 454.6 Q F0 3(13.3.3. Exporting)72 480.8 R 3(aL)3 G(ar)-3 E
(ge Object)-.12 E F1 1.76 -.88(To e)9 H(xport a lar).715 E
(ge object into UNIX \214le, call)-.198 E F2(int)148 506 Q
(lo_export\(PGconn *conn, Oid lobjId, text *filename\))148 518.2 Q F1
(The)108 544.4 Q F3(lobjId)3.071 E F1(ar)3.071 E .321
(gument speci\214es the Oid of the lar)-.198 F .32(ge object to e)-.198
F .32(xport and the)-.165 F F3(\214lename)3.07 E F1(ar)3.07 E(gu-)-.198
E(ment speci\214es the UNIX pathname of the \214le.)108 557.6 Q F0 3
(13.3.4. Opening)72 583.8 R(an Existing Lar)3 E(ge Object)-.12 E F1 1.76
-.88(To o)108 600.9 T(pen an e).88 E(xisting lar)-.165 E
(ge object, call)-.198 E F2(int)148 626.1 Q
(lo_open\(PGconn *conn, Oid lobjId, int mode, ...\))148 638.3 Q F1(The)
108 664.5 Q F3(lobjId)3.207 E F1(ar)3.207 E .457
(gument speci\214es the Oid of the lar)-.198 F .458(ge object to open.)
-.198 F .458(The mode bits control)5.958 F
(whether the object is opened for reading)108 677.7 Q F4(INV_READ)2.75 E
F1(\), writing or both.)A 4.2(Al)108 694.8 S(ar)-4.2 E 1.45
(ge object cannot be opened before it is created.)-.198 F/F5 11
/Courier@0 SF(lo_open)6.949 E F1 1.449(returns a lar)4.199 F 1.449
(ge object)-.198 F 5.198(descriptor for later use in)108 708 R F5
(lo_read)7.948 E F1(,)A F5(lo_write)7.948 E F1(,)A F5(lo_lseek)7.948 E
F1(,)A F5(lo_tell)7.948 E F1 7.949(,a)C(nd)-7.949 E F5(lo_close)108
721.2 Q F1(.)A/F6 11/Times-Bold@0 SF(63)282.5 756 Q EP
%%Page: 64 64
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(13.3.5. Writing)72 97.2 R(Data to a Lar)3 E
(ge Object)-.12 E/F1 11/Times-Roman@0 SF(The routine)108 114.3 Q/F2 10
/Courier@0 SF(int)148 139.5 Q
(lo_write\(PGconn *conn, int fd, char *buf, int len\))148 151.7 Q F1
(writes)108 177.9 Q/F3 11/Times-Italic@0 SF(len)3.046 E F1 .296
(bytes from)3.046 F F3 -.22(bu)3.046 G(f).22 E F1 .296(to lar)3.046 F
.296(ge object)-.198 F F3(fd)3.046 E F1 5.796(.T)C(he)-5.796 E F3(fd)
3.046 E F1(ar)3.045 E .295(gument must ha)-.198 F .625 -.165(ve b)-.22 H
.295(een returned by).165 F 2.75(ap)108 191.1 S(re)-2.75 E(vious)-.275 E
F3(lo_open)2.75 E F1(.)A .059
(The number of bytes actually written is returned.)108 208.2 R .059
(In the e)5.559 F -.165(ve)-.275 G .059(nt of an error).165 F 2.809(,t)
-.44 G .06(he return v)-2.809 F(alue)-.275 E(is ne)108 221.4 Q -.055(ga)
-.165 G(ti).055 E -.165(ve)-.275 G(.).165 E F0 3(13.3.6. Seeking)72
247.6 R(on a Lar)3 E(ge Object)-.12 E F1 1.76 -.88(To c)108 264.7 T
(hange the current read or write location on a lar).88 E
(ge object, call)-.198 E F2(int)148 289.9 Q
(lo_lseek\(PGconn *conn, int fd, int offset, int whence\))148 302.1 Q F1
.386(This routine mo)108 328.3 R -.165(ve)-.165 G 3.136(st).165 G .386
(he current location pointer for the lar)-3.136 F .386
(ge object described by)-.198 F F3(fd)3.135 E F1 .385(to the)3.135 F(ne)
108 341.5 Q 6.512(wl)-.275 G 3.762(ocation speci\214ed by)-6.512 F F3
(of)6.512 E(fset)-.198 E F1 9.262(.T)C 3.762(he v)-9.262 F 3.762(alid v)
-.275 F 3.762(alues for .i whence are)-.275 F/F4 11/Courier@0 SF
(SEEK_SET)6.512 E(SEEK_CUR)108 354.7 Q F1(and)2.75 E F4(SEEK_END.)2.75 E
F0 3(13.3.7. Closing)72 380.9 R 3(aL)3 G(ar)-3 E(ge Object Descriptor)
-.12 E F1 2.75(Al)108 398 S(ar)-2.75 E
(ge object may be closed by calling)-.198 E F2(int)148 423.2 Q
(lo_close\(PGconn *conn, int fd\))148 435.4 Q F1(where)108 461.6 Q F3
(fd)3.9 E F1 1.15(is a lar)3.9 F 1.15(ge object descriptor returned by)
-.198 F F3(lo_open)3.9 E F1 6.65(.O)C 3.9(ns)-6.65 G(uccess,)-3.9 E F3
(lo_close)3.9 E F1(returns)3.899 E 2.75(zero. On)108 474.8 R(error)2.75
E 2.75(,t)-.44 G(he return v)-2.75 E(alue is ne)-.275 E -.055(ga)-.165 G
(ti).055 E -.165(ve)-.275 G(.).165 E F0 3(13.4. Built)72 491.9 R(in r)3
E(egister)-.216 E(ed functions)-.216 E F1 .182(There are tw)108 509 R
2.932(ob)-.11 G .182(uilt-in re)-3.152 F .182(gistered functions,)-.165
F F3(lo_import)2.932 E F1(and)2.932 E F3(lo_e)2.932 E(xport)-.22 E F1
.182(which are con)2.932 F -.165(ve)-.44 G(nient).165 E
(for use in SQL queries.)108 522.2 Q(Here is an e)108 539.3 Q
(xample of there use)-.165 E F2(CREATE TABLE image \()148 564.5 Q 66
(name text,)196 576.7 R 54(raster oid)196 588.9 R(\);)148 601.1 Q
(INSERT INTO image \(name, raster\))148 625.5 Q
(VALUES \('beautiful image', lo_import\('/etc/motd'\)\);)166 637.7 Q
(SELECT lo_export\(image.raster, "/tmp/motd"\) from image)148 662.1 Q
(WHERE name = 'beautiful image';)166 674.3 Q/F5 11/Times-Bold@0 SF(64)
282.5 756 Q EP
%%Page: 65 65
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 4.583(13.5. Accessing)72 97.2 R(Lar)4.583 E 1.583
(ge Objects fr)-.12 F 1.583(om LIBPQ)-.216 F/F1 11/Times-Roman@0 SF
(Belo)10.582 E 4.332(wi)-.275 G 4.332(sas)-4.332 G 1.582
(ample program which sho)-4.332 F(ws)-.275 E(ho)108 110.4 Q 2.774(wt)
-.275 G .024(he lar)-2.774 F .024(ge object interf)-.198 F .024(ace in)
-.11 F/F2 10/Times-Roman@0 SF(LIBPQ)2.775 E F1 .025(can be used.)2.775 F
-.165(Pa)5.525 G .025(rts of the program are commented).165 F(out b)108
123.6 Q(ut are left in the source for the readers bene\214t.)-.22 E
(This program can be found in)5.5 E/F3 10/Courier@0 SF
(../src/test/examples)148 148.8 Q F1 1.29
(Frontend applications which use the lar)108 178.9 R 1.289
(ge object interf)-.198 F 1.289(ace in)-.11 F F2(LIBPQ)4.039 E F1 1.289
(should include the)4.039 F(header \214le)108 192.1 Q/F4 11/Courier@0 SF
(libpq/libpq-fs.h)2.75 E F1(and link with the)2.75 E F4(libpq)2.75 E F1
(library)2.75 E(.)-.715 E/F5 11/Times-Bold@0 SF(65)282.5 756 Q EP
%%Page: 66 66
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(13.6. Sample)72 97.2 R(Pr)3 E(ogram)-.216 E/F1
10/Courier@0 SF(/*-----------------------------------------------------\
--------------------)148 122.4 Q(*)154 134.6 Q 6(*t)154 146.8 S
(estlo.c--)-6 E 24(*t)154 159 S(est using large objects with libpq)-24 E
(*)154 171.2 Q 6(*C)154 183.4 S
(opyright \(c\) 1994, Regents of the University of California)-6 E(*)154
195.6 Q(*)154 207.8 Q 6(*I)154 220 S(DENTIFICATION)-6 E 24(*$)154 232.2
S(Header: /usr/local/devel/pglite/cvs/src/doc/manual.me,v 1.17 1996/02/\
24 01:19:32 jolly Exp $)-24 E(*)154 244.4 Q(*--------------------------\
-----------------------------------------------)154 256.6 Q(*/)154 268.8
Q(#include <stdio.h>)148 281 Q(#include "libpq-fe.h")148 293.2 Q
(#include "libpq/libpq-fs.h")148 305.4 Q(#define BUFSIZE)148 329.8 Q
(1024)54 E(/*)148 354.2 Q 6(*i)154 366.4 S(mportFile -)-6 E 24(*i)154
378.6 S
(mport file "in_filename" into database as large object "lobjOid")-24 E
(*)154 390.8 Q(*/)154 403 Q
(Oid importFile\(PGconn *conn, char *filename\))148 415.2 Q({)148 427.4
Q(Oid lobjId;)172 439.6 Q(int lobj_fd;)172 451.8 Q(char buf[BUFSIZE];)
172 464 Q(int nbytes, tmp;)172 476.2 Q(int fd;)172 488.4 Q(/*)172 512.8
Q 6(*o)178 525 S(pen the file to be read in)-6 E(*/)178 537.2 Q
(fd = open\(filename, O_RDONLY, 0666\);)172 549.4 Q(if \(fd < 0\))172
561.6 Q 18({/)12 G 6(*e)-18 G(rror */)-6 E
(fprintf\(stderr, "can't open unix file)184 573.8 Q(})172 586 Q(/*)172
610.4 Q 6(*c)178 622.6 S(reate the large object)-6 E(*/)178 634.8 Q
(lobjId = lo_creat\(conn, INV_READ|INV_WRITE\);)172 647 Q
(if \(lobjId == 0\) {)172 659.2 Q
(fprintf\(stderr, "can't create large object"\);)184 671.4 Q(})172 683.6
Q(lobj_fd = lo_open\(conn, lobjId, INV_WRITE\);)172 708 Q(/*)172 720.2 Q
/F2 11/Times-Bold@0 SF(66)282.5 756 Q EP
%%Page: 67 67
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF 6(*r)178 96.2 S
(ead in from the Unix file and write to the inversion file)-6 E(*/)178
108.4 Q(while \(\(nbytes = read\(fd, buf, BUFSIZE\)\) > 0\) {)172 120.6
Q(tmp = lo_write\(conn, lobj_fd, buf, nbytes\);)184 132.8 Q
(if \(tmp < nbytes\) {)184 145 Q(fprintf\(stderr, "error while reading)
208 157.2 Q(})184 169.4 Q(})172 181.6 Q(\(void\) close\(fd\);)172 206 Q
(\(void\) lo_close\(conn, lobj_fd\);)172 218.2 Q(return lobjId;)172
242.6 Q(})148 254.8 Q
(void pickout\(PGconn *conn, Oid lobjId, int start, int len\))148 279.2
Q({)148 291.4 Q(int lobj_fd;)172 303.6 Q(char* buf;)172 315.8 Q
(int nbytes;)172 328 Q(int nread;)172 340.2 Q
(lobj_fd = lo_open\(conn, lobjId, INV_READ\);)172 364.6 Q
(if \(lobj_fd < 0\) {)172 376.8 Q
(fprintf\(stderr,"can't open large object %d",)184 389 Q(lobjId\);)220
401.2 Q(})172 413.4 Q(lo_lseek\(conn, lobj_fd, start, SEEK_SET\);)172
437.8 Q(buf = malloc\(len+1\);)172 450 Q(nread = 0;)172 474.4 Q
(while \(len - nread > 0\) {)172 486.6 Q
(nbytes = lo_read\(conn, lobj_fd, buf, len - nread\);)184 498.8 Q
(buf[nbytes] = ' ';)184 511 Q(fprintf\(stderr,">>> %s", buf\);)184 523.2
Q(nread += nbytes;)184 535.4 Q(})172 547.6 Q(fprintf\(stderr,"0\);)172
559.8 Q(lo_close\(conn, lobj_fd\);)172 572 Q(})148 584.2 Q
(void overwrite\(PGconn *conn, Oid lobjId, int start, int len\))148
608.6 Q({)148 620.8 Q(int lobj_fd;)172 633 Q(char* buf;)172 645.2 Q
(int nbytes;)172 657.4 Q(int nwritten;)172 669.6 Q(int i;)172 681.8 Q
(lobj_fd = lo_open\(conn, lobjId, INV_READ\);)172 706.2 Q
(if \(lobj_fd < 0\) {)172 718.4 Q/F1 11/Times-Bold@0 SF(67)282.5 756 Q
EP
%%Page: 68 68
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(fprintf\(stderr,"can't open large object %d",)184
96.2 Q(lobjId\);)220 108.4 Q(})172 120.6 Q
(lo_lseek\(conn, lobj_fd, start, SEEK_SET\);)172 145 Q
(buf = malloc\(len+1\);)172 157.2 Q(for \(i=0;i<len;i++\))172 181.6 Q
(buf[i] = 'X';)184 193.8 Q(buf[i] = ' ';)172 206 Q(nwritten = 0;)172
230.4 Q(while \(len - nwritten > 0\) {)172 242.6 Q
(nbytes = lo_write\(conn, lobj_fd, buf + nwritten, len - nwritten\);)184
254.8 Q(nwritten += nbytes;)184 267 Q(})172 279.2 Q
(fprintf\(stderr,"0\);)172 291.4 Q(lo_close\(conn, lobj_fd\);)172 303.6
Q(})148 315.8 Q(/*)148 352.4 Q 6(*e)154 364.6 S(xportFile -)-6 E 24(*e)
154 376.8 S(xport large object "lobjOid" to file "out_filename")-24 E(*)
154 389 Q(*/)154 401.2 Q
(void exportFile\(PGconn *conn, Oid lobjId, char *filename\))148 413.4 Q
({)148 425.6 Q(int lobj_fd;)172 437.8 Q(char buf[BUFSIZE];)172 450 Q
(int nbytes, tmp;)172 462.2 Q(int fd;)172 474.4 Q(/*)172 498.8 Q 6(*c)
178 511 S(reate an inversion "object")-6 E(*/)178 523.2 Q
(lobj_fd = lo_open\(conn, lobjId, INV_READ\);)172 535.4 Q
(if \(lobj_fd < 0\) {)172 547.6 Q
(fprintf\(stderr,"can't open large object %d",)184 559.8 Q(lobjId\);)220
572 Q(})172 584.2 Q(/*)172 608.6 Q 6(*o)178 620.8 S
(pen the file to be written to)-6 E(*/)178 633 Q
(fd = open\(filename, O_CREAT|O_WRONLY, 0666\);)172 645.2 Q
(if \(fd < 0\))172 657.4 Q 18({/)12 G 6(*e)-18 G(rror */)-6 E
(fprintf\(stderr, "can't open unix file)184 669.6 Q(filename\);)220
681.8 Q(})172 694 Q(/*)172 718.4 Q/F1 11/Times-Bold@0 SF(68)282.5 756 Q
EP
%%Page: 69 69
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF 6(*r)178 96.2 S
(ead in from the Unix file and write to the inversion file)-6 E(*/)178
108.4 Q
(while \(\(nbytes = lo_read\(conn, lobj_fd, buf, BUFSIZE\)\) > 0\) {)172
120.6 Q(tmp = write\(fd, buf, nbytes\);)184 132.8 Q
(if \(tmp < nbytes\) {)196 145 Q(fprintf\(stderr,"error while writing)
208 157.2 Q(filename\);)244 169.4 Q(})184 181.6 Q(})172 193.8 Q
(\(void\) lo_close\(conn, lobj_fd\);)172 218.2 Q(\(void\) close\(fd\);)
172 230.4 Q(return;)172 254.8 Q(})148 267 Q(void)148 291.4 Q
(exit_nicely\(PGconn* conn\))148 303.6 Q({)148 315.8 Q
(PQfinish\(conn\);)160 328 Q(exit\(1\);)160 340.2 Q(})148 352.4 Q(int)
148 376.8 Q(main\(int argc, char **argv\))148 389 Q({)148 401.2 Q
(char *in_filename, *out_filename;)172 413.4 Q(char *database;)172 425.6
Q(Oid lobjOid;)172 437.8 Q(PGconn *conn;)172 450 Q(PGresult *res;)172
462.2 Q(if \(argc != 4\) {)172 486.6 Q
(fprintf\(stderr, "Usage: %s database_name in_filename out_filename0,)
184 498.8 Q(argv[0]\);)220 511 Q(exit\(1\);)184 523.2 Q(})172 535.4 Q
(database = argv[1];)172 559.8 Q(in_filename = argv[2];)172 572 Q
(out_filename = argv[3];)172 584.2 Q(/*)172 608.6 Q 6(*s)178 620.8 S
(et up the connection)-6 E(*/)178 633 Q
(conn = PQsetdb\(NULL, NULL, NULL, NULL, database\);)172 645.2 Q
(/* check to see that the backend connection was successfully made */)
172 669.6 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)172 681.8 Q
(fprintf\(stderr,"Connection to database '%s' failed.0, database\);)184
694 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)184 706.2 Q
(exit_nicely\(conn\);)184 718.4 Q/F1 11/Times-Bold@0 SF(69)282.5 756 Q
EP
%%Page: 70 70
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(})172 96.2 Q(res = PQexec\(conn, "begin"\);)172
120.6 Q(PQclear\(res\);)172 132.8 Q(printf\("importing file)172 145 Q 6
(/* lobjOid)148 157.2 R 6(=i)6 G(mportFile\(conn, in_filename\); */)-6 E
(lobjOid = lo_import\(conn, in_filename\);)172 169.4 Q(/*)148 181.6 Q
(printf\("as large object %d.0, lobjOid\);)172 193.8 Q
(printf\("picking out bytes 1000-2000 of the large object0\);)172 218.2
Q(pickout\(conn, lobjOid, 1000, 1000\);)172 230.4 Q
(printf\("overwriting bytes 1000-2000 of the large object with X's0\);)
172 254.8 Q(overwrite\(conn, lobjOid, 1000, 1000\);)172 267 Q(*/)148
279.2 Q(printf\("exporting large object to file)172 303.6 Q 18
(/* exportFile\(conn,)148 315.8 R(lobjOid, out_filename\); */)6 E
(lo_export\(conn, lobjOid,out_filename\);)172 328 Q
(res = PQexec\(conn, "end"\);)172 352.4 Q(PQclear\(res\);)172 364.6 Q
(PQfinish\(conn\);)172 376.8 Q(exit\(0\);)172 389 Q(})148 401.2 Q/F1 11
/Times-Bold@0 SF(70)282.5 756 Q EP
%%Page: 71 71
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(14. THE)72 165.4 R(POSTGRES R)4.75 E
(ULE SYSTEM)-.57 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86
178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5
178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119
178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL
135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6
DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5
178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6
174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6
190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5
178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229
178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL
245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6
DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5
178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6
284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6
300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5
178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339
178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL
355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6
DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5
178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6
394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6
410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5
178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449
178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL
465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6
DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5
178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11
/Times-Roman@0 SF 3.372
(Production rule systems are conceptually simple, b)108 208.9 R 3.372
(ut there are man)-.22 F 6.122(ys)-.165 G 3.372(ubtle points)-6.122 F
(in)108 222.1 Q -.22(vo)-.44 G(lv).22 E .603(ed in actually using them.)
-.165 F(Consequently)6.103 E 3.353(,w)-.715 G 3.352(ew)-3.353 G .602
(ill not attempt to e)-3.352 F .602(xplain the actual)-.165 F 2.737
(syntax and operation of the)108 235.3 R/F2 10/Times-Roman@0 SF
(POSTGRES)5.488 E F1 2.738(rule system here.)5.488 F 2.738
(Instead, you should read)8.238 F([ST)108 248.5 Q 1.803(ON90b] to under\
stand some of these points and the theoretical foundations of the)-.198
F F2(POSTGRES)108 261.7 Q F1 2.477
(rule system before trying to use rules.)5.227 F 2.478
(The discussion in this section is)7.977 F .205(intended to pro)108
274.9 R .205(vide an o)-.165 F -.165(ve)-.165 G(rvie).165 E 2.955(wo)
-.275 G 2.954(ft)-2.955 G(he)-2.954 E F2(POSTGRES)2.954 E F1 .204
(rule system and point the user at help-)2.954 F(ful references and e)
108 288.1 Q(xamples.)-.165 E 1.641(The \231query re)108 305.2 R 1.642
(write\232 rule system modi\214es queries to tak)-.275 F 4.392(er)-.11 G
1.642(ules into consideration, and)-4.392 F .518
(then passes the modi\214ed query to the query optimizer for e)108 318.4
R -.165(xe)-.165 G 3.268(cution. It).165 F .517(is v)3.267 F .517
(ery po)-.165 F(werful,)-.275 E .246(and can be used for man)108 331.6 R
2.996(yt)-.165 G .246(hings such as query language procedures, vie)
-2.996 F .246(ws, and v)-.275 F(ersions.)-.165 E(The po)108 344.8 Q
(wer of this rule system is discussed in [ONG90] as well as [ST)-.275 E
(ON90b].)-.198 E/F3 11/Times-Bold@0 SF(71)282.5 756 Q EP
%%Page: 72 72
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(15. ADMINISTERING)72 165.4 R
(POSTGRES)4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6
80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6
97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6
113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5
178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152
178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL
168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6
DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5
178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6
207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6
223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5
178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262
178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL
278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6
DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5
178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6
317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6
333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5
178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372
178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL
388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6
DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5
178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6
427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6
443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5
178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482
178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL
498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF
1.395(In this section, we will discuss aspects of)108 208.9 R/F2 10
/Times-Roman@0 SF(POSTGRES)4.145 E F1 1.394
(that are of interest to those who)4.144 F(mak)108 222.1 Q 3.096(ee)-.11
G(xtensi)-3.261 E .676 -.165(ve u)-.275 H .346(se of).165 F F2(POSTGRES)
3.096 E F1 3.096(,o)C 3.096(rw)-3.096 G .346
(ho are the site administrator for a group of)-3.096 F F2(POST)3.096 E
(-)-.92 E(GRES)108 235.3 Q F1(users.)2.75 E/F3 12/Times-Bold@0 SF 3
(15.1. Fr)72 261.5 R(equent T)-.216 E(asks)-1.104 E 77.5 274.7 72 274.7
DL 80.5 274.7 75 274.7 DL 86 274.7 80.5 274.7 DL 91.5 274.7 86 274.7 DL
97 274.7 91.5 274.7 DL 102.5 274.7 97 274.7 DL 108 274.7 102.5 274.7 DL
113.5 274.7 108 274.7 DL 119 274.7 113.5 274.7 DL 124.5 274.7 119 274.7
DL 130 274.7 124.5 274.7 DL 135.5 274.7 130 274.7 DL 141 274.7 135.5
274.7 DL 146.5 274.7 141 274.7 DL 152 274.7 146.5 274.7 DL 157.5 274.7
152 274.7 DL 163 274.7 157.5 274.7 DL 168.5 274.7 163 274.7 DL 174 274.7
168.5 274.7 DL 179.5 274.7 174 274.7 DL 185 274.7 179.5 274.7 DL 190.5
274.7 185 274.7 DL 196 274.7 190.5 274.7 DL 201.5 274.7 196 274.7 DL 207
274.7 201.5 274.7 DL 212.5 274.7 207 274.7 DL 218 274.7 212.5 274.7 DL
223.5 274.7 218 274.7 DL 229 274.7 223.5 274.7 DL 234.5 274.7 229 274.7
DL 240 274.7 234.5 274.7 DL 245.5 274.7 240 274.7 DL 251 274.7 245.5
274.7 DL 256.5 274.7 251 274.7 DL 262 274.7 256.5 274.7 DL 267.5 274.7
262 274.7 DL 273 274.7 267.5 274.7 DL 278.5 274.7 273 274.7 DL 284 274.7
278.5 274.7 DL 289.5 274.7 284 274.7 DL 295 274.7 289.5 274.7 DL 300.5
274.7 295 274.7 DL 306 274.7 300.5 274.7 DL 311.5 274.7 306 274.7 DL 317
274.7 311.5 274.7 DL 322.5 274.7 317 274.7 DL 328 274.7 322.5 274.7 DL
333.5 274.7 328 274.7 DL 339 274.7 333.5 274.7 DL 344.5 274.7 339 274.7
DL 350 274.7 344.5 274.7 DL 355.5 274.7 350 274.7 DL 361 274.7 355.5
274.7 DL 366.5 274.7 361 274.7 DL 372 274.7 366.5 274.7 DL 377.5 274.7
372 274.7 DL 383 274.7 377.5 274.7 DL 388.5 274.7 383 274.7 DL 394 274.7
388.5 274.7 DL 399.5 274.7 394 274.7 DL 405 274.7 399.5 274.7 DL 410.5
274.7 405 274.7 DL 416 274.7 410.5 274.7 DL 421.5 274.7 416 274.7 DL 427
274.7 421.5 274.7 DL 432.5 274.7 427 274.7 DL 438 274.7 432.5 274.7 DL
443.5 274.7 438 274.7 DL 449 274.7 443.5 274.7 DL 454.5 274.7 449 274.7
DL 460 274.7 454.5 274.7 DL 465.5 274.7 460 274.7 DL 471 274.7 465.5
274.7 DL 476.5 274.7 471 274.7 DL 482 274.7 476.5 274.7 DL 487.5 274.7
482 274.7 DL 493 274.7 487.5 274.7 DL 498.5 274.7 493 274.7 DL 504 274.7
498.5 274.7 DL F1 .405
(Here we will brie\215y discuss some procedures that you should be f)108
305 R .405(amiliar with in manag-)-.11 F(ing an)108 318.2 Q(y)-.165 E F2
(POSTGRES)2.75 E F1(installation.)2.75 E F3 3(15.1.1. Starting)72 344.4
R(the P)3 E(ostmaster)-.24 E F1 .539(If you did not install)108 361.5 R
F2(POSTGRES)3.289 E F1 -.165(ex)3.289 G .538
(actly as described in the installation instructions, you).165 F(may ha)
108 374.7 Q .33 -.165(ve t)-.22 H 2.75(op).165 G
(erform some additional steps before starting the)-2.75 E/F4 11
/Courier@0 SF(postmaster)2.75 E F1(process.)2.75 E 5.5<8345>113.5 391.8
S -.165(ve)-5.5 G 3.135(ni).165 G 3.135(fy)-3.135 G .385
(ou were not the person who installed)-3.135 F F2(POSTGRES)3.136 E F1
3.136(,y)C .386(ou should understand the)-3.136 F 1.448
(installation instructions.)122.85 405 R 1.448
(The installation instructions e)6.948 F 1.448
(xplain some important issues)-.165 F .008(with respect to where)122.85
418.2 R F2(POSTGRES)2.759 E F1 .009
(places some important \214les, proper settings for en)2.759 F(vi-)-.44
E(ronment v)122.85 431.4 Q(ariables, etc. that may v)-.275 E
(ary from one v)-.275 E(ersion of)-.165 E F2(POSTGRES)2.75 E F1
(to another)2.75 E(.)-.605 E 5.5<8359>113.5 444.6 S(ou)-6.71 E/F5 11
/Times-Italic@0 SF(must)4.815 E F1 2.065(start the)4.815 F F4
(postmaster)4.815 E F1 2.064(process with the user)4.814 F 2.064
(-id that o)-.22 F 2.064(wns the installed)-.275 F 1.264
(database \214les.)122.85 457.8 R 1.264(In most cases, if you ha)6.764 F
1.594 -.165(ve f)-.22 H(ollo).165 E 1.264
(wed the installation instructions, this)-.275 F .393
(will be the user \231postgres\232.)122.85 471 R .392
(If you do not start the)5.893 F F4(postmaster)3.142 E F1 .392
(with the right user)3.142 F(-)-.22 E .703(id, the back)122.85 484.2 R
.703(end serv)-.11 F .703(ers that are started by the)-.165 F F4
(postmaster)3.453 E F1 .704(will not be able to read)3.453 F(the data.)
122.85 497.4 Q 5.5<834d>113.5 510.6 S(ak)-5.5 E 3.831(es)-.11 G 1.081
(ure that)-3.831 F F4(/usr/local/postgres95/bin)3.831 E F1 1.08
(is in your shell command path,)3.831 F(because the)122.85 523.8 Q F4
(postmaster)2.75 E F1(will use your)2.75 E F4(PATH)2.75 E F1(to locate)
2.75 E F2(POSTGRES)2.75 E F1(commands.)2.75 E 5.5<8352>113.5 537 S .571
(emember to set the en)-5.5 F .571(vironment v)-.44 F(ariable)-.275 E F4
(PGDATA)3.321 E F1 .571(to the directory where the)3.321 F F2(POST)3.322
E(-)-.92 E(GRES)122.85 550.2 Q F1 .043(databases are installed.)2.794 F
.043(\(This v)5.543 F .043(ariable is more fully e)-.275 F .043
(xplained in the)-.165 F F2(POSTGRES)2.793 E F1
(installation instructions.\))122.85 563.4 Q 5.5<8349>113.5 576.6 S
3.041(fy)-5.5 G .292(ou do start the)-3.041 F F4(postmaster)3.042 E F1
.292(using non-standard options, such as a dif)3.042 F .292(ferent TCP)
-.275 F .052(port number)122.85 589.8 R 2.802(,r)-.44 G .052
(emember to tell all users so that the)-2.802 F 2.802(yc)-.165 G .052
(an set their)-2.802 F F4(PGPORT)2.801 E F1(en)2.801 E(vironment)-.44 E
-.275(va)122.85 603 S(riable correctly).275 E(.)-.715 E F3 3
(15.1.2. Shutting)72 629.2 R(Do)3 E(wn the P)-.12 E(ostmaster)-.24 E F1
.174(If you need to halt the)108 646.3 R F4(postmaster)2.924 E F1 .175
(process, you can use the)2.925 F F2(UNIX)2.925 E F4(kill)2.925 E F1
.175(\(1\) command.)B .445(Some people habitually use the)108 659.5 R F4
(-9)3.195 E F1(or)3.195 E F4(-KILL)3.195 E F1 .445
(option; this should ne)3.195 F -.165(ve)-.275 G 3.194(rb).165 G 3.194
(en)-3.194 G .444(ecessary and)-3.194 F 1.129
(we do not recommend that you do this, as the)108 672.7 R F4(postmaster)
3.879 E F1 1.129(will be unable to free its)3.879 F -.275(va)108 685.9 S
(rious shared resources, its child processes will be unable to e).275 E
(xit gracefully)-.165 E 2.75(,e)-.715 G(tc.)-2.75 E/F6 11/Times-Bold@0
SF(72)282.5 756 Q EP
%%Page: 73 73
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(15.1.3. Adding)72 97.2 R(and Remo)3 E
(ving Users)-.12 E/F1 11/Times-Roman@0 SF(The)108 114.3 Q/F2 11
/Courier@0 SF(createuser)3.748 E F1(and)3.748 E F2(destroyuser)3.748 E
F1 .998(commands enable and disable access to)3.748 F/F3 10
/Times-Roman@0 SF(POST)3.747 E(-)-.92 E(GRES)108 127.5 Q F1
(by speci\214c users on the host system.)2.75 E F0 3(15.1.4. P)72 153.7
R(eriodic Upk)-.24 E(eep)-.12 E F1(The)108 170.8 Q F2(vacuum)2.825 E F1
.075(command should be run on each database periodically)2.825 F 5.575
(.T)-.715 G .076(his command pro-)-5.575 F .532
(cesses deleted instances)108 186.2 R/F4 8/Times-Roman@0 SF(9)-4.4 I F1
.532(and, more importantly)3.282 4.4 N 3.282(,u)-.715 G .532
(pdates the system)-3.282 F/F5 11/Times-Italic@0 SF(statistics)3.281 E
F1(concerning)3.281 E .531(the size of each class.)108 199.4 R .531
(If these statistics are permitted to become out-of-date and inaccu-)
6.031 F .521(rate, the)108 212.6 R F3(POSTGRES)3.271 E F1 .52
(query optimizer may mak)3.271 F 3.27(ee)-.11 G .52
(xtremely poor decisions with respect to)-3.435 F 1.083(query e)108
225.8 R -.275(va)-.275 G 1.083(luation strate).275 F 3.833
(gies. Therefore,)-.165 F 1.083(we recommend running)3.833 F F2(vacuum)
3.834 E F1 -2.365 -.275(ev e)3.834 H 1.084(ry night or).275 F
(so \(perhaps in a script that is e)108 239 Q -.165(xe)-.165 G
(cuted by the).165 E F3(UNIX)2.75 E F2(cron)2.75 E F1(\(1\) or)A F2(at)
2.75 E F1(\(1\) commands\).)A/F6 11/Times-Bold@0 SF .066(Do fr)108 256.1
R .066(equent backups)-.198 F F1 5.565(.T)C .065
(hat is, you should either back up your database directories using)
-5.565 F(the)108 269.3 Q F3(POSTGRES)4.428 E F6(copy)4.428 E F1 1.679
(command and/or the)4.429 F F3(UNIX)4.429 E F2(dump)4.429 E F1 1.679
(\(1\) or)B F2(tar)4.429 E F1 1.679(\(1\) commands.)B -1.21(Yo)7.179 G
(u)1.21 E .45(may think, \231Wh)108 282.5 R 3.2(ya)-.055 G 3.2(mIb)-3.2
G .449(acking up my database?)-3.2 F .449(What about crash reco)5.949 F
-.165(ve)-.165 G 3.199(ry?\232 One).165 F(side)3.199 E(ef)108 295.7 Q
.483(fect of the)-.275 F F3(POSTGRES)3.233 E F1 .483(\231no o)3.233 F
-.165(ve)-.165 G .483
(rwrite\232 storage manager is that it is also a \231no log\232 stor)
.165 F(-)-.22 E 1.793(age manager)108 308.9 R 7.293(.T)-.605 G 1.792(ha\
t is, the database log stores only abort/commit data, and this is not)
-7.293 F .713(enough information to reco)108 322.1 R -.165(ve)-.165 G
3.463(rt).165 G .713
(he database if the storage medium \(disk\) or the database)-3.463 F
1.262(\214les are corrupted!)108 335.3 R 1.261(In other w)6.761 F 1.261
(ords, if a disk block goes bad or)-.11 F F3(POSTGRES)4.011 E F1 1.261
(happens to)4.011 F .486(corrupt a database \214le,)108 348.5 R F6 -.275
(yo)3.236 G 3.236(uc).275 G .486(annot r)-3.236 F(eco)-.198 E -.11(ve)
-.11 G 3.236(rt).11 G .486(hat \214le)-3.236 F F1 5.986(.T)C .486
(his can be disastrous if the \214le is)-5.986 F
(one of the shared catalogs, such as)108 361.7 Q F2(pg_database)2.75 E
F1(.)A F0 3(15.1.5. T)72 387.9 R(uning)-1.104 E F1 .265(Once your users\
start to load a signi\214cant amount of data, you will typically run i\
nto per)108 405 R(-)-.22 E 1.034(formance problems.)108 418.2 R F3
(POSTGRES)6.534 E F1 1.034(is not the f)3.784 F 1.035
(astest DBMS in the w)-.11 F 1.035(orld, b)-.11 F 1.035(ut man)-.22 F
3.785(yo)-.165 G 3.785(ft)-3.785 G(he)-3.785 E -.11(wo)108 431.4 S .19
(rst problems encountered by users are due to their lack of e).11 F .19
(xperience with an)-.165 F 2.94(yD)-.165 G(BMS.)-2.94 E
(Some general tips include:)108 444.6 Q 13.75(\(1\) De\214ne)113.5 461.7
R 2.337(indices o)5.087 F -.165(ve)-.165 G 5.087(ra).165 G(ttrib)-5.087
E 2.338(utes that are commonly used for quali\214cations.)-.22 F -.165
(Fo)7.838 G(r).165 E -.165(ex)142.826 474.9 S(ample, if you often e).165
E -.165(xe)-.165 G(cute queries of the form).165 E/F7 10/Courier@0 SF
(SELECT * from EMP where salary < 5000)182.826 500.1 Q F1 1.478
(then a B-tree inde)142.826 526.3 R 4.228(xo)-.165 G 4.228(nt)-4.228 G
(he)-4.228 E F2(salary)4.227 E F1(attrib)4.227 E 1.477
(ute will probably be useful.)-.22 F 1.477(If scans)6.977 F(in)142.826
539.5 Q -.22(vo)-.44 G(lving equality are more common, as in).22 E F7
(SELECT * from EMP where salary = 5000)182.826 564.7 Q F1 2.063
(then you should consider de\214ning a hash inde)142.826 590.9 R 4.814
(xo)-.165 G(n)-4.814 E F2(salary)4.814 E F1 7.564(.Y)C 2.064
(ou can de\214ne)-8.774 F .202
(both, though it will use more disk space and may slo)142.826 604.1 R
2.951(wd)-.275 G -.275(ow)-2.951 G 2.951(nu).275 G .201(pdates a bit.)
-2.951 F(Scans)5.701 E(using indices are)142.826 617.3 Q F6(much)2.75 E
F1 -.11(fa)2.75 G(ster than sequential scans of the entire class.).11 E
13.75(\(2\) Run)113.5 634.4 R(the)3.882 E F2(vacuum)3.882 E F1 1.132
(command a lot.)3.882 F 1.132
(This command updates the statistics that the)6.632 F .404
(query optimizer uses to mak)142.826 647.6 R 3.154(ei)-.11 G .404
(ntelligent decisions; if the statistics are inaccurate,)-3.154 F .088
(the system will mak)142.826 660.8 R 2.839(ei)-.11 G .089
(nordinately stupid decisions with respect to the w)-2.839 F .089
(ay it joins)-.11 F .32 LW 76 670.4 72 670.4 DL 80 670.4 76 670.4 DL 84
670.4 80 670.4 DL 88 670.4 84 670.4 DL 92 670.4 88 670.4 DL 96 670.4 92
670.4 DL 100 670.4 96 670.4 DL 104 670.4 100 670.4 DL 108 670.4 104
670.4 DL 112 670.4 108 670.4 DL 116 670.4 112 670.4 DL 120 670.4 116
670.4 DL 124 670.4 120 670.4 DL 128 670.4 124 670.4 DL 132 670.4 128
670.4 DL 136 670.4 132 670.4 DL 140 670.4 136 670.4 DL 144 670.4 140
670.4 DL 148 670.4 144 670.4 DL 152 670.4 148 670.4 DL 156 670.4 152
670.4 DL 160 670.4 156 670.4 DL 164 670.4 160 670.4 DL 168 670.4 164
670.4 DL 172 670.4 168 670.4 DL 176 670.4 172 670.4 DL 180 670.4 176
670.4 DL 184 670.4 180 670.4 DL 188 670.4 184 670.4 DL 192 670.4 188
670.4 DL 196 670.4 192 670.4 DL 200 670.4 196 670.4 DL 204 670.4 200
670.4 DL 208 670.4 204 670.4 DL 212 670.4 208 670.4 DL 216 670.4 212
670.4 DL/F8 5/Times-Roman@0 SF(9)93.6 680.8 Q F4 .195(This may mean dif)
2.195 3.2 N .195(ferent things depending on the)-.2 F/F9 8
/Times-Italic@0 SF(ar)2.195 E -.12(ch)-.296 G .195(ive mode).12 F F4
.195(with which each class has been created.)2.195 F(Ho)4.195 E(we)-.2 E
-.12(ve)-.2 G .835 -.32(r, t).12 H .195(he current).32 F .759
(implementation of the)72 693.6 R/F10 8/Courier@0 SF(vacuum)2.759 E F4
.759(command does)2.759 F F9(not)2.759 E F4 .759(perform an)2.759 F
2.759(yc)-.12 G .759(ompaction or clustering of data.)-2.759 F .76
(Therefore, the)4.76 F/F11 7/Times-Roman@0 SF(UNIX)2.76 E F4 .76
(\214les which)2.76 F(store each)72 703.2 Q F11(POSTGRES)2 E F4
(class ne)2 E -.12(ve)-.2 G 2(rs).12 G
(hrink and the space \231reclaimed\232 by)-2 E F10(vacuum)2 E F4(is ne)2
E -.12(ve)-.2 G 2(ra).12 G(ctually reused.)-2 E F6(73)282.5 756 Q EP
%%Page: 74 74
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF(and scans classes.)142.826 97.2 Q 13.75
(\(3\) When)113.5 114.3 R 1.381
(specifying query qual\214cations \(i.e., the)4.131 F/F1 11/Courier@0 SF
(where)4.131 E F0 1.38(part of the query\), try to)4.13 F 2.234
(ensure that a clause in)142.826 127.5 R -.22(vo)-.44 G 2.235
(lving a constant can be turned into one of the form).22 F/F2 11
/Times-Italic@0 SF -.165(ra)142.826 140.7 S(ng).165 E(e_variable oper)
-.11 E(ator constant)-.165 E F0 2.75(,e)C(.g.,)-2.75 E/F3 10/Courier@0
SF(EMP.salary = 5000)182.826 165.9 Q F0(The)142.826 192.1 Q/F4 10
/Times-Roman@0 SF(POSTGRES)3.184 E F0 .433
(query optimizer will only use an inde)3.184 F 3.183(xw)-.165 G .433
(ith a constant quali\214ca-)-3.183 F(tion of this form.)142.826 205.3 Q
(It doesn')5.5 E 2.75(th)-.198 G(urt to write the clause as)-2.75 E F3
(5000 = EMP.salary)182.826 230.5 Q F0 .779
(if the operator \(in this case,)142.826 256.7 R F1(=)3.529 E F0 3.53
(\)h)C .78(as a)-3.53 F F2(commutator)3.53 E F0 .78
(operator de\214ned so that)3.53 F F4(POST)3.53 E(-)-.92 E(GRES)142.826
269.9 Q F0 .784(can re)3.534 F .784
(write the query into the desired form.)-.275 F(Ho)6.284 E(we)-.275 E
-.165(ve)-.275 G 1.664 -.44(r, i).165 H 3.534(fs).44 G .783
(uch an operator)-3.534 F(does not e)142.826 283.1 Q(xist,)-.165 E F4
(POSTGRES)2.75 E F0(will ne)2.75 E -.165(ve)-.275 G 2.75(rc).165 G
(onsider the use of an inde)-2.75 E(x.)-.165 E 13.75(\(4\) When)113.5
300.2 R .152(joining se)2.902 F -.165(ve)-.275 G .152
(ral classes together in one query).165 F 2.902(,t)-.715 G .153
(ry to write the join clauses in)-2.902 F 2.75<6199>142.826 313.4 S
(chained\232 form, e.g.,)-2.75 E F3
(where A.a = B.b and B.b = C.c and ...)182.826 338.6 Q F0 .795
(Notice that relati)142.826 364.8 R -.165(ve)-.275 G .795(ly fe).165 F
3.545(wc)-.275 G .795(lauses refer to a gi)-3.545 F -.165(ve)-.275 G
3.544(nc).165 G .794(lass and attrib)-3.544 F .794(ute; the clauses)-.22
F 1.628(form a linear sequence connecting the attrib)142.826 378 R 1.628
(utes, lik)-.22 F 4.378(el)-.11 G 1.628(inks in a chain.)-4.378 F 1.628
(This is)7.128 F
(preferable to a query written in a \231star\232 form, such as)142.826
391.2 Q F3(where A.a = B.b and A.a = C.c and ...)182.826 416.4 Q F0
2.321(Here, man)142.826 442.6 R 5.071(yc)-.165 G 2.321
(lauses refer to the same class and attrib)-5.071 F 2.321
(ute \(in this case,)-.22 F F1(A.a)5.071 E F0(\).)A 1.108
(When presented with a query of this form, the)142.826 455.8 R F4
(POSTGRES)3.858 E F0 1.108(query optimizer will)3.858 F
(tend to consider f)142.826 469 Q
(ar more choices than it should and may run out of memory)-.11 E(.)-.715
E 13.75(\(5\) If)113.5 486.1 R 1.684
(you are really desperate to see what query plans look lik)4.434 F 1.683
(e, you can run the)-.11 F F1(postmaster)142.826 499.3 Q F0 1.258
(with the)4.008 F F1(-d)4.008 E F0 1.259(option and then run)4.008 F F1
(monitor)4.009 E F0 1.259(with the)4.009 F F1(-t)4.009 E F0(option.)
4.009 E .246
(The format in which query plans will be printed is hard to read b)
142.826 512.5 R .246(ut you should be)-.22 F(able to tell whether an)
142.826 525.7 Q 2.75(yi)-.165 G(nde)-2.75 E 2.75(xs)-.165 G
(cans are being performed.)-2.75 E/F5 12/Times-Bold@0 SF 3(15.2. Infr)72
551.9 R(equent T)-.216 E(asks)-1.104 E .44 LW 77.5 565.1 72 565.1 DL
80.5 565.1 75 565.1 DL 86 565.1 80.5 565.1 DL 91.5 565.1 86 565.1 DL 97
565.1 91.5 565.1 DL 102.5 565.1 97 565.1 DL 108 565.1 102.5 565.1 DL
113.5 565.1 108 565.1 DL 119 565.1 113.5 565.1 DL 124.5 565.1 119 565.1
DL 130 565.1 124.5 565.1 DL 135.5 565.1 130 565.1 DL 141 565.1 135.5
565.1 DL 146.5 565.1 141 565.1 DL 152 565.1 146.5 565.1 DL 157.5 565.1
152 565.1 DL 163 565.1 157.5 565.1 DL 168.5 565.1 163 565.1 DL 174 565.1
168.5 565.1 DL 179.5 565.1 174 565.1 DL 185 565.1 179.5 565.1 DL 190.5
565.1 185 565.1 DL 196 565.1 190.5 565.1 DL 201.5 565.1 196 565.1 DL 207
565.1 201.5 565.1 DL 212.5 565.1 207 565.1 DL 218 565.1 212.5 565.1 DL
223.5 565.1 218 565.1 DL 229 565.1 223.5 565.1 DL 234.5 565.1 229 565.1
DL 240 565.1 234.5 565.1 DL 245.5 565.1 240 565.1 DL 251 565.1 245.5
565.1 DL 256.5 565.1 251 565.1 DL 262 565.1 256.5 565.1 DL 267.5 565.1
262 565.1 DL 273 565.1 267.5 565.1 DL 278.5 565.1 273 565.1 DL 284 565.1
278.5 565.1 DL 289.5 565.1 284 565.1 DL 295 565.1 289.5 565.1 DL 300.5
565.1 295 565.1 DL 306 565.1 300.5 565.1 DL 311.5 565.1 306 565.1 DL 317
565.1 311.5 565.1 DL 322.5 565.1 317 565.1 DL 328 565.1 322.5 565.1 DL
333.5 565.1 328 565.1 DL 339 565.1 333.5 565.1 DL 344.5 565.1 339 565.1
DL 350 565.1 344.5 565.1 DL 355.5 565.1 350 565.1 DL 361 565.1 355.5
565.1 DL 366.5 565.1 361 565.1 DL 372 565.1 366.5 565.1 DL 377.5 565.1
372 565.1 DL 383 565.1 377.5 565.1 DL 388.5 565.1 383 565.1 DL 394 565.1
388.5 565.1 DL 399.5 565.1 394 565.1 DL 405 565.1 399.5 565.1 DL 410.5
565.1 405 565.1 DL 416 565.1 410.5 565.1 DL 421.5 565.1 416 565.1 DL 427
565.1 421.5 565.1 DL 432.5 565.1 427 565.1 DL 438 565.1 432.5 565.1 DL
443.5 565.1 438 565.1 DL 449 565.1 443.5 565.1 DL 454.5 565.1 449 565.1
DL 460 565.1 454.5 565.1 DL 465.5 565.1 460 565.1 DL 471 565.1 465.5
565.1 DL 476.5 565.1 471 565.1 DL 482 565.1 476.5 565.1 DL 487.5 565.1
482 565.1 DL 493 565.1 487.5 565.1 DL 498.5 565.1 493 565.1 DL 504 565.1
498.5 565.1 DL F0 .029(At some time or another)108 595.4 R 2.779(,e)-.44
G -.165(ve)-3.054 G(ry).165 E F4(POSTGRES)2.778 E F0 .028
(site administrator has to perform all of the fol-)2.778 F(lo)108 608.6
Q(wing actions.)-.275 E F5 3(15.2.1. Cleaning)72 634.8 R
(Up After Crashes)3 E F0(The)108 651.9 Q F1(postgres)3.101 E F0(serv)
3.101 E .351(er and the)-.165 F F1(postmaster)3.101 E F0 .351(run as tw)
3.101 F 3.101(od)-.11 G(if)-3.101 E .351(ferent processes.)-.275 F(The)
5.851 E 3.102(ym)-.165 G(ay)-3.102 E 1.494(crash separately or together)
108 665.1 R 6.993(.T)-.605 G 1.493(he housek)-6.993 F 1.493
(eeping procedures required to \214x one kind of)-.11 F(crash are dif)
108 678.3 Q(ferent from those required to \214x the other)-.275 E(.)
-.605 E(The message you will usually see when the back)108 695.4 Q
(end serv)-.11 E(er crashes is:)-.165 E F3
(FATAL: no response from backend: detected in ...)148 720.6 Q/F6 11
/Times-Bold@0 SF(74)282.5 756 Q EP
%%Page: 75 75
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF .584(This generally means one of tw)108 97.2 R
3.334(ot)-.11 G .584(hings: there is a b)-3.334 F .584(ug in the)-.22 F
/F1 10/Times-Roman@0 SF(POSTGRES)3.334 E F0(serv)3.334 E(er)-.165 E
3.335(,o)-.44 G 3.335(rt)-3.335 G(here)-3.335 E .003(is a b)108 110.4 R
.003(ug in some user code that has been dynamically loaded into)-.22 F
F1(POSTGRES)2.752 E F0 5.502(.Y)C .002(ou should)-6.712 F .823
(be able to restart your application and resume processing, b)108 123.6
R .824(ut there are some considera-)-.22 F(tions:)108 136.8 Q(\(1\))
113.5 153.9 Q F1(POSTGRES)16.5 E F0 1.694
(usually dumps a core \214le \(a snapshot of process memory used for)
4.444 F(deb)142.826 167.1 Q(ugging\) in the database directory)-.22 E/F2
10/Courier@0 SF(/usr/local/postgres95/data/base/<database>/core)182.826
192.3 Q F0 .478(on the serv)142.826 218.5 R .479(er machine.)-.165 F
.479(If you don')5.979 F 3.229(tw)-.198 G .479(ant to try to deb)-3.339
F .479(ug the problem or produce)-.22 F 3.399(as)142.826 231.7 S .649
(tack trace to report the b)-3.399 F .648
(ug to someone else, you can delete this \214le \(which is)-.22 F
(probably around 10MB\).)142.826 244.9 Q 13.75(\(2\) When)113.5 262 R
.576(one back)3.326 F .576(end crashes in an uncontrolled w)-.11 F .577
(ay \(i.e., without calling its b)-.11 F(uilt-)-.22 E .64
(in cleanup routines\), the)142.826 275.2 R/F3 11/Courier@0 SF
(postmaster)3.39 E F0 .64(will detect this situation, kill all running)
3.39 F(serv)142.826 288.4 Q 2.589
(ers and reinitialize the state shared among all back)-.165 F 2.589
(ends \(e.g., the shared)-.11 F -.22(bu)142.826 301.6 S -.275(ff).22 G
1.61(er pool and locks\).).275 F 1.61(If your serv)7.11 F 1.609
(er crashed, you will get the \231no response\232)-.165 F 1.132
(message sho)142.826 314.8 R 1.132(wn abo)-.275 F -.165(ve)-.165 G 6.632
(.I).165 G 3.882(fy)-6.632 G 1.132(our serv)-3.882 F 1.132(er w)-.165 F
1.132(as killed because someone else')-.11 F 3.882(ss)-.605 G(erv)-3.882
E(er)-.165 E(crashed, you will see the follo)142.826 328 Q
(wing message:)-.275 E F2 6(Ih)182.826 353.2 S
(ave been signalled by the postmaster.)-6 E
(Some backend process has died unexpectedly and possibly)182.826 365.4 Q
(corrupted shared memory.)182.826 377.6 Q(The current transaction was)12
E(aborted, and I am going to exit.)182.826 389.8 Q(Please resend the)12
E(last query. -- The postgres backend)182.826 402 Q F0 13.75
(\(3\) Sometimes)113.5 432.1 R .371
(shared state is not completely cleaned up.)3.121 F .37
(Frontend applications may)5.87 F(see errors of the form:)142.826 445.3
Q F2(WARN: cannot write block 34 of myclass [mydb] blind)182.826 470.5 Q
F0(In this case, you should kill the)142.826 496.7 Q F3(postmaster)2.75
E F0(and restart it.)2.75 E 13.75(\(4\) When)113.5 513.8 R .541(the sys\
tem crashes while updating the system catalogs \(e.g., when you are)3.29
F .581(creating a class, de\214ning an inde)142.826 527 R .581
(x, retrie)-.165 F .58(ving into a class, etc.\) the B-tree indices)
-.275 F .986(de\214ned on the catalogs are sometimes corrupted.)142.826
540.2 R .987(The general \(and non-unique\))6.487 F .363
(symptom is that)142.826 553.4 R/F4 11/Times-Bold@0 SF(all)3.113 E F0
.363(queries stop w)3.113 F 3.113(orking. If)-.11 F .363(you ha)3.113 F
.693 -.165(ve t)-.22 H .363(ried all of the abo).165 F .693 -.165(ve s)
-.165 H(teps).165 E .231(and nothing else seems to w)142.826 566.6 R
.231(ork, try using the)-.11 F F3(reindexdb)2.981 E F0 2.981
(command. If)2.981 F F3(rein-)2.981 E(dexdb)142.826 579.8 Q F0 .293
(succeeds b)3.043 F .293(ut things still don')-.22 F 3.043(tw)-.198 G
.293(ork, you ha)-3.153 F .623 -.165(ve a)-.22 H .292
(nother problem; if it f).165 F(ails,)-.11 E .084
(the system catalogs themselv)142.826 593 R .084
(es were almost certainly corrupted and you will ha)-.165 F -.165(ve)
-.22 G(to go back to your backups.)142.826 606.2 Q(The)108 623.3 Q F3
(postmaster)3.443 E F0 .693(does not usually crash \(it doesn')3.443 F
3.443(td)-.198 G 3.443(ov)-3.443 G .693(ery much e)-3.608 F .693
(xcept start serv)-.165 F(ers\))-.165 E -.22(bu)108 636.5 S 4.052(ti).22
G 4.052(td)-4.052 G 1.302(oes happen on occasion.)-4.052 F 1.302
(In addition, there are a fe)6.802 F 4.053(wc)-.275 G 1.303
(ases where it encounters)-4.053 F .574
(problems during the reinitialization of shared resources.)108 649.7 R
(Speci\214cally)6.074 E 3.324(,t)-.715 G .574(here are race con-)-3.324
F .482(ditions where the operating system lets the)108 662.9 R F3
(postmaster)3.232 E F0 .482(free shared resources b)3.232 F .483
(ut then)-.22 F .788(will not permit it to reallocate the same amount o\
f shared resources \(e)108 676.1 R -.165(ve)-.275 G 3.538(nw).165 G .788
(hen there is)-3.538 F(no contention\).)108 689.3 Q -1.21(Yo)108 706.4 S
5.278(uw)1.21 G 2.528(ill typically ha)-5.278 F 2.858 -.165(ve t)-.22 H
5.278(or).165 G 2.528(un the)-5.278 F F3(ipcclean)5.278 E F0 2.529
(command if system errors cause the)5.278 F F3(postmaster)108 719.6 Q F0
3.334(to crash.)6.084 F 3.333
(If this happens, you may \214nd \(using the)8.833 F F1(UNIX)6.083 E F3
(ipcs)6.083 E F0(\(1\))A F4(75)282.5 756 Q EP
%%Page: 76 76
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF .354(command\) that the \231postgres\232 user h\
as shared memory and/or semaphores allocated e)108 97.2 R -.165(ve)-.275
G(n).165 E .265(though no)108 110.4 R/F1 11/Courier@0 SF(postmaster)
3.015 E F0 .265(process is running.)3.015 F .265
(In this case, you should run)5.765 F F1(ipcclean)3.014 E F0(as)3.014 E
2.671(the \231postgres\232 user in order to deallocate these resources.)
108 123.6 R 2.672(Be w)8.171 F 2.672(arned that)-.11 F/F2 11
/Times-Italic@0 SF(all)5.422 E F0(such)5.422 E .269(resources o)108
136.8 R .268(wned by the \231postgres\232 user will be deallocated.)
-.275 F .268(If you ha)5.768 F .598 -.165(ve m)-.22 H(ultiple).165 E F1
(post-)3.018 E(master)108 150 Q F0 .383(processes running on the same m\
achine, you should kill all of them before run-)3.133 F(ning)108 163.2 Q
F1(ipcclean)2.913 E F0 .163(\(otherwise, the)2.913 F 2.913(yw)-.165 G
.163(ill crash on their o)-2.913 F .162
(wn when their shared resources are)-.275 F(suddenly deallocated\).)108
176.4 Q/F3 12/Times-Bold@0 SF 3(15.2.2. Mo)72 202.6 R(ving Database Dir)
-.12 E(ectories)-.216 E F0 4.764(By def)108 219.7 R 4.764(ault, all)-.11
F/F4 10/Times-Roman@0 SF(POSTGRES)7.515 E F0 4.765
(databases are stored in separate subdirectories under)7.515 F F1
(/usr/local/postgres95/data/base)108 235.1 Q F0(.)A/F5 8/Times-Roman@0
SF(10)-4.4 I F0 1.688(At some point, you may \214nd that you)4.438 4.4 N
.8(wish to mo)108 248.3 R 1.13 -.165(ve o)-.165 H .799(ne or more datab\
ases to another location \(e.g., to a \214lesystem with more).165 F
(free space\).)108 261.5 Q(If you wish to mo)108 278.6 Q -.165(ve)-.165
G F2(all)2.915 E F0(of your databases to the ne)2.75 E 2.75(wl)-.275 G
(ocation, you can simply:)-2.75 E 5.5<834b>113.5 295.7 S(ill the)-5.5 E
F1(postmaster)2.75 E F0(.)A 5.5<8343>113.5 308.9 S(op)-5.5 E 2.838(yt)
-.11 G .088(he entire)-2.838 F F1(data)2.838 E F0 .089
(directory to the ne)2.838 F 2.839(wl)-.275 G .089
(ocation \(making sure that the ne)-2.839 F 2.839<778c>-.275 G .089
(les are)-2.839 F -.275(ow)122.85 322.1 S
(ned by user \231postgres\232\).).275 E/F6 10/Courier@0 SF 6(%c)162.85
347.3 S 6(p-)-6 G(rp /usr/local/postgres95/data /new/place/data)-6 E F0
5.5<8352>113.5 373.5 S .773(eset your)-5.5 F F1(PGDATA)3.523 E F0(en)
3.523 E .773(vironment v)-.44 F .773
(ariable \(as described earlier in this manual and in)-.275 F
(the installation instructions\).)122.85 386.7 Q F6 6(#u)162.85 411.9 S
(sing csh or tcsh...)-6 E 6(%s)162.85 424.1 S
(etenv PGDATA /new/place/data)-6 E 6(#u)162.85 448.5 S
(sing sh, ksh or bash...)-6 E 6(%P)162.85 460.7 S
(GDATA=/new/place/data; export PGDATA)-6 E F0 5.5<8352>113.5 486.9 S
(estart the)-5.5 E F1(postmaster)2.75 E F0(.)A F6 6(%p)162.85 512.1 S
(ostmaster &)-6 E F0 5.5<8341>113.5 538.3 S 1.129
(fter you run some queries and are sure that the ne)-5.5 F(wly-mo)-.275
E -.165(ve)-.165 G 3.879(dd).165 G 1.129(atabase w)-3.879 F 1.129
(orks, you)-.11 F(can remo)122.85 551.5 Q .33 -.165(ve t)-.165 H(he old)
.165 E F1(data)2.75 E F0(directory)2.75 E(.)-.715 E F6 6(%r)162.85 576.7
S 6(m-)-6 G(rf /usr/local/postgres95/data)-6 E F0 2.673 -.88(To i)108
606.8 T .913(nstall a).88 F F2(single)3.663 E F0 .913
(database in an alternate directory while lea)3.663 F .913
(ving all other databases in)-.22 F(place, do the follo)108 620 Q(wing:)
-.275 E 5.5<8343>113.5 637.1 S .81(reate the database \(if it doesn')
-5.5 F 3.561(ta)-.198 G .811(lready e)-3.561 F .811(xist\) using the)
-.165 F/F7 11/Times-Bold@0 SF(cr)3.561 E(eatedb)-.198 E F0 3.561
(command. In)3.561 F(the)3.561 E(follo)122.85 650.3 Q
(wing steps we will assume the database is named)-.275 E F1(foo)2.75 E
F0(.)A .32 LW 76 667.4 72 667.4 DL 80 667.4 76 667.4 DL 84 667.4 80
667.4 DL 88 667.4 84 667.4 DL 92 667.4 88 667.4 DL 96 667.4 92 667.4 DL
100 667.4 96 667.4 DL 104 667.4 100 667.4 DL 108 667.4 104 667.4 DL 112
667.4 108 667.4 DL 116 667.4 112 667.4 DL 120 667.4 116 667.4 DL 124
667.4 120 667.4 DL 128 667.4 124 667.4 DL 132 667.4 128 667.4 DL 136
667.4 132 667.4 DL 140 667.4 136 667.4 DL 144 667.4 140 667.4 DL 148
667.4 144 667.4 DL 152 667.4 148 667.4 DL 156 667.4 152 667.4 DL 160
667.4 156 667.4 DL 164 667.4 160 667.4 DL 168 667.4 164 667.4 DL 172
667.4 168 667.4 DL 176 667.4 172 667.4 DL 180 667.4 176 667.4 DL 184
667.4 180 667.4 DL 188 667.4 184 667.4 DL 192 667.4 188 667.4 DL 196
667.4 192 667.4 DL 200 667.4 196 667.4 DL 204 667.4 200 667.4 DL 208
667.4 204 667.4 DL 212 667.4 208 667.4 DL 216 667.4 212 667.4 DL/F8 5
/Times-Roman@0 SF(10)93.6 677.8 Q F5 .324
(Data for certain classes may stored else)2.324 3.2 N .324
(where if a non-standard storage manager w)-.2 F .324
(as speci\214ed when the)-.08 F 2.323(yw)-.12 G .323(ere created.)-2.323
F(Use)4.323 E(of non-standard storage managers is an e)72 690.6 Q
(xperimental feature that is not supported outside of Berk)-.12 E(ele)
-.08 E -.52(y.)-.12 G F7(76)282.5 756 Q EP
%%Page: 77 77
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF 5.5<834b>113.5 97.2 S(ill the)-5.5 E/F1 11
/Courier@0 SF(postmaster)2.75 E F0(.)A 5.5<8343>113.5 110.4 S(op)-5.5 E
4.575(yt)-.11 G 1.824(he directory)-4.575 F F1
(/usr/local/postgres95/data/base/foo)4.574 E F0 1.824(and its con-)4.574
F(tents to its ultimate destination.)122.85 123.6 Q
(It should still be o)5.5 E(wned by the \231postgres\232 user)-.275 E(.)
-.605 E/F2 10/Courier@0 SF 6(%c)162.85 148.8 S 6(p-)-6 G
(rp /usr/local/postgres95/data/base/foo /new/place/foo)-6 E F0 5.5<8352>
113.5 175 S(emo)-5.5 E .33 -.165(ve t)-.165 H(he directory).165 E F1
(/usr/local/postgres95/data/base/foo)2.75 E F0(:)A F2 6(%r)162.85 200.2
S 6(m-)-6 G(rf /usr/local/postgres95/data/base/foo)-6 E F0 5.5<834d>
113.5 226.4 S(ak)-5.5 E 3.48(eas)-.11 G .73(ymbolic link from)-3.48 F F1
(/usr/local/postgres95/data/base)3.48 E F0 .73(to the ne)3.48 F(w)-.275
E(directory:)122.85 239.6 Q F2 6(%l)162.85 264.8 S 6(n-)-6 G 6(s/)-6 G
(new/place/foo /usr/local/postgres95/data/base/foo)-6 E F0 5.5<8352>
113.5 291 S(estart the)-5.5 E F1(postmaster)2.75 E F0(.)A/F3 12
/Times-Bold@0 SF 3(15.2.3. Updating)72 317.2 R(Databases)3 E/F4 10
/Times-Roman@0 SF(POSTGRES)108 334.3 Q F0 .679(is a research system.)
3.429 F .679(In general,)6.179 F F4(POSTGRES)3.429 E F0 .679
(may not retain the same binary)3.429 F .715
(format for the storage of databases from release to release.)108 347.5
R .715(Therefore, when you update)6.215 F(your)108 360.7 Q F4(POSTGRES)
2.8 E F0(softw)2.8 E .05(are, you will probably ha)-.11 F .38 -.165
(ve t)-.22 H 2.8(om).165 G .049(odify your databases as well.)-2.8 F
(This)5.549 E .248(is a common occurrence with commercial database syst\
ems as well; unfortunately)108 373.9 R 2.998(,u)-.715 G(nlik)-2.998 E(e)
-.11 E .598(commercial systems,)108 387.1 R F4(POSTGRES)3.348 E F0 .598
(does not come with user)3.348 F .597(-friendly utilities to mak)-.22 F
3.347(ey)-.11 G(our)-3.347 E(life easier when these updates occur)108
400.3 Q(.)-.605 E .171(In general, you must do the follo)108 417.4 R
.172(wing to update your databases to a ne)-.275 F 2.922(ws)-.275 G
(oftw)-2.922 E .172(are release:)-.11 F<83>113.5 434.5 Q/F5 11
/Times-Italic@0 SF(Extensions)5.5 E F0 1.073(\(such as user)3.823 F
1.073(-de\214ned types, functions, aggre)-.22 F -.055(ga)-.165 G 1.072
(tes, etc.\) must be reloaded).055 F(by re-e)122.85 447.7 Q -.165(xe)
-.165 G(cuting the SQL).165 E/F6 11/Times-Bold@0 SF(CREA)2.75 E(TE)
-1.045 E F0 2.75(commands. See)2.75 F(Appendix A for more details.)2.75
E<83>113.5 460.9 Q F5(Data)5.5 E F0 1.08
(must be dumped from the old classes into ASCII \214les \(using the)
3.829 F F6(COPY)3.83 E F0(com-)3.83 E .235(mand\), the ne)122.85 474.1 R
2.985(wc)-.275 G .235(lasses created in the ne)-2.985 F 2.985(wd)-.275 G
.234(atabase \(using the)-2.985 F F6(CREA)2.984 E(TE)-1.045 E F0 -1.023
(TA)C .234(BLE com-)1.023 F
(mand\), and the data reloaded from the ASCII \214les.)122.85 487.3 Q
<83>113.5 500.5 Q F5(Rules)5.5 E F0(and)4.214 E F5(vie)4.214 E(ws)-.165
E F0 1.465(must also be reloaded by re-e)4.215 F -.165(xe)-.165 G 1.465
(cuting the v).165 F(arious)-.275 E F6(CREA)4.215 E(TE)-1.045 E F0(com-)
4.215 E(mands.)122.85 513.7 Q -1.21(Yo)108 530.8 S 4.717(us)1.21 G 1.966
(hould gi)-4.717 F 2.296 -.165(ve a)-.275 H 2.296 -.165(ny n).165 H
2.516 -.275(ew r).165 H 1.966
(elease a \231trial period\232; in particular).275 F 4.716(,d)-.44 G
4.716(on)-4.716 G 1.966(ot delete the old)-4.716 F 1.741(database until\
you are satis\214ed that there are no compatibility problems with the \
ne)108 544 R(w)-.275 E(softw)108 557.2 Q 3.529(are. F)-.11 F .779(or e)
-.165 F .779(xample, you do not w)-.165 F .779(ant to disco)-.11 F -.165
(ve)-.165 G 3.529(rt).165 G .779(hat a b)-3.529 F .779(ug in a type')
-.22 F 3.529<7399>-.605 G .778(input\232 \(con-)-3.529 F -.165(ve)108
570.4 S 2.143(rsion from ASCII\) and \231output\232 \(con).165 F -.165
(ve)-.44 G 2.143(rsion to ASCII\) routines pre).165 F -.165(ve)-.275 G
2.143(nts you from).165 F 1.032(reloading your data after you ha)108
583.6 R 1.362 -.165(ve d)-.22 H(estro).165 E 1.031
(yed your old databases!)-.11 F 1.031(\(This should be stan-)6.531 F
.838(dard procedure when updating an)108 596.8 R 3.589(ys)-.165 G(oftw)
-3.589 E .839(are package, b)-.11 F .839
(ut some people try to economize)-.22 F
(on disk space without applying enough foresight.\))108 610 Q F3 3
(15.3. Database)72 636.2 R(Security)3 E .44 LW 77.5 649.4 72 649.4 DL
80.5 649.4 75 649.4 DL 86 649.4 80.5 649.4 DL 91.5 649.4 86 649.4 DL 97
649.4 91.5 649.4 DL 102.5 649.4 97 649.4 DL 108 649.4 102.5 649.4 DL
113.5 649.4 108 649.4 DL 119 649.4 113.5 649.4 DL 124.5 649.4 119 649.4
DL 130 649.4 124.5 649.4 DL 135.5 649.4 130 649.4 DL 141 649.4 135.5
649.4 DL 146.5 649.4 141 649.4 DL 152 649.4 146.5 649.4 DL 157.5 649.4
152 649.4 DL 163 649.4 157.5 649.4 DL 168.5 649.4 163 649.4 DL 174 649.4
168.5 649.4 DL 179.5 649.4 174 649.4 DL 185 649.4 179.5 649.4 DL 190.5
649.4 185 649.4 DL 196 649.4 190.5 649.4 DL 201.5 649.4 196 649.4 DL 207
649.4 201.5 649.4 DL 212.5 649.4 207 649.4 DL 218 649.4 212.5 649.4 DL
223.5 649.4 218 649.4 DL 229 649.4 223.5 649.4 DL 234.5 649.4 229 649.4
DL 240 649.4 234.5 649.4 DL 245.5 649.4 240 649.4 DL 251 649.4 245.5
649.4 DL 256.5 649.4 251 649.4 DL 262 649.4 256.5 649.4 DL 267.5 649.4
262 649.4 DL 273 649.4 267.5 649.4 DL 278.5 649.4 273 649.4 DL 284 649.4
278.5 649.4 DL 289.5 649.4 284 649.4 DL 295 649.4 289.5 649.4 DL 300.5
649.4 295 649.4 DL 306 649.4 300.5 649.4 DL 311.5 649.4 306 649.4 DL 317
649.4 311.5 649.4 DL 322.5 649.4 317 649.4 DL 328 649.4 322.5 649.4 DL
333.5 649.4 328 649.4 DL 339 649.4 333.5 649.4 DL 344.5 649.4 339 649.4
DL 350 649.4 344.5 649.4 DL 355.5 649.4 350 649.4 DL 361 649.4 355.5
649.4 DL 366.5 649.4 361 649.4 DL 372 649.4 366.5 649.4 DL 377.5 649.4
372 649.4 DL 383 649.4 377.5 649.4 DL 388.5 649.4 383 649.4 DL 394 649.4
388.5 649.4 DL 399.5 649.4 394 649.4 DL 405 649.4 399.5 649.4 DL 410.5
649.4 405 649.4 DL 416 649.4 410.5 649.4 DL 421.5 649.4 416 649.4 DL 427
649.4 421.5 649.4 DL 432.5 649.4 427 649.4 DL 438 649.4 432.5 649.4 DL
443.5 649.4 438 649.4 DL 449 649.4 443.5 649.4 DL 454.5 649.4 449 649.4
DL 460 649.4 454.5 649.4 DL 465.5 649.4 460 649.4 DL 471 649.4 465.5
649.4 DL 476.5 649.4 471 649.4 DL 482 649.4 476.5 649.4 DL 487.5 649.4
482 649.4 DL 493 649.4 487.5 649.4 DL 498.5 649.4 493 649.4 DL 504 649.4
498.5 649.4 DL F0 1.632(Most sites that use)108 679.7 R F4(POSTGRES)
4.383 E F0 1.633
(are educational or research institutions and do not pay)4.383 F 1.615
(much attention to security in their)108 692.9 R F4(POSTGRES)4.365 E F0
4.365(installations. If)4.365 F 1.614(desired, one can install)4.365 F
F4(POSTGRES)108 706.1 Q F0 1.524(with additional security features.)
4.274 F(Naturally)7.024 E 4.274(,s)-.715 G 1.524
(uch features come with addi-)-4.274 F(tional administrati)108 719.3 Q
.33 -.165(ve ove)-.275 H(rhead that must be dealt with.).165 E F6(77)
282.5 756 Q EP
%%Page: 78 78
%%BeginPageSetup
BP
%%EndPageSetup
/F0 12/Times-Bold@0 SF 3(15.3.1. K)72 97.2 R(erber)-.3 E(os)-.216 E/F1
10/Times-Roman@0 SF(POSTGRES)108 114.3 Q/F2 11/Times-Roman@0 SF 1.328
(can be con\214gured to use the MIT K)4.078 F 1.327(erberos netw)-.275 F
1.327(ork authentication system.)-.11 F .791(This pre)108 127.5 R -.165
(ve)-.275 G .791(nts outside users from connecting to your databases o)
.165 F -.165(ve)-.165 G 3.541(rt).165 G .791(he netw)-3.541 F .792
(ork without)-.11 F(the correct authentication information.)108 140.7 Q
F0 3(15.4. Querying)72 166.9 R(the System Catalogs)3 E .44 LW 77.5 180.1
72 180.1 DL 80.5 180.1 75 180.1 DL 86 180.1 80.5 180.1 DL 91.5 180.1 86
180.1 DL 97 180.1 91.5 180.1 DL 102.5 180.1 97 180.1 DL 108 180.1 102.5
180.1 DL 113.5 180.1 108 180.1 DL 119 180.1 113.5 180.1 DL 124.5 180.1
119 180.1 DL 130 180.1 124.5 180.1 DL 135.5 180.1 130 180.1 DL 141 180.1
135.5 180.1 DL 146.5 180.1 141 180.1 DL 152 180.1 146.5 180.1 DL 157.5
180.1 152 180.1 DL 163 180.1 157.5 180.1 DL 168.5 180.1 163 180.1 DL 174
180.1 168.5 180.1 DL 179.5 180.1 174 180.1 DL 185 180.1 179.5 180.1 DL
190.5 180.1 185 180.1 DL 196 180.1 190.5 180.1 DL 201.5 180.1 196 180.1
DL 207 180.1 201.5 180.1 DL 212.5 180.1 207 180.1 DL 218 180.1 212.5
180.1 DL 223.5 180.1 218 180.1 DL 229 180.1 223.5 180.1 DL 234.5 180.1
229 180.1 DL 240 180.1 234.5 180.1 DL 245.5 180.1 240 180.1 DL 251 180.1
245.5 180.1 DL 256.5 180.1 251 180.1 DL 262 180.1 256.5 180.1 DL 267.5
180.1 262 180.1 DL 273 180.1 267.5 180.1 DL 278.5 180.1 273 180.1 DL 284
180.1 278.5 180.1 DL 289.5 180.1 284 180.1 DL 295 180.1 289.5 180.1 DL
300.5 180.1 295 180.1 DL 306 180.1 300.5 180.1 DL 311.5 180.1 306 180.1
DL 317 180.1 311.5 180.1 DL 322.5 180.1 317 180.1 DL 328 180.1 322.5
180.1 DL 333.5 180.1 328 180.1 DL 339 180.1 333.5 180.1 DL 344.5 180.1
339 180.1 DL 350 180.1 344.5 180.1 DL 355.5 180.1 350 180.1 DL 361 180.1
355.5 180.1 DL 366.5 180.1 361 180.1 DL 372 180.1 366.5 180.1 DL 377.5
180.1 372 180.1 DL 383 180.1 377.5 180.1 DL 388.5 180.1 383 180.1 DL 394
180.1 388.5 180.1 DL 399.5 180.1 394 180.1 DL 405 180.1 399.5 180.1 DL
410.5 180.1 405 180.1 DL 416 180.1 410.5 180.1 DL 421.5 180.1 416 180.1
DL 427 180.1 421.5 180.1 DL 432.5 180.1 427 180.1 DL 438 180.1 432.5
180.1 DL 443.5 180.1 438 180.1 DL 449 180.1 443.5 180.1 DL 454.5 180.1
449 180.1 DL 460 180.1 454.5 180.1 DL 465.5 180.1 460 180.1 DL 471 180.1
465.5 180.1 DL 476.5 180.1 471 180.1 DL 482 180.1 476.5 180.1 DL 487.5
180.1 482 180.1 DL 493 180.1 487.5 180.1 DL 498.5 180.1 493 180.1 DL 504
180.1 498.5 180.1 DL F2 .509
(As an administrator \(or sometimes as a plain user\), you w)108 210.4 R
.51(ant to \214nd out what e)-.11 F(xtensions)-.165 E(ha)108 223.6 Q
.854 -.165(ve b)-.22 H .524(een added to a gi).165 F -.165(ve)-.275 G
3.273(nd).165 G 3.273(atabase. The)-3.273 F .523(queries listed belo)
3.273 F 3.273(wa)-.275 G .523(re \231canned\232 queries that)-3.273 F
.599(you can run on an)108 236.8 R 3.35(yd)-.165 G .6
(atabase to get simple answers.)-3.35 F .6(Before e)6.1 F -.165(xe)-.165
G .6(cuting an).165 F 3.35(yo)-.165 G 3.35(ft)-3.35 G .6(he queries)
-3.35 F(belo)108 250 Q 1.46 -.715(w, b)-.275 H 2.78(es).715 G .03
(ure to e)-2.78 F -.165(xe)-.165 G .029(cute the).165 F F1(POSTGRES)
2.779 E/F3 11/Courier@0 SF(vacuum)2.779 E F2 2.779(command. \(The)2.779
F .029(queries will run much)2.779 F(more quickly that w)108 263.2 Q(ay)
-.11 E 2.75(.\) Also,)-.715 F
(note that these queries are also listed in)2.75 E/F4 10/Courier@0 SF
(/usr/local/postgres95/tutorial/syscat.sql)148 288.4 Q F2
(so use cut-and-paste \(or the)108 314.6 Q F3(\\i)2.75 E F2
(command\) instead of doing a lot of typing.)2.75 E 3.742(This query pr\
ints the names of all database adminstrators and the name of their)108
331.7 R(database\(s\).)108 344.9 Q F4(SELECT usename, datname)148 370.1
Q(FROM pg_user, pg_database)172 382.3 Q
(WHERE usesysid = int2in\(int4out\(datdba\)\))172 394.5 Q
(ORDER BY usename, datname;)172 406.7 Q F2(This query lists all user)108
432.9 Q(-de\214ned classes in the database.)-.22 E F4(SELECT relname)148
458.1 Q(FROM pg_class)172 470.3 Q(WHERE relkind = 'r')172 482.5 Q
(-- not indices)66 E(and relname !~ '^pg_')184 494.7 Q(-- not catalogs)
42 E(and relname !~ '^Inv')184 506.9 Q(-- not large objects)42 E
(ORDER BY relname;)172 519.1 Q F2 .671(This query lists all simple indi\
ces \(i.e., those that are not de\214ned o)108 545.3 R -.165(ve)-.165 G
3.421(raf).165 G .671(unction of se)-3.421 F(v-)-.275 E(eral attrib)108
558.5 Q(utes\).)-.22 E F4(SELECT bc.relname AS class_name,)148 583.7 Q
(ic.relname AS index_name,)202 595.9 Q(a.attname)202 608.1 Q
(FROM pg_class bc,)172 620.3 Q(-- base class)78 E(pg_class ic,)202 632.5
Q(-- index class)78 E(pg_index i,)202 644.7 Q(pg_attribute a)202 656.9 Q
(-- att in base)66 E(WHERE i.indrelid = bc.oid)172 669.1 Q
(and i.indexrelid = ic.oid)190 681.3 Q(and i.indkey[0] = a.attnum)190
693.5 Q(and a.attrelid = bc.oid)190 705.7 Q(and i.indproc = '0'::oid)190
717.9 Q(-- no functional indices)18 E/F5 11/Times-Bold@0 SF(78)282.5 756
Q EP
%%Page: 79 79
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(ORDER BY class_name, index_name, attname;)172 96.2 Q
/F1 11/Times-Roman@0 SF .14(This query prints a report of the user)108
122.4 R .14(-de\214ned attrib)-.22 F .14
(utes and their types for all user)-.22 F(-de\214ned)-.22 E
(classes in the database.)108 135.6 Q F0
(SELECT c.relname, a.attname, t.typname)148 160.8 Q
(FROM pg_class c, pg_attribute a, pg_type t)172 173 Q
(WHERE c.relkind = 'r')172 185.2 Q(-- no indices)30 E
(and c.relname !~ '^pg_' -- no catalogs)184 197.4 Q
(and c.relname !~ '^Inv' -- no large objects)184 209.6 Q
(and a.attnum > 0)184 221.8 Q(-- no system att's)48 E
(and a.attrelid = c.oid)184 234 Q(and a.atttypid = t.oid)184 246.2 Q
(ORDER BY relname, attname;)172 258.4 Q F1(This query lists all user)108
284.6 Q(-de\214ned base types \(not including array types\).)-.22 E F0
(SELECT u.usename, t.typname)148 309.8 Q(FROM pg_type t, pg_user u)172
322 Q(WHERE u.usesysid = int2in\(int4out\(t.typowner\)\))172 334.2 Q
(and t.typrelid = '0'::oid)184 346.4 Q(-- no complex types)18 E
(and t.typelem = '0'::oid)184 358.6 Q(-- no arrays)24 E
(and u.usename <> 'postgres')184 370.8 Q(ORDER BY usename, typname;)172
383 Q F1(This query lists all left-unary \(post-\214x\) operators.)108
409.2 Q F0(SELECT o.oprname AS left_unary,)148 434.4 Q
(right.typname AS operand,)202 446.6 Q(result.typname AS return_type)202
458.8 Q(FROM pg_operator o, pg_type right, pg_type result)172 471 Q
(WHERE o.oprkind = 'l')172 483.2 Q(-- left unary)66 E
(and o.oprright = right.oid)184 495.4 Q(and o.oprresult = result.oid)184
507.6 Q(ORDER BY operand;)172 519.8 Q F1
(This query lists all right-unary \(pre-\214x\) operators.)108 546 Q F0
(SELECT o.oprname AS right_unary,)148 571.2 Q(left.typname AS operand,)
202 583.4 Q(result.typname AS return_type)202 595.6 Q
(FROM pg_operator o, pg_type left, pg_type result)172 607.8 Q
(WHERE o.oprkind = 'r')172 620 Q(-- right unary)60 E
(and o.oprleft = left.oid)184 632.2 Q(and o.oprresult = result.oid)184
644.4 Q(ORDER BY operand;)172 656.6 Q F1
(This query lists all binary operators.)108 682.8 Q F0
(SELECT o.oprname AS binary_op,)148 708 Q(left.typname AS left_opr,)202
720.2 Q/F2 11/Times-Bold@0 SF(79)282.5 756 Q EP
%%Page: 80 80
%%BeginPageSetup
BP
%%EndPageSetup
/F0 10/Courier@0 SF(right.typname AS right_opr,)202 96.2 Q
(result.typname AS return_type)202 108.4 Q
(FROM pg_operator o, pg_type left, pg_type right, pg_type result)172
120.6 Q(WHERE o.oprkind = 'b')172 132.8 Q(-- binary)54 E
(and o.oprleft = left.oid)184 145 Q(and o.oprright = right.oid)184 157.2
Q(and o.oprresult = result.oid)184 169.4 Q
(ORDER BY left_opr, right_opr;)172 181.6 Q/F1 11/Times-Roman@0 SF 1.527
(This query returns the name, number of ar)108 207.8 R 1.526
(guments \(parameters\) and return type of all)-.198 F(user)108 221 Q
.826(-de\214ned C functions.)-.22 F .826
(The same query can be used to \214nd all b)6.326 F .827
(uilt-in C functions if)-.22 F 3.101(you change the \231C\232 to \231in\
ternal\232, or all SQL functions if you change the \231C\232 to)108
234.2 R(\231postquel\232.)108 247.4 Q F0
(SELECT p.proname, p.pronargs, t.typname)148 272.6 Q
(FROM pg_proc p, pg_language l, pg_type t)172 284.8 Q
(WHERE p.prolang = l.oid)172 297 Q(and p.prorettype = t.oid)184 309.2 Q
(and l.lanname = 'c')184 321.4 Q(ORDER BY proname;)172 333.6 Q F1 1.286
(This query lists all of the aggre)108 359.8 R -.055(ga)-.165 G 1.286
(te functions that ha).055 F 1.616 -.165(ve b)-.22 H 1.287
(een installed and the types to).165 F 1.369(which the)108 373 R 4.119
(yc)-.165 G 1.368(an be applied.)-4.119 F/F2 11/Courier@0 SF(count)6.868
E F1 1.368(is not included because it can tak)4.118 F 4.118(ea)-.11 G
1.698 -.165(ny t)-4.118 H 1.368(ype as its).165 F(ar)108 386.2 Q
(gument.)-.198 E F0(SELECT a.aggname, t.typname)148 411.4 Q
(FROM pg_aggregate a, pg_type t)172 423.6 Q(WHERE a.aggbasetype = t.oid)
172 435.8 Q(ORDER BY aggname, typname;)172 448 Q F1 1.036(This query li\
sts all of the operator classes that can be used with each access metho\
d as)108 474.2 R
(well as the operators that can be used with the respecti)108 487.4 Q
.33 -.165(ve o)-.275 H(perator classes.).165 E F0
(SELECT am.amname, opc.opcname, opr.oprname)148 512.6 Q
(FROM pg_am am, pg_amop amop, pg_opclass opc, pg_operator opr)172 524.8
Q(WHERE amop.amopid = am.oid)172 537 Q(and amop.amopclaid = opc.oid)184
549.2 Q(and amop.amopopr = opr.oid)184 561.4 Q
(ORDER BY amname, opcname, oprname;)172 573.6 Q/F3 11/Times-Bold@0 SF
(80)282.5 756 Q EP
%%Page: 81 81
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 19/Times-Bold@0 SF 4.75(16. REFERENCES)72 165.4 R 77.5 178.6
72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86
178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5
178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6
119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6
135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5
178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174
178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL
190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6
DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5
178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6
229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6
245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5
178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284
178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL
300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6
DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5
178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6
339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6
355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5
178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394
178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL
410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6
DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5
178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6
449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6
465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5
178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504
178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF([D)108 208.9 Q -1.221(AT)
-.44 G 16.445(E93] Date,)1.221 F .066
(C. J. and Darwen, Hugh, A Guide to The SQL Standard, 3rd Edition,)2.816
F(Reading, MA, June 1993.)173.186 222.1 Q([MEL)108 239.2 Q 15.18
(T93] Melton,)-1.012 F 2.75(J. Understanding)2.75 F(the Ne)2.75 E 2.75
(wS)-.275 G(QL, 1994.)-2.75 E 20.284([ONG90] Ong,)108 256.3 R .878
(L. and Goh, J., `)3.628 F 2.638 -.88(`A U)-.814 H .878(ni\214ed Frame)
.88 F -.11(wo)-.275 G .878(rk for V).11 F .878(ersion Modeling Using)
-1.221 F .172(Production Rules in a Database System," Electronics Resea\
rch Laboratory)173.186 269.5 R(,)-.715 E(Uni)173.186 282.7 Q -.165(ve)
-.275 G .611(rsity of California, ERL T).165 F .612
(echnical Memorandum M90/33, Berk)-.77 F(ele)-.11 E -.715(y,)-.165 G
(CA, April 1990.)173.186 295.9 Q([R)108 313 Q -.385(OW)-.44 G 12.551
(E87] Ro).385 F 2.491(we, L. and Stonebrak)-.275 F(er)-.11 E 5.241(,M)
-.44 G 2.491(., `)-5.241 F 2.491(`The POSTGRES Data Model,)-.814 F 4.118
-.814('' P)-.77 H(roc.).814 E
(1987 VLDB Conference, Brighton, England, Sept. 1987.)173.186 326.2 Q
([ST)108 343.3 Q 15.587(ON86] Stonebrak)-.198 F(er)-.11 E 3.433(,M)-.44
G 3.433(.a)-3.433 G .683(nd Ro)-3.433 F .683(we, L., `)-.275 F .683
(`The Design of POSTGRES,)-.814 F 2.311 -.814('' P)-.77 H .684
(roc. 1986).814 F -.44(AC)173.186 356.5 S 2.147
(M-SIGMOD Conference on Management of Data, W).44 F 2.146
(ashington, DC,)-.88 F(May 1986.)173.186 369.7 Q([ST)108 386.8 Q 10.703
(ON87a] Stonebrak)-.198 F(er)-.11 E 3.378(,M)-.44 G .628
(., Hanson, E. and Hong, C.-H., `)-3.378 F .628(`The Design of the POST)
-.814 F(-)-1.012 E .476(GRES Rules System,)173.186 400 R 2.104 -.814
('' P)-.77 H .475(roc. 1987 IEEE Conference on Data Engineering,).814 F
(Los Angeles, CA, Feb)173.186 413.2 Q 2.75(.1)-.44 G(987.)-2.75 E([ST)
108 430.3 Q 10.087(ON87b] Stonebrak)-.198 F(er)-.11 E 4.026(,M)-.44 G
1.276(., `)-4.026 F 1.276(`The POSTGRES Storage System,)-.814 F 2.904
-.814('' P)-.77 H 1.276(roc. 1987 VLDB).814 F
(Conference, Brighton, England, Sept. 1987.)173.186 443.5 Q([ST)108
460.6 Q 15.587(ON89] Stonebrak)-.198 F(er)-.11 E 3.64(,M)-.44 G .89
(., Hearst, M., and Potamianos, S., `)-3.64 F 2.65 -.88(`A C)-.814 H .89
(ommentary on the).88 F(POSTGRES Rules System,)173.186 473.8 Q 1.628
-.814('' S)-.77 H(IGMOD Record).814 E/F2 11/Times-Italic@0 SF(18)2.75 E
F1(\(3\), Sept. 1989.)A([ST)108 490.9 Q 10.703(ON90a] Stonebrak)-.198 F
(er)-.11 E 2.878(,M)-.44 G .128(., Ro)-2.878 F .129
(we, L. A., and Hirohama, M., `)-.275 F .129(`The Implementation of)
-.814 F(POSTGRES,)173.186 504.1 Q 3.993 -.814('' I)-.77 H 2.365(EEE T)
.814 F 2.365(ransactions on Kno)-.385 F 2.365
(wledge and Data Engineering)-.275 F F2(2)173.186 517.3 Q F1
(\(1\), March 1990.)A([ST)108 534.4 Q 10.087(ON90b] Stonebrak)-.198 F
(er)-.11 E 5.388(,M)-.44 G 5.389(.e)-5.388 G 5.389(ta)-5.389 G 2.639
(l., `)-5.389 F 2.639(`On Rules, Procedures, Caching and V)-.814 F(ie)
-.66 E 2.639(ws in)-.275 F 1.245(Database Systems,)173.186 547.6 R 2.873
-.814('' P)-.77 H 1.245(roc. 1990 A).814 F 1.244
(CM-SIGMOD Conference on Manage-)-.44 F(ment of Data, Atlantic City)
173.186 560.8 Q 2.75(,N)-.715 G(.J., June 1990.)-2.75 E/F3 11
/Times-Bold@0 SF(81)282.5 756 Q EP
%%Page: 82 82
%%BeginPageSetup
BP
%%EndPageSetup
.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
97.2 DL/F0 12/Times-Bold@0 SF -.3(Ap)72 136.6 S
(pendix A: Linking Dynamically-Loaded Functions).3 E 77.5 149.8 72 149.8
DL 80.5 149.8 75 149.8 DL 86 149.8 80.5 149.8 DL 91.5 149.8 86 149.8 DL
97 149.8 91.5 149.8 DL 102.5 149.8 97 149.8 DL 108 149.8 102.5 149.8 DL
113.5 149.8 108 149.8 DL 119 149.8 113.5 149.8 DL 124.5 149.8 119 149.8
DL 130 149.8 124.5 149.8 DL 135.5 149.8 130 149.8 DL 141 149.8 135.5
149.8 DL 146.5 149.8 141 149.8 DL 152 149.8 146.5 149.8 DL 157.5 149.8
152 149.8 DL 163 149.8 157.5 149.8 DL 168.5 149.8 163 149.8 DL 174 149.8
168.5 149.8 DL 179.5 149.8 174 149.8 DL 185 149.8 179.5 149.8 DL 190.5
149.8 185 149.8 DL 196 149.8 190.5 149.8 DL 201.5 149.8 196 149.8 DL 207
149.8 201.5 149.8 DL 212.5 149.8 207 149.8 DL 218 149.8 212.5 149.8 DL
223.5 149.8 218 149.8 DL 229 149.8 223.5 149.8 DL 234.5 149.8 229 149.8
DL 240 149.8 234.5 149.8 DL 245.5 149.8 240 149.8 DL 251 149.8 245.5
149.8 DL 256.5 149.8 251 149.8 DL 262 149.8 256.5 149.8 DL 267.5 149.8
262 149.8 DL 273 149.8 267.5 149.8 DL 278.5 149.8 273 149.8 DL 284 149.8
278.5 149.8 DL 289.5 149.8 284 149.8 DL 295 149.8 289.5 149.8 DL 300.5
149.8 295 149.8 DL 306 149.8 300.5 149.8 DL 311.5 149.8 306 149.8 DL 317
149.8 311.5 149.8 DL 322.5 149.8 317 149.8 DL 328 149.8 322.5 149.8 DL
333.5 149.8 328 149.8 DL 339 149.8 333.5 149.8 DL 344.5 149.8 339 149.8
DL 350 149.8 344.5 149.8 DL 355.5 149.8 350 149.8 DL 361 149.8 355.5
149.8 DL 366.5 149.8 361 149.8 DL 372 149.8 366.5 149.8 DL 377.5 149.8
372 149.8 DL 383 149.8 377.5 149.8 DL 388.5 149.8 383 149.8 DL 394 149.8
388.5 149.8 DL 399.5 149.8 394 149.8 DL 405 149.8 399.5 149.8 DL 410.5
149.8 405 149.8 DL 416 149.8 410.5 149.8 DL 421.5 149.8 416 149.8 DL 427
149.8 421.5 149.8 DL 432.5 149.8 427 149.8 DL 438 149.8 432.5 149.8 DL
443.5 149.8 438 149.8 DL 449 149.8 443.5 149.8 DL 454.5 149.8 449 149.8
DL 460 149.8 454.5 149.8 DL 465.5 149.8 460 149.8 DL 471 149.8 465.5
149.8 DL 476.5 149.8 471 149.8 DL 482 149.8 476.5 149.8 DL 487.5 149.8
482 149.8 DL 493 149.8 487.5 149.8 DL 498.5 149.8 493 149.8 DL 504 149.8
498.5 149.8 DL/F1 11/Times-Roman@0 SF 1.43(After you ha)108 180.1 R
1.761 -.165(ve c)-.22 H 1.431(reated and re).165 F 1.431
(gistered a user)-.165 F 1.431(-de\214ned function, your w)-.22 F 1.431
(ork is essentially)-.11 F(done.)108 193.3 Q/F2 10/Times-Roman@0 SF
(POSTGRES)5.585 E F1 2.835(,h)C -.275(ow)-2.835 G -2.365 -.275(ev e).275
H .965 -.44(r, m).275 H .085(ust load the).44 F/F3 11/Times-Italic@0 SF
.085(object code)2.835 F F1 .085(\(e.g., a)2.835 F/F4 11/Courier@0 SF
(.o)2.835 E F1 .084(\214le, or a shared library\))2.835 F .536
(that implements your function.)108 206.5 R .537(As pre)6.036 F .537
(viously mentioned,)-.275 F F2(POSTGRES)3.287 E F1 .537
(loads your code at)3.287 F 1.335(run-time, as required.)108 219.7 R
1.334(In order to allo)6.834 F 4.084(wy)-.275 G 1.334
(our code to be dynamically loaded, you may)-4.084 F(ha)108 232.9 Q 1.43
-.165(ve t)-.22 H 3.85(oc).165 G 1.1
(ompile and link-edit it in a special w)-3.85 F(ay)-.11 E 6.6(.T)-.715 G
1.1(his section brie\215y describes ho)-6.6 F 3.85(wt)-.275 G(o)-3.85 E
.666(perform the compilation and link-editing required before you can l\
oad your user)108 246.1 R(-de\214ned)-.22 E .222
(functions into a running)108 259.3 R F2(POSTGRES)2.973 E F1(serv)2.973
E(er)-.165 E 5.723(.N)-.605 G .223(ote that)-5.723 F F3 .223(this pr)
2.973 F .223(ocess has c)-.495 F(hang)-.165 E .223(ed as of V)-.11 F(er)
-1.221 E(-)-.22 E .177(sion 4.2.)108 274.7 R/F5 8/Times-Roman@0 SF(11)
-4.4 I F1 -1.21(Yo)2.927 4.4 O 2.927(us)1.21 G .177(hould e)-2.927 F
.177
(xpect to read \(and reread, and re-reread\) the manual pages for the)
-.165 F 3.075(Cc)108 287.9 S(ompiler)-3.075 E(,)-.44 E F4(cc)3.075 E F1
.325(\(1\), and the link editor)B(,)-.44 E F4(ld)3.075 E F1 .324
(\(1\), if you ha)B .654 -.165(ve s)-.22 H .324(peci\214c questions.)
.165 F .324(In addition,)5.824 F 36.494(the re)108 301.1 R 36.494
(gression test suites in the directory)-.165 F F4
(/usr/local/postgres95/src/regress)108 314.3 Q F1 2.851(contain se)5.602
F -.165(ve)-.275 G 2.851(ral w).165 F 2.851(orking e)-.11 F 2.851
(xamples of)-.165 F(this process.)108 327.5 Q(If you cop)5.5 E 2.75(yw)
-.11 G(hat these tests do, you should not ha)-2.75 E .33 -.165(ve a)-.22
H .33 -.165(ny p).165 H(roblems.).165 E(The follo)108 344.6 Q
(wing terminology will be used belo)-.275 E(w:)-.275 E(Dynamic loading)
108 361.7 Q .398(is what)133 374.9 R F2(POSTGRES)3.148 E F1 .399
(does to an object \214le.)3.149 F .399
(The object \214le is copied into the running)5.899 F F2(POSTGRES)133
388.1 Q F1(serv)3.051 E .301(er and the functions and v)-.165 F .3
(ariables within the \214le are made a)-.275 F -.275(va)-.22 G(ilable)
.275 E 2.218(to the functions within the)133 401.3 R F2(POSTGRES)4.968 E
F1(process.)4.969 E F2(POSTGRES)7.719 E F1 2.219(does this using the)
4.969 F(dynamic loading mechanism pro)133 414.5 Q
(vided by the operating system.)-.165 E(Loading and link editing)108
431.6 Q .438(is what you do to an object \214le in order to produce ano\
ther kind of object \214le \(e.g.,)133 444.8 R .433(an e)133 458 R -.165
(xe)-.165 G .433(cutable program or a shared library\).).165 F -1.21(Yo)
5.933 G 3.184(up)1.21 G .434(erform this using the link editing)-3.184 F
(program,)133 471.2 Q F4(ld)2.75 E F1(\(1\).)A(The follo)108 488.3 Q
(wing general restrictions and notes also apply to the discussion belo)
-.275 E -.715(w.)-.275 G 5.5<8350>113.5 505.4 S 1.132(aths gi)-5.665 F
-.165(ve)-.275 G 3.882(nt).165 G 3.882(ot)-3.882 G(he)-3.882 E/F6 11
/Times-Bold@0 SF(cr)3.882 E 1.131(eate function)-.198 F F1 1.131
(command must be absolute paths \(i.e., start with)3.881 F .535(\231/\
\232\) that refer to directories visible on the machine on which the)
122.85 518.6 R F2(POSTGRES)3.285 E F1(serv)3.285 E .535(er is)-.165 F
(running.)122.85 534 Q F5(12)-4.4 I F1 5.5<8354>113.5 547.2 S(he)-5.5 E
F2(POSTGRES)4.044 E F1 1.294(user must be able to tra)4.044 F -.165(ve)
-.22 G 1.294(rse the path gi).165 F -.165(ve)-.275 G 4.044(nt).165 G
4.043(ot)-4.044 G(he)-4.043 E F6(cr)4.043 E 1.293(eate function)-.198 F
F1 1.102(command and be able to read the object \214le.)122.85 560.4 R
1.102(This is because the)6.602 F F2(POSTGRES)3.852 E F1(serv)3.853 E
(er)-.165 E 2.562(runs as the)122.85 573.6 R F2(POSTGRES)5.311 E F1
(user)5.311 E 5.311(,n)-.44 G 2.561
(ot as the user who starts up the frontend process.)-5.311 F .32 LW 76
583.2 72 583.2 DL 80 583.2 76 583.2 DL 84 583.2 80 583.2 DL 88 583.2 84
583.2 DL 92 583.2 88 583.2 DL 96 583.2 92 583.2 DL 100 583.2 96 583.2 DL
104 583.2 100 583.2 DL 108 583.2 104 583.2 DL 112 583.2 108 583.2 DL 116
583.2 112 583.2 DL 120 583.2 116 583.2 DL 124 583.2 120 583.2 DL 128
583.2 124 583.2 DL 132 583.2 128 583.2 DL 136 583.2 132 583.2 DL 140
583.2 136 583.2 DL 144 583.2 140 583.2 DL 148 583.2 144 583.2 DL 152
583.2 148 583.2 DL 156 583.2 152 583.2 DL 160 583.2 156 583.2 DL 164
583.2 160 583.2 DL 168 583.2 164 583.2 DL 172 583.2 168 583.2 DL 176
583.2 172 583.2 DL 180 583.2 176 583.2 DL 184 583.2 180 583.2 DL 188
583.2 184 583.2 DL 192 583.2 188 583.2 DL 196 583.2 192 583.2 DL 200
583.2 196 583.2 DL 204 583.2 200 583.2 DL 208 583.2 204 583.2 DL 212
583.2 208 583.2 DL 216 583.2 212 583.2 DL/F7 5/Times-Roman@0 SF(11)93.6
593.6 Q F5 .445(The old)2.446 3.2 N/F8 7/Times-Roman@0 SF(POSTGRES)2.445
E F5 .445(dynamic loading mechanism required in-depth kno)2.445 F .445
(wledge in terms of e)-.2 F -.12(xe)-.12 G .445
(cutable format, placement and).12 F .174(alignment of e)72 606.4 R -.12
(xe)-.12 G .174(cutable instructions within memory).12 F 2.174(,e)-.52 G
.174(tc. on the part of the person writing the dynamic loader)-2.174 F
4.174(.S)-.44 G .174(uch loaders tended to)-4.174 F .862(be slo)72 616 R
2.862(wa)-.2 G .862(nd b)-2.862 F(uggy)-.16 E 4.862(.A)-.52 G 2.862(so)
-4.862 G 2.862(fV)-2.862 G .862(ersion 4.2, the)-3.75 F F8(POSTGRES)
2.862 E F5 .862(dynamic loading mechanism has been re)2.862 F .861
(written to use the dynamic loading)-.2 F .698(mechanism pro)72 625.6 R
.698(vided by the operating system.)-.12 F .699
(This approach is generally f)4.698 F(aster)-.08 E 2.699(,m)-.32 G .699
(ore reliable and more portable than our pre)-2.699 F(vious)-.2 E .181
(dynamic loading mechanism.)72 635.2 R .18
(The reason for this is that nearly all modern v)4.181 F .18(ersions of)
-.12 F F8(UNIX)2.18 E F5 .18(use a dynamic loading mechanism to im-)2.18
F .648(plement shared libraries and must therefore pro)72 644.8 R .648
(vide a f)-.12 F .648(ast and reliable mechanism.)-.08 F .648
(On the other hand, the object \214le must be post-)4.648 F .433
(processed a bit before it can be loaded into)72 654.4 R F8(POSTGRES)
2.433 E F5 4.433(.W)C 2.433(eh)-5.073 G .433(ope that the lar)-2.433 F
.432(ge increase in speed and reliability will mak)-.144 F 2.432(eu)-.08
G 2.432(pf)-2.432 G .432(or the)-2.432 F(slight decrease in con)72 664 Q
-.12(ve)-.32 G(nience.).12 E F7(12)93.6 674.4 Q F5(Relati)2.257 3.2 M
.497 -.12(ve p)-.2 H .257(aths do in f).12 F .257(act w)-.08 F .257
(ork, b)-.08 F .257(ut are relati)-.16 F .497 -.12(ve t)-.2 H 2.257(ot)
.12 G .257
(he directory where the database resides \(which is generally in)-2.257
F .256(visible to the)-.32 F .044(frontend application\).)72 687.2 R(Ob)
4.044 E(viously)-.12 E 2.044(,i)-.52 G 2.044(tm)-2.044 G(ak)-2.044 E
.044(es no sense to mak)-.08 F 2.044(et)-.08 G .044(he path relati)
-2.044 F .284 -.12(ve t)-.2 H 2.044(ot).12 G .044
(he directory in which the user started the frontend ap-)-2.044 F
(plication, since the serv)72 696.8 Q
(er could be running on a completely dif)-.12 E(ferent machine!)-.2 E F6
(82)282.5 756 Q EP
%%Page: 83 83
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF 1.887(\(Making the \214le or a higher)122.85
97.2 R(-le)-.22 E -.165(ve)-.275 G 4.637(ld).165 G 1.887
(irectory unreadable and/or une)-4.637 F -.165(xe)-.165 G 1.887
(cutable by the).165 F(\231postgres\232 user is an)122.85 110.4 Q/F1 11
/Times-Italic@0 SF -.22(ex)2.75 G(tr).22 E(emely)-.407 E F0
(common mistak)2.75 E(e.\))-.11 E 5.5<8353>113.5 123.6 S 1.373(ymbol na\
mes de\214ned within object \214les must not con\215ict with each other\
or with)-5.5 F(symbols de\214ned in)122.85 136.8 Q/F2 10/Times-Roman@0
SF(POSTGRES)2.75 E F0(.)A 5.5<8354>113.5 150 S .308
(he GNU C compiler usually does not pro)-5.5 F .308
(vide the special options that are required to)-.165 F 1.35
(use the operating system')122.85 163.2 R 4.1(sd)-.605 G 1.349
(ynamic loader interf)-4.1 F 4.099(ace. In)-.11 F 1.349
(such cases, the C compiler)4.099 F
(that comes with the operating system must be used.)122.85 176.4 Q/F3 12
/Times-Bold@0 SF(UL)72 202.6 Q(TRIX)-1.104 E F0 .024(It is v)108 219.7 R
.024(ery easy to b)-.165 F .025
(uild dynamically-loaded object \214les under UL)-.22 F 2.775(TRIX. UL)
-1.012 F .025(TRIX does not)-1.012 F(ha)108 232.9 Q 2.587 -.165(ve a)
-.22 H 2.587 -.165(ny s).165 H 2.257
(hared-library mechanism and hence does not place an).165 F 5.007(yr)
-.165 G 2.256(estrictions on the)-5.007 F .204(dynamic loader interf)108
246.1 R 2.954(ace. On)-.11 F .205
(the other hand, we had to \(re\)write a non-portable dynamic)2.955 F
(loader ourselv)108 259.3 Q(es and could not use true shared libraries.)
-.165 E 1.364(Under UL)108 276.4 R 1.363(TRIX, the only restriction is \
that you must produce each object \214le with the)-1.012 F(option)108
289.6 Q/F4 11/Courier@0 SF(-G 0)2.75 E F0 5.5(.\()C(Notice that that')
-5.5 E 2.75(st)-.605 G(he numeral `)-2.75 E(`)-.814 E F4(0)A F0 1.628
-.814('' a)D(nd not the letter `).814 E(`)-.814 E F4(O)A F0 -.814('')C
2.75(\). F).814 F(or e)-.165 E(xample,)-.165 E/F5 10/Courier@0 SF 6(#s)
184 314.8 S(imple ULTRIX example)-6 E 6(%c)184 327 S 6(c-)-6 G 6(G0-)-6
G 6(cf)-6 G(oo.c)-6 E F0 1.628(produces an object \214le called)108
353.2 R F4(foo.o)4.378 E F0 1.628
(that can then be dynamically loaded into)4.378 F F2(POST)4.379 E(-)-.92
E(GRES)108 366.4 Q F0 5.5(.N)C 2.75(oa)-5.5 G
(dditional loading or link-editing must be performed.)-2.75 E F3
(DEC OSF/1)72 392.6 Q F0 .797(Under DEC OSF/1, you can tak)108 409.7 R
3.547(ea)-.11 G 1.126 -.165(ny s)-3.547 H .796
(imple object \214le and produce a shared object \214le).165 F .834
(by running the)108 422.9 R F4(ld)3.584 E F0 .834(command o)3.584 F
-.165(ve)-.165 G 3.584(ri).165 G 3.584(tw)-3.584 G .835
(ith the correct options.)-3.584 F .835(The commands to do this)6.335 F
(look lik)108 436.1 Q(e:)-.11 E F5 6(#s)184 461.3 S
(imple DEC OSF/1 example)-6 E 6(%c)184 473.5 S 6(c-)-6 G 6(cf)-6 G(oo.c)
-6 E 6(%l)184 485.7 S 6(d-)-6 G
(shared -expect_unresolved '*' -o foo.so foo.o)-6 E F0 .224
(The resulting shared object \214le can then be loaded into)108 511.9 R
F2(POSTGRES)2.974 E F0 5.724(.W)C .224(hen specifying the)-5.724 F .062
(object \214le name to the)108 525.1 R/F6 11/Times-Bold@0 SF(cr)2.812 E
.062(eate function)-.198 F F0 .063(command, one must gi)2.812 F .393
-.165(ve i)-.275 H 2.813(tt).165 G .063(he name of the shared)-2.813 F
.996(object \214le \(ending in)108 540.5 R F4(.so)3.746 E F0 3.746(\)r)C
.996(ather than the simple object \214le.)-3.746 F/F7 8/Times-Roman@0 SF
(13)-4.4 I F0 .996(If the \214le you specify is)3.746 4.4 N
(not a shared object, the back)108 553.7 Q(end will hang!)-.11 E F3
(SunOS 4.x, Solaris 2.x and HP-UX)72 579.9 Q F0 .348(Under both SunOS 4\
.x, Solaris 2.x and HP-UX, the simple object \214le must be created by)
108 597 R 1.225
(compiling the source \214le with special compiler \215ags)108 610.2 R
F1(and)3.976 E F0 3.976(as)3.976 G 1.226(hared library must be pro-)
-3.976 F(duced.)108 623.4 Q .32 LW 76 633 72 633 DL 80 633 76 633 DL 84
633 80 633 DL 88 633 84 633 DL 92 633 88 633 DL 96 633 92 633 DL 100 633
96 633 DL 104 633 100 633 DL 108 633 104 633 DL 112 633 108 633 DL 116
633 112 633 DL 120 633 116 633 DL 124 633 120 633 DL 128 633 124 633 DL
132 633 128 633 DL 136 633 132 633 DL 140 633 136 633 DL 144 633 140 633
DL 148 633 144 633 DL 152 633 148 633 DL 156 633 152 633 DL 160 633 156
633 DL 164 633 160 633 DL 168 633 164 633 DL 172 633 168 633 DL 176 633
172 633 DL 180 633 176 633 DL 184 633 180 633 DL 188 633 184 633 DL 192
633 188 633 DL 196 633 192 633 DL 200 633 196 633 DL 204 633 200 633 DL
208 633 204 633 DL 212 633 208 633 DL 216 633 212 633 DL/F8 5
/Times-Roman@0 SF(13)93.6 643.4 Q F7(Actually)2.723 3.2 M(,)-.52 E/F9 7
/Times-Roman@0 SF(POSTGRES)2.723 E F7 .723(does not care what you name \
the \214le as long as it is a shared object \214le.)2.723 F .724
(If you prefer to name your)4.724 F .041
(shared object \214les with the e)72 656.2 R(xtension)-.12 E/F10 8
/Courier@0 SF(.o)2.041 E F7 2.041(,t)C .041(his is \214ne with)-2.041 F
F9(POSTGRES)2.041 E F7 .041(so long as you mak)2.041 F 2.041(es)-.08 G
.04(ure that the correct \214le name is gi)-2.041 F -.12(ve)-.2 G 2.04
(nt).12 G 2.04(ot)-2.04 G(he)-2.04 E/F11 8/Times-Bold@0 SF(cr)72 665.8 Q
.331(eate function)-.144 F F7 2.331(command. In)2.331 F .331(other w)
2.331 F .331(ords, you must simply be consistent.)-.08 F(Ho)4.331 E(we)
-.2 E -.12(ve)-.2 G .971 -.32(r, f).12 H .332
(rom a pragmatic point of vie).32 F 1.372 -.52(w, w)-.2 H 2.332(ed).52 G
(iscourage)-2.332 E .626
(this practice because you will undoubtedly confuse yourself with re)72
675.4 R -.04(ga)-.12 G .626(rds to which \214les ha).04 F .865 -.12
(ve b)-.16 H .625(een made into shared object \214les and).12 F .557
(which ha)72 685 R .797 -.12(ve n)-.16 H 2.557(ot. F).12 F .557(or e)
-.12 F .558(xample, it')-.12 F 2.558(sv)-.44 G .558(ery hard to write)
-2.678 F F10(Makefile)2.558 E F7 2.558(st)C 2.558(od)-2.558 G 2.558(ot)
-2.558 G .558
(he link-editing automatically if both the object \214le and the)-2.558
F(shared object \214le end in)72 694.6 Q F10(.o)2 E F7(!)A F6(83)282.5
756 Q EP
%%Page: 84 84
%%BeginPageSetup
BP
%%EndPageSetup
/F0 11/Times-Roman@0 SF .671
(The necessary steps with HP-UX are as follo)108 97.2 R 3.42(ws. The)
-.275 F/F1 11/Courier@0 SF(+z)3.42 E F0 .67
(\215ag to the HP-UX C compiler)3.42 F 1.752
(produces so-called \231Position Independent Code\232 \(PIC\) and the)
108 110.4 R F1(+u)4.502 E F0 1.752(\215ag remo)4.502 F -.165(ve)-.165 G
4.502(ss).165 G(ome)-4.502 E 1.207(alignment restrictions that the P)108
123.6 R 1.207(A-RISC architecture normally enforces.)-1.012 F 1.206
(The object \214le)6.706 F 1.607(must be turned into a shared library u\
sing the HP-UX link editor with the)108 136.8 R F1(-b)4.357 E F0
(option.)4.357 E .109(This sounds complicated b)108 150 R .109
(ut is actually v)-.22 F .108
(ery simple, since the commands to do it are just:)-.165 F/F2 10
/Courier@0 SF 6(#s)184 175.2 S(imple HP-UX example)-6 E 6(%c)184 187.4 S
6(c+)-6 G 6(z+)-6 G 6(u-)-6 G 6(cf)-6 G(oo.c)-6 E 6(%l)184 199.6 S 6(d-)
-6 G 6(b-)-6 G 6(of)-6 G(oo.sl foo.o)-6 E F0 1.502(As with the)108 225.8
R F1(.so)4.252 E F0 1.503(\214les mentioned in the last subsection, the)
4.253 F/F3 11/Times-Bold@0 SF(cr)4.253 E 1.503(eate function)-.198 F F0
(command)4.253 E .378(must be told which \214le is the correct \214le t\
o load \(i.e., you must gi)108 239 R .708 -.165(ve i)-.275 H 3.128(tt)
.165 G .378(he location of the)-3.128 F(shared library)108 252.2 Q 2.75
(,o)-.715 G(r)-2.75 E F1(.sl)2.75 E F0(\214le\).)2.75 E
(Under SunOS 4.x, the commands look lik)108 269.3 Q(e:)-.11 E F2 6(#s)
184 294.5 S(imple SunOS 4.x example)-6 E 6(%c)184 306.7 S 6(c-)-6 G
(PIC -c foo.c)-6 E 6(%l)184 318.9 S 6(d-)-6 G
(dc -dp -Bdynamic -o foo.so foo.o)-6 E F0(and the equi)108 345.1 Q -.275
(va)-.275 G(lent lines under Solaris 2.x are:).275 E F2 6(#s)184 370.3 S
(imple Solaris 2.x example)-6 E 6(%c)184 382.5 S 6(c-)-6 G 6(KP)-6 G
(IC -c foo.c)-6 E(or)220 394.7 Q 6(%g)184 406.9 S(cc -fPIC -c foo.c)-6 E
6(%l)184 419.1 S 6(d-)-6 G 6(G-)-6 G(Bdynamic -o foo.so foo.o)-6 E F0
.827(When linking shared libraries, you may ha)108 445.3 R 1.157 -.165
(ve t)-.22 H 3.577(os).165 G .827
(pecify some additional shared libraries)-3.577 F(\(typically system li\
braries, such as the C and math libraries\) on your)108 458.5 Q F1(ld)
2.75 E F0(command line.)2.75 E F3(84)282.5 756 Q EP
%%Trailer
end
%%EOF
|