PostgreSQL Source Code: src/backend/utils/adt/float.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

16

17#include <ctype.h>

19#include <math.h>

20#include <limits.h>

21

28#include "utils/fmgrprotos.h"

30

31

32

33

34

35

36

37

38

39

41

42

51

52

53

54

55

56

57

58

59

60

71

72

73static double sind_q1(double x);

74static double cosd_q1(double x);

76

77

78

79

80

81

82

83

84

87{

90 errmsg("value out of range: overflow")));

91}

92

95{

98 errmsg("value out of range: underflow")));

99}

100

103{

106 errmsg("division by zero")));

107}

108

109

110

111

112

113

114

115

116

117int

119{

121

122 if (inf == 0)

123 return 0;

124 else if (val > 0)

125 return 1;

126 else

127 return -1;

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

165{

167

169 fcinfo->context));

170}

171

172

173

174

175

176

177

178

179

180

181

184 const char *type_name, const char *orig_string,

185 struct Node *escontext)

186{

187 float val;

188 char *endptr;

189

190

191

192

193

194

195

196

197 while (*num != '\0' && isspace((unsigned char) *num))

198 num++;

199

200

201

202

203

204 if (*num == '\0')

207 errmsg("invalid input syntax for type %s: \"%s\"",

209

212

213

214 if (endptr == num || errno != 0)

215 {

217

218

219

220

221

222

223

224

225

226

227

229 {

231 endptr = num + 3;

232 }

234 {

236 endptr = num + 8;

237 }

239 {

241 endptr = num + 9;

242 }

244 {

246 endptr = num + 9;

247 }

249 {

251 endptr = num + 3;

252 }

254 {

256 endptr = num + 4;

257 }

259 {

261 endptr = num + 4;

262 }

264 {

265

266

267

268

269

270

271

272 if (val == 0.0 ||

275#else

278 )

279 {

280

282

284

287 errmsg("\"%s\" is out of range for type real",

289 }

290 }

291 else

294 errmsg("invalid input syntax for type %s: \"%s\"",

296 }

297

298

299 while (*endptr != '\0' && isspace((unsigned char) *endptr))

300 endptr++;

301

302

305 else if (*endptr != '\0')

308 errmsg("invalid input syntax for type %s: \"%s\"",

310

311 return val;

312}

313

314

315

316

317

320{

324

326 {

329 }

330

333}

334

335

336

337

345

346

347

348

359

360

361

362

365{

367

369 fcinfo->context));

370}

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

396 const char *type_name, const char *orig_string,

397 struct Node *escontext)

398{

399 double val;

400 char *endptr;

401

402

403 while (*num != '\0' && isspace((unsigned char) *num))

404 num++;

405

406

407

408

409

410 if (*num == '\0')

413 errmsg("invalid input syntax for type %s: \"%s\"",

415

418

419

420 if (endptr == num || errno != 0)

421 {

423

424

425

426

427

428

429

430

431

432

433

435 {

437 endptr = num + 3;

438 }

440 {

442 endptr = num + 8;

443 }

445 {

447 endptr = num + 9;

448 }

450 {

452 endptr = num + 9;

453 }

455 {

457 endptr = num + 3;

458 }

460 {

462 endptr = num + 4;

463 }

465 {

467 endptr = num + 4;

468 }

470 {

471

472

473

474

475

476

477

478

479

480

481

483 {

485

489 errmsg("\"%s\" is out of range for type double precision",

491 }

492 }

493 else

496 errmsg("invalid input syntax for type %s: \"%s\"",

498 }

499

500

501 while (*endptr != '\0' && isspace((unsigned char) *endptr))

502 endptr++;

503

504

507 else if (*endptr != '\0')

510 errmsg("invalid input syntax for type %s: \"%s\"",

512

513 return val;

514}

515

516

517

518

519

520

528

529

530

531

532

533

534

535

536char *

538{

541

543 {

546 }

547

550}

551

552

553

554

562

563

564

565

576

577

578

579

580

581

582

583

584

585

586

587

588

589

597

598

599

600

603{

606

607 result = -arg1;

609}

610

618

621{

625

627 result = arg1;

628 else

629 result = arg2;

631}

632

635{

639

641 result = arg1;

642 else

643 result = arg2;

645}

646

647

648

649

650

651

652

653

654

655

663

664

665

666

667

670{

673

674 result = -arg1;

676}

677

685

688{

692

694 result = arg1;

695 else

696 result = arg2;

698}

699

702{

706

708 result = arg1;

709 else

710 result = arg2;

712}

713

714

715

716

717

718

719

720

721

722

723

724

725

726

735

744

753

762

763

764

765

766

767

768

777

786

795

804

805

806

807

808

809

810

811

812

813

814

815int

817{

819 return 1;

821 return -1;

822 return 0;

823}

824

833

842

851

860

869

878

887

888static int

896

905

906

907

908

909int

911{

913 return 1;

915 return -1;

916 return 0;

917}

918

927

936

945

954

963

972

981

982static int

990

999

1009

1019

1020

1021

1022

1023

1024

1025

1028{

1035

1036

1037

1038

1039

1040 if (isnan(offset) || offset < 0)

1043 errmsg("invalid preceding or following size in window function")));

1044

1045

1046

1047

1048

1049

1051 {

1052 if (isnan(base))

1054 else

1056 }

1057 else if (isnan(base))

1058 {

1060 }

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1076 (sub ? base > 0 : base < 0))

1078

1079

1080

1081

1082

1083

1084

1085 if (sub)

1086 sum = base - offset;

1087 else

1088 sum = base + offset;

1089

1092 else

1094}

1095

1096

1097

1098

1099

1100

1101

1104{

1111

1112

1113

1114

1115

1116 if (isnan(offset) || offset < 0)

1119 errmsg("invalid preceding or following size in window function")));

1120

1121

1122

1123

1124

1125

1127 {

1128 if (isnan(base))

1130 else

1132 }

1133 else if (isnan(base))

1134 {

1136 }

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1152 (sub ? base > 0 : base < 0))

1154

1155

1156

1157

1158

1159

1160

1161 if (sub)

1162 sum = base - offset;

1163 else

1164 sum = base + offset;

1165

1168 else

1170}

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1189

1190

1191

1192

1193

1196{

1199

1200 result = (float4) num;

1203 if (unlikely(result == 0.0f) && num != 0.0)

1205

1207}

1208

1209

1210

1211

1212

1215{

1217

1218

1219

1220

1221

1222

1223 num = rint(num);

1224

1225

1229 errmsg("integer out of range")));

1230

1232}

1233

1234

1235

1236

1237

1240{

1242

1243

1244

1245

1246

1247

1248 num = rint(num);

1249

1250

1254 errmsg("smallint out of range")));

1255

1257}

1258

1259

1260

1261

1262

1270

1271

1272

1273

1274

1282

1283

1284

1285

1286

1289{

1291

1292

1293

1294

1295

1296

1297 num = rint(num);

1298

1299

1303 errmsg("integer out of range")));

1304

1306}

1307

1308

1309

1310

1311

1314{

1316

1317

1318

1319

1320

1321

1322 num = rint(num);

1323

1324

1328 errmsg("smallint out of range")));

1329

1331}

1332

1333

1334

1335

1336

1344

1345

1346

1347

1348

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1374

1375

1376

1377

1378

1386

1387

1388

1389

1390

1398

1399

1400

1401

1402

1403

1406{

1409

1410 if (arg1 > 0)

1411 result = 1.0;

1412 else if (arg1 < 0)

1413 result = -1.0;

1414 else

1415 result = 0.0;

1416

1418}

1419

1420

1421

1422

1423

1424

1425

1426

1429{

1432

1433 if (arg1 >= 0)

1435 else

1437

1439}

1440

1441

1442

1443

1444

1447{

1450

1451 if (arg1 < 0)

1454 errmsg("cannot take square root of a negative number")));

1455

1461

1463}

1464

1465

1466

1467

1468

1483

1484

1485

1486

1487

1490{

1494

1495

1496

1497

1498

1499

1500

1502 {

1506 }

1508 {

1509 if (arg1 != 1.0)

1512 }

1513

1514

1515

1516

1517

1518

1522 errmsg("zero raised to a negative power is undefined")));

1526 errmsg("a negative number raised to a non-integer power yields a complex result")));

1527

1528

1529

1530

1531

1532

1534 {

1536

1537 if (absx == 1.0)

1538 result = 1.0;

1539 else if (arg2 > 0.0)

1540 {

1541 if (absx > 1.0)

1542 result = arg2;

1543 else

1544 result = 0.0;

1545 }

1546 else

1547 {

1548 if (absx > 1.0)

1549 result = 0.0;

1550 else

1551 result = -arg2;

1552 }

1553 }

1555 {

1556 if (arg2 == 0.0)

1557 result = 1.0;

1558 else if (arg1 > 0.0)

1559 {

1560 if (arg2 > 0.0)

1561 result = arg1;

1562 else

1563 result = 0.0;

1564 }

1565 else

1566 {

1567

1568

1569

1570

1571

1572

1573 float8 halfy = arg2 / 2;

1575

1576 if (arg2 > 0.0)

1578 else

1580 }

1581 }

1582 else

1583 {

1584

1585

1586

1587

1588

1589

1590

1594 {

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606 if (arg1 == 0.0)

1607 result = 0.0;

1608 else

1609 {

1611

1612 if (absx == 1.0)

1613 result = 1.0;

1614 else if (arg2 >= 0.0 ? (absx > 1.0) : (absx < 1.0))

1616 else

1618 }

1619 }

1621 {

1622 if (result != 0.0)

1624 else

1626 }

1627 else

1628 {

1633 }

1634 }

1635

1637}

1638

1639

1640

1641

1642

1645{

1648

1649

1650

1651

1652

1653

1655 result = arg1;

1657 {

1658

1659 result = (arg1 > 0.0) ? arg1 : 0;

1660 }

1661 else

1662 {

1663

1664

1665

1666

1670 {

1671 if (result != 0.0)

1673 else

1675 }

1678 else if (unlikely(result == 0.0))

1680 }

1681

1683}

1684

1685

1686

1687

1688

1691{

1694

1695

1696

1697

1698

1699 if (arg1 == 0.0)

1702 errmsg("cannot take logarithm of zero")));

1703 if (arg1 < 0)

1706 errmsg("cannot take logarithm of a negative number")));

1707

1713

1715}

1716

1717

1718

1719

1720

1723{

1726

1727

1728

1729

1730

1731

1732 if (arg1 == 0.0)

1735 errmsg("cannot take logarithm of zero")));

1736 if (arg1 < 0)

1739 errmsg("cannot take logarithm of a negative number")));

1740

1746

1748}

1749

1750

1751

1752

1753

1756{

1759

1760

1763

1764

1765

1766

1767

1768

1772 errmsg("input is out of range")));

1773

1777

1779}

1780

1781

1782

1783

1784

1787{

1790

1791

1794

1795

1796

1797

1798

1799

1803 errmsg("input is out of range")));

1804

1808

1810}

1811

1812

1813

1814

1815

1818{

1821

1822

1825

1826

1827

1828

1829

1830

1834

1836}

1837

1838

1839

1840

1841

1844{

1848

1849

1852

1853

1854

1855

1856

1860

1862}

1863

1864

1865

1866

1867

1870{

1873

1874

1877

1878

1879

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1898 errmsg("input is out of range")));

1901

1903}

1904

1905

1906

1907

1908

1911{

1914

1915

1918

1919

1925 errmsg("input is out of range")));

1926

1927 result = 1.0 / result;

1928

1929

1931}

1932

1933

1934

1935

1936

1939{

1942

1943

1946

1947

1953 errmsg("input is out of range")));

1956

1958}

1959

1960

1961

1962

1963

1966{

1969

1970

1973

1974

1980 errmsg("input is out of range")));

1981

1982

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

2018static void

2030

2031#define INIT_DEGREE_CONSTANTS() \

2032do { \

2033 if (!degree_consts_set) \

2034 init_degree_constants(); \

2035} while(0)

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047static double

2049{

2050

2051

2052

2053

2054

2055

2056 if (x <= 0.5)

2057 {

2059

2061 }

2062 else

2063 {

2065

2067 }

2068}

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080static double

2082{

2083

2084

2085

2086

2087

2088

2089 if (x <= 0.5)

2090 {

2092

2094 }

2095 else

2096 {

2098

2100 }

2101}

2102

2103

2104

2105

2106

2109{

2112

2113

2116

2118

2119

2120

2121

2122

2123

2127 errmsg("input is out of range")));

2128

2129 if (arg1 >= 0.0)

2131 else

2133

2136

2138}

2139

2140

2141

2142

2143

2146{

2149

2150

2153

2155

2156

2157

2158

2159

2160

2164 errmsg("input is out of range")));

2165

2166 if (arg1 >= 0.0)

2168 else

2170

2173

2175}

2176

2177

2178

2179

2180

2183{

2187

2188

2191

2193

2194

2195

2196

2197

2198

2199

2202

2205

2207}

2208

2209

2210

2211

2212

2215{

2220

2221

2224

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2238

2241

2243}

2244

2245

2246

2247

2248

2249

2250

2251static double

2258

2259

2260

2261

2262

2263

2264

2265static double

2272

2273

2274

2275

2276

2277

2278static double

2280{

2281

2282

2283

2284

2285

2286

2287 if (x <= 30.0)

2289 else

2291}

2292

2293

2294

2295

2296

2297

2298static double

2300{

2301

2302

2303

2304

2305

2306

2307 if (x <= 60.0)

2309 else

2311}

2312

2313

2314

2315

2316

2319{

2322 int sign = 1;

2323

2324

2325

2326

2327

2330

2334 errmsg("input is out of range")));

2335

2337

2338

2340

2341 if (arg1 < 0.0)

2342 {

2343

2345 }

2346

2347 if (arg1 > 180.0)

2348 {

2349

2351 }

2352

2353 if (arg1 > 90.0)

2354 {

2355

2358 }

2359

2361

2364

2366}

2367

2368

2369

2370

2371

2374{

2378 int sign = 1;

2379

2380

2381

2382

2383

2386

2390 errmsg("input is out of range")));

2391

2393

2394

2396

2397 if (arg1 < 0.0)

2398 {

2399

2402 }

2403

2404 if (arg1 > 180.0)

2405 {

2406

2409 }

2410

2411 if (arg1 > 90.0)

2412 {

2413

2416 }

2417

2420

2421

2422

2423

2424

2425

2426 if (result == 0.0)

2427 result = 0.0;

2428

2429

2430

2432}

2433

2434

2435

2436

2437

2440{

2443 int sign = 1;

2444

2445

2446

2447

2448

2451

2455 errmsg("input is out of range")));

2456

2458

2459

2461

2462 if (arg1 < 0.0)

2463 {

2464

2467 }

2468

2469 if (arg1 > 180.0)

2470 {

2471

2474 }

2475

2476 if (arg1 > 90.0)

2477 {

2478

2480 }

2481

2483

2486

2488}

2489

2490

2491

2492

2493

2496{

2500 int sign = 1;

2501

2502

2503

2504

2505

2508

2512 errmsg("input is out of range")));

2513

2515

2516

2518

2519 if (arg1 < 0.0)

2520 {

2521

2524 }

2525

2526 if (arg1 > 180.0)

2527 {

2528

2531 }

2532

2533 if (arg1 > 90.0)

2534 {

2535

2538 }

2539

2542

2543

2544

2545

2546

2547

2548 if (result == 0.0)

2549 result = 0.0;

2550

2551

2552

2554}

2555

2556

2557

2558

2559

2567

2568

2569

2570

2571

2577

2578

2579

2580

2581

2589

2590

2591

2592

2593

2594

2595

2596

2599{

2602

2605

2606

2607

2608

2609

2610

2612 {

2613 if (arg1 < 0)

2615 else

2617 }

2618

2620}

2621

2622

2623

2624

2625

2628{

2631

2634

2635

2636

2637

2638

2641

2642 if (unlikely(result == 0.0))

2644

2646}

2647

2648

2649

2650

2653{

2656

2657

2658

2659

2661

2664

2666}

2667

2668

2669

2670

2673{

2676

2677

2678

2679

2681

2683}

2684

2685

2686

2687

2690{

2693

2694

2695

2696

2697

2698

2699

2700 if (arg1 < 1.0)

2703 errmsg("input is out of range")));

2704

2706

2708}

2709

2710

2711

2712

2715{

2718

2719

2720

2721

2722

2723

2727 errmsg("input is out of range")));

2728

2729

2730

2731

2732

2733

2734 if (arg1 == -1.0)

2736 else if (arg1 == 1.0)

2738 else

2740

2742}

2743

2744

2745

2746

2747

2748

2749

2750

2753{

2756

2757

2758

2759

2761

2764

2766}

2767

2768

2769

2770

2773{

2776

2777

2778

2779

2781

2784

2786}

2787

2788

2789

2790

2791

2792

2793

2794

2797{

2800

2801

2802

2803

2804

2806 result = arg1;

2808 {

2809

2810 if (arg1 < 0)

2811 {

2813 result = get_float8_nan();

2814 }

2815 else

2816 result = arg1;

2817 }

2818 else

2819 {

2820

2821

2822

2823

2824

2825

2826

2827

2830

2832 {

2833 if (result != 0.0)

2835 else

2837 }

2838 else if (result == 0.0)

2840 }

2841

2843}

2844

2845

2846

2847

2848

2851{

2854

2855

2856#if defined(_AIX)

2859#endif

2860

2861

2862

2863

2864

2865

2868

2869

2870

2871

2872

2873

2874

2875

2878

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

2934{

2935

2936

2937

2938

2939

2944 elog(ERROR, "%s: expected %d-element float8 array", caller, n);

2946}

2947

2948

2949

2950

2951

2952

2953

2954

2955

2958{

2969 tmp,

2970 N,

2973

2976

2980

2984

2985

2986

2987

2988

2989

2990

2991

2992

2993

2994

2995

2996

2997

2998 if (N1 == 0.0)

2999 {

3000 N = N2;

3003 }

3004 else if (N2 == 0.0)

3005 {

3006 N = N1;

3009 }

3010 else

3011 {

3012 N = N1 + N2;

3018 }

3019

3020

3021

3022

3023

3024

3026 {

3030

3032 }

3033 else

3034 {

3037

3041

3043

3045 }

3046}

3047

3050{

3057 tmp;

3058

3063

3064

3065

3066

3067

3068 N += 1.0;

3071 {

3074

3075

3076

3077

3078

3079

3080

3082 {

3085

3087 }

3088 }

3089 else

3090 {

3091

3092

3093

3094

3095

3096

3099 }

3100

3101

3102

3103

3104

3105

3107 {

3111

3113 }

3114 else

3115 {

3118

3122

3124

3126 }

3127}

3128

3131{

3133

3134

3140 tmp;

3141

3146

3147

3148

3149

3150

3151 N += 1.0;

3154 {

3157

3158

3159

3160

3161

3162

3163

3165 {

3168

3170 }

3171 }

3172 else

3173 {

3174

3175

3176

3177

3178

3179

3182 }

3183

3184

3185

3186

3187

3188

3190 {

3194

3196 }

3197 else

3198 {

3201

3205

3207

3209 }

3210}

3211

3214{

3219

3223

3224

3225

3226 if (N == 0.0)

3228

3230}

3231

3234{

3239

3242

3244

3245

3246 if (N == 0.0)

3248

3249

3250

3252}

3253

3256{

3261

3264

3266

3267

3268 if (N <= 1.0)

3270

3271

3272

3274}

3275

3278{

3283

3286

3288

3289

3290 if (N == 0.0)

3292

3293

3294

3296}

3297

3300{

3305

3308

3310

3311

3312 if (N <= 1.0)

3314

3315

3316

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

3355{

3371

3381

3382

3383

3384

3385

3386 N += 1.0;

3390 {

3391

3392

3393

3394

3395

3400

3404

3405

3406

3407

3408

3409

3410

3411

3418

3419

3420

3421

3422

3423

3424

3426 {

3435

3442 }

3443 }

3444 else

3445 {

3446

3447

3448

3449

3450

3451

3456

3459 }

3460

3461

3462

3463

3464

3465

3467 {

3476

3478 }

3479 else

3480 {

3483

3492

3494

3496 }

3497}

3498

3499

3500

3501

3502

3503

3504

3505

3506

3509{

3532 N,

3540

3543

3552

3561

3562

3563

3564

3565

3566

3567

3568

3569

3570

3571

3572

3573

3574

3575

3576

3577

3578 if (N1 == 0.0)

3579 {

3580 N = N2;

3588 }

3589 else if (N2 == 0.0)

3590 {

3591 N = N1;

3599 }

3600 else

3601 {

3602 N = N1 + N2;

3618 else

3622 else

3624 }

3625

3626

3627

3628

3629

3630

3632 {

3641

3643 }

3644 else

3645 {

3648

3657

3659

3661 }

3662}

3663

3664

3667{

3672

3676

3677

3678 if (N < 1.0)

3680

3681

3682

3684}

3685

3688{

3693

3697

3698

3699 if (N < 1.0)

3701

3702

3703

3705}

3706

3709{

3714

3718

3719

3720 if (N < 1.0)

3722

3723

3724

3726}

3727

3730{

3736

3741

3742

3743 if (N < 1.0)

3745

3746

3749

3751}

3752

3755{

3761

3766

3767

3768 if (N < 1.0)

3770

3771

3774

3776}

3777

3780{

3785

3789

3790

3791 if (N < 1.0)

3793

3795}

3796

3799{

3804

3808

3809

3810 if (N < 2.0)

3812

3814}

3815

3818{

3827 result;

3828

3834

3835

3836 if (N < 1.0)

3838

3839

3840

3841

3842 if (Sxx == 0 || Syy == 0)

3844

3845

3846

3847

3848

3849

3850

3854 else

3857

3858

3859

3860

3861

3862 if (result < -1)

3863 result = -1;

3864 else if (result > 1)

3865 result = 1;

3866

3868}

3869

3872{

3879

3885

3886

3887 if (N < 1.0)

3889

3890

3891

3892

3893 if (Sxx == 0)

3895

3896

3897 if (Syy == 0)

3899

3901}

3902

3905{

3911

3916

3917

3918 if (N < 1.0)

3920

3921

3922

3923

3924 if (Sxx == 0)

3926

3928}

3929

3932{

3940

3947

3948

3949 if (N < 1.0)

3951

3952

3953

3954

3955 if (Sxx == 0)

3957

3959}

3960

3961

3962

3963

3964

3965

3966

3967

3968

3969

3970

3971

3972

3973

3982

3991

4000

4009

4010

4011

4012

4013

4014

4015

4024

4033

4042

4051

4052

4053

4054

4055

4056

4057

4058

4059

4060

4069

4078

4087

4096

4105

4114

4115

4116

4117

4126

4135

4144

4153

4162

4171

4172

4173

4174

4175

4176

4177

4178

4179

4180

4181

4182

4183

4184

4185

4186

4189{

4195

4196 if (count <= 0)

4199 errmsg("count must be greater than zero")));

4200

4204 errmsg("lower and upper bounds cannot be NaN")));

4205

4209 errmsg("lower and upper bounds must be finite")));

4210

4212 {

4213 if (isnan(operand) || operand >= bound2)

4214 {

4218 errmsg("integer out of range")));

4219 }

4220 else if (operand < bound1)

4221 result = 0;

4222 else

4223 {

4225 {

4226

4228 }

4229 else

4230 {

4231

4232

4233

4234

4235

4236

4237

4238

4239

4240 result = count * ((operand / 2 - bound1 / 2) / (bound2 / 2 - bound1 / 2));

4241 }

4242

4243 if (result >= count)

4244 result = count - 1;

4245

4246 result++;

4247 }

4248 }

4250 {

4252 result = 0;

4253 else if (operand <= bound2)

4254 {

4258 errmsg("integer out of range")));

4259 }

4260 else

4261 {

4264 else

4265 result = count * ((bound1 / 2 - operand / 2) / (bound1 / 2 - bound2 / 2));

4266 if (result >= count)

4267 result = count - 1;

4268 result++;

4269 }

4270 }

4271 else

4272 {

4275 errmsg("lower bound cannot equal upper bound")));

4276 result = 0;

4277 }

4278

4280}

#define PG_GETARG_ARRAYTYPE_P(n)

#define PG_RETURN_ARRAYTYPE_P(x)

ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)

#define FLOAT4_FITS_IN_INT32(num)

#define FLOAT8_FITS_IN_INT32(num)

#define FLOAT4_FITS_IN_INT16(num)

#define FLOAT8_FITS_IN_INT16(num)

int double_to_shortest_decimal_buf(double f, char *result)

int errcode(int sqlerrcode)

#define ereturn(context, dummy_value,...)

#define ereport(elevel,...)

int float_to_shortest_decimal_buf(float f, char *result)

float8 float8in_internal(char *num, char **endptr_p, const char *type_name, const char *orig_string, struct Node *escontext)

Datum float4lt(PG_FUNCTION_ARGS)

Datum dceil(PG_FUNCTION_ARGS)

Datum btfloat4cmp(PG_FUNCTION_ARGS)

Datum float84gt(PG_FUNCTION_ARGS)

Datum dasinh(PG_FUNCTION_ARGS)

Datum float84mi(PG_FUNCTION_ARGS)

static double sind_0_to_30(double x)

Datum dtof(PG_FUNCTION_ARGS)

Datum radians(PG_FUNCTION_ARGS)

pg_noinline void float_zero_divide_error(void)

pg_noinline void float_overflow_error(void)

Datum width_bucket_float8(PG_FUNCTION_ARGS)

Datum dasind(PG_FUNCTION_ARGS)

Datum float8_var_samp(PG_FUNCTION_ARGS)

Datum btfloat84cmp(PG_FUNCTION_ARGS)

Datum ftoi4(PG_FUNCTION_ARGS)

Datum dsind(PG_FUNCTION_ARGS)

Datum datan2(PG_FUNCTION_ARGS)

Datum derfc(PG_FUNCTION_ARGS)

Datum float8div(PG_FUNCTION_ARGS)

Datum float8_regr_syy(PG_FUNCTION_ARGS)

Datum float48gt(PG_FUNCTION_ARGS)

Datum degrees(PG_FUNCTION_ARGS)

Datum btfloat4sortsupport(PG_FUNCTION_ARGS)

Datum dlgamma(PG_FUNCTION_ARGS)

Datum dacosd(PG_FUNCTION_ARGS)

static double acosd_q1(double x)

Datum float8_regr_r2(PG_FUNCTION_ARGS)

Datum float8_regr_combine(PG_FUNCTION_ARGS)

Datum float8_regr_slope(PG_FUNCTION_ARGS)

Datum float8eq(PG_FUNCTION_ARGS)

Datum dtanh(PG_FUNCTION_ARGS)

static double cosd_q1(double x)

Datum dlog10(PG_FUNCTION_ARGS)

Datum float84mul(PG_FUNCTION_ARGS)

static bool degree_consts_set

Datum datanh(PG_FUNCTION_ARGS)

Datum dcosd(PG_FUNCTION_ARGS)

static int btfloat8fastcmp(Datum x, Datum y, SortSupport ssup)

Datum derf(PG_FUNCTION_ARGS)

Datum float4up(PG_FUNCTION_ARGS)

Datum float48pl(PG_FUNCTION_ARGS)

Datum dsinh(PG_FUNCTION_ARGS)

Datum float8_combine(PG_FUNCTION_ARGS)

Datum float8_avg(PG_FUNCTION_ARGS)

Datum float8_covar_pop(PG_FUNCTION_ARGS)

Datum dtan(PG_FUNCTION_ARGS)

Datum float8ge(PG_FUNCTION_ARGS)

Datum float8_stddev_pop(PG_FUNCTION_ARGS)

static double asind_q1(double x)

Datum dround(PG_FUNCTION_ARGS)

Datum float4um(PG_FUNCTION_ARGS)

Datum dlog1(PG_FUNCTION_ARGS)

Datum datan2d(PG_FUNCTION_ARGS)

Datum float4abs(PG_FUNCTION_ARGS)

Datum ftod(PG_FUNCTION_ARGS)

Datum float4mul(PG_FUNCTION_ARGS)

Datum float4le(PG_FUNCTION_ARGS)

Datum dcos(PG_FUNCTION_ARGS)

Datum float8_regr_intercept(PG_FUNCTION_ARGS)

Datum float8out(PG_FUNCTION_ARGS)

Datum float84le(PG_FUNCTION_ARGS)

Datum dexp(PG_FUNCTION_ARGS)

Datum float8pl(PG_FUNCTION_ARGS)

Datum float8lt(PG_FUNCTION_ARGS)

Datum float4gt(PG_FUNCTION_ARGS)

Datum float4out(PG_FUNCTION_ARGS)

#define INIT_DEGREE_CONSTANTS()

Datum dsign(PG_FUNCTION_ARGS)

Datum float8recv(PG_FUNCTION_ARGS)

Datum float4send(PG_FUNCTION_ARGS)

Datum float4ne(PG_FUNCTION_ARGS)

Datum float84eq(PG_FUNCTION_ARGS)

Datum float84lt(PG_FUNCTION_ARGS)

Datum float48mi(PG_FUNCTION_ARGS)

Datum float8le(PG_FUNCTION_ARGS)

Datum dtrunc(PG_FUNCTION_ARGS)

Datum btfloat8cmp(PG_FUNCTION_ARGS)

Datum float8in(PG_FUNCTION_ARGS)

Datum float8ne(PG_FUNCTION_ARGS)

Datum dpow(PG_FUNCTION_ARGS)

Datum float8mi(PG_FUNCTION_ARGS)

static double sind_q1(double x)

Datum ftoi2(PG_FUNCTION_ARGS)

Datum float4mi(PG_FUNCTION_ARGS)

Datum float8_accum(PG_FUNCTION_ARGS)

Datum float48eq(PG_FUNCTION_ARGS)

Datum i2tof(PG_FUNCTION_ARGS)

static float8 one_minus_cos_60

Datum float84pl(PG_FUNCTION_ARGS)

Datum btfloat48cmp(PG_FUNCTION_ARGS)

Datum float48ge(PG_FUNCTION_ARGS)

Datum float84div(PG_FUNCTION_ARGS)

Datum dcotd(PG_FUNCTION_ARGS)

pg_noinline void float_underflow_error(void)

Datum float8smaller(PG_FUNCTION_ARGS)

float8 degree_c_forty_five

Datum dsqrt(PG_FUNCTION_ARGS)

Datum float84ge(PG_FUNCTION_ARGS)

Datum float8_stddev_samp(PG_FUNCTION_ARGS)

Datum datand(PG_FUNCTION_ARGS)

Datum float8larger(PG_FUNCTION_ARGS)

Datum dcbrt(PG_FUNCTION_ARGS)

Datum float4in(PG_FUNCTION_ARGS)

static int btfloat4fastcmp(Datum x, Datum y, SortSupport ssup)

Datum float8_regr_sxy(PG_FUNCTION_ARGS)

Datum float8_var_pop(PG_FUNCTION_ARGS)

Datum float48div(PG_FUNCTION_ARGS)

Datum float84ne(PG_FUNCTION_ARGS)

Datum float4_accum(PG_FUNCTION_ARGS)

Datum float8up(PG_FUNCTION_ARGS)

int float4_cmp_internal(float4 a, float4 b)

Datum float48le(PG_FUNCTION_ARGS)

Datum float8_regr_sxx(PG_FUNCTION_ARGS)

Datum float8_corr(PG_FUNCTION_ARGS)

Datum float4recv(PG_FUNCTION_ARGS)

Datum in_range_float8_float8(PG_FUNCTION_ARGS)

Datum float48ne(PG_FUNCTION_ARGS)

Datum dpi(PG_FUNCTION_ARGS)

float4 float4in_internal(char *num, char **endptr_p, const char *type_name, const char *orig_string, struct Node *escontext)

Datum dacos(PG_FUNCTION_ARGS)

Datum float48lt(PG_FUNCTION_ARGS)

static void init_degree_constants(void)

Datum dgamma(PG_FUNCTION_ARGS)

Datum float8mul(PG_FUNCTION_ARGS)

Datum float4div(PG_FUNCTION_ARGS)

Datum in_range_float4_float8(PG_FUNCTION_ARGS)

Datum dtand(PG_FUNCTION_ARGS)

Datum float8abs(PG_FUNCTION_ARGS)

Datum i4tod(PG_FUNCTION_ARGS)

int is_infinite(double val)

Datum i2tod(PG_FUNCTION_ARGS)

Datum dfloor(PG_FUNCTION_ARGS)

Datum btfloat8sortsupport(PG_FUNCTION_ARGS)

Datum dcosh(PG_FUNCTION_ARGS)

Datum dacosh(PG_FUNCTION_ARGS)

Datum float4ge(PG_FUNCTION_ARGS)

Datum dasin(PG_FUNCTION_ARGS)

Datum i4tof(PG_FUNCTION_ARGS)

Datum datan(PG_FUNCTION_ARGS)

Datum float8gt(PG_FUNCTION_ARGS)

Datum float8_regr_avgx(PG_FUNCTION_ARGS)

Datum float8um(PG_FUNCTION_ARGS)

Datum float8_regr_avgy(PG_FUNCTION_ARGS)

Datum dcot(PG_FUNCTION_ARGS)

Datum dsin(PG_FUNCTION_ARGS)

Datum dtoi4(PG_FUNCTION_ARGS)

Datum float4pl(PG_FUNCTION_ARGS)

Datum float8_covar_samp(PG_FUNCTION_ARGS)

Datum float8send(PG_FUNCTION_ARGS)

Datum float4larger(PG_FUNCTION_ARGS)

Datum dtoi2(PG_FUNCTION_ARGS)

static float8 * check_float8_array(ArrayType *transarray, const char *caller, int n)

static double cosd_0_to_60(double x)

Datum float48mul(PG_FUNCTION_ARGS)

Datum float4smaller(PG_FUNCTION_ARGS)

Datum float8_regr_accum(PG_FUNCTION_ARGS)

char * float8out_internal(double num)

int float8_cmp_internal(float8 a, float8 b)

Datum float4eq(PG_FUNCTION_ARGS)

static float8 float8_mul(const float8 val1, const float8 val2)

static float4 float4_div(const float4 val1, const float4 val2)

#define RADIANS_PER_DEGREE

static float4 get_float4_infinity(void)

static bool float4_lt(const float4 val1, const float4 val2)

static float8 float8_pl(const float8 val1, const float8 val2)

static float8 float8_mi(const float8 val1, const float8 val2)

static bool float4_ge(const float4 val1, const float4 val2)

static float4 get_float4_nan(void)

static bool float8_ne(const float8 val1, const float8 val2)

static bool float4_ne(const float4 val1, const float4 val2)

static float4 float4_pl(const float4 val1, const float4 val2)

static bool float4_eq(const float4 val1, const float4 val2)

static float4 float4_mul(const float4 val1, const float4 val2)

static float8 get_float8_infinity(void)

static bool float8_ge(const float8 val1, const float8 val2)

static float4 float4_mi(const float4 val1, const float4 val2)

static bool float8_le(const float8 val1, const float8 val2)

static bool float4_gt(const float4 val1, const float4 val2)

static bool float8_eq(const float8 val1, const float8 val2)

static bool float4_le(const float4 val1, const float4 val2)

static float8 get_float8_nan(void)

static float8 float8_div(const float8 val1, const float8 val2)

static bool float8_lt(const float8 val1, const float8 val2)

static bool float8_gt(const float8 val1, const float8 val2)

#define PG_RETURN_BYTEA_P(x)

#define PG_GETARG_FLOAT8(n)

#define PG_RETURN_FLOAT8(x)

#define PG_GETARG_POINTER(n)

#define PG_RETURN_CSTRING(x)

#define PG_GETARG_CSTRING(n)

#define PG_RETURN_INT16(x)

#define PG_RETURN_INT32(x)

#define PG_GETARG_INT32(n)

#define PG_GETARG_BOOL(n)

#define PG_GETARG_FLOAT4(n)

#define PG_RETURN_FLOAT4(x)

#define PG_RETURN_BOOL(x)

#define PG_GETARG_INT16(n)

static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)

char * pstrdup(const char *in)

int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)

Datum ascii(PG_FUNCTION_ARGS)

static char buf[DEFAULT_XLOG_SEG_SIZE]

int pg_strfromd(char *str, size_t count, int precision, double value)

int pg_strncasecmp(const char *s1, const char *s2, size_t n)

static float4 DatumGetFloat4(Datum X)

#define Float8GetDatumFast(X)

static float8 DatumGetFloat8(Datum X)

float4 pq_getmsgfloat4(StringInfo msg)

float8 pq_getmsgfloat8(StringInfo msg)

void pq_begintypsend(StringInfo buf)

void pq_sendfloat4(StringInfo buf, float4 f)

bytea * pq_endtypsend(StringInfo buf)

void pq_sendfloat8(StringInfo buf, float8 f)

struct SortSupportData * SortSupport

struct StringInfoData * StringInfo

int(* comparator)(Datum x, Datum y, SortSupport ssup)