This file is indexed.

/usr/lib/firebird/2.5/UDF/ib_udf2.sql is in firebird2.5-server-common 2.5.4.26856.ds4-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
/*
 * The contents of this file are subject to the Interbase Public
 * License Version 1.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy
 * of the License at http://www.Inprise.com/IPL.html
 *
 * Software distributed under the License is distributed on an
 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
 * or implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code was created by Inprise Corporation
 * and its predecessors. Portions created by Inprise Corporation are
 * Copyright (C) Inprise Corporation.
 *
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 * Revision 1.2  2000/11/28 06:47:52  fsg
 * Changed declaration of ascii_char in ib_udf.sql
 * to get correct result as proposed by Claudio Valderrama
 * 2001.5.19 Claudio Valderrama, add the declaration of alternative
 * substrlen function to handle string,start,length instead.
 * 2004.9.1 Claudio Valderrama, changed some UDF's to be able to detect NULL
 * and renamed the resulting file as ib_udf2.sql.
 *
 */
/*****************************************
 *
 *	a b s
 *
 *****************************************
 *
 * Functional description:
 * 	Returns the absolute value of a
 * 	number.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION abs
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	a c o s
 *
 *****************************************
 *
 * Functional description:
 *	Returns the arccosine of a number
 *	between -1 and 1, if the number is
 *	out of bounds it returns NaN, as handled
 *	by the _matherr routine.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION acos
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_acos' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	a s c i i _ c h a r
 *
 *****************************************
 *
 * Functional description:
 *	Returns the ASCII character corresponding
 *	with the value passed in.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION ascii_char
	INTEGER NULL
	RETURNS CSTRING(1) FREE_IT
	ENTRY_POINT 'IB_UDF_ascii_char' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	a s c i i _ v a l
 *
 *****************************************
 *
 * Functional description:
 *	Returns the ascii value of the character
 * 	passed in.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION ascii_val
	CHAR(1)
	RETURNS INTEGER BY VALUE
	ENTRY_POINT 'IB_UDF_ascii_val' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	a s i n
 *
 *****************************************
 *
 * Functional description:
 *	Returns the arcsin of a number between
 *	-1 and 1, if the number is out of
 *	range NaN is returned.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION asin
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_asin' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	a t a n
 *
 *****************************************
 *
 * Functional description:
 *	Returns the arctangent of a number.
 *
 *
 *****************************************
DECLARE EXTERNAL FUNCTION atan
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_atan' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	a t a n 2
 *
 *****************************************
 *
 * Functional description:
 * 	Returns the arctangent of the
 *	first param / the second param.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION atan2
	DOUBLE PRECISION, DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_atan2' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	b i n _ a n d
 *
 *****************************************
 *
 * Functional description:
 *	Returns the result of a binary AND
 *	operation performed on the two numbers.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION bin_and
	INTEGER, INTEGER
	RETURNS INTEGER BY VALUE
	ENTRY_POINT 'IB_UDF_bin_and' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	b i n _ o r
 *
 *****************************************
 *
 * Functional description:
 *	Returns the result of a binary OR
 *	operation performed on the two numbers.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION bin_or
	INTEGER, INTEGER
	RETURNS INTEGER BY VALUE
	ENTRY_POINT 'IB_UDF_bin_or' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	b i n _ x o r
 *
 *****************************************
 *
 * Functional description:
 *	Returns the result of a binary XOR
 *	operation performed on the two numbers.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION bin_xor
	INTEGER, INTEGER
	RETURNS INTEGER BY VALUE
	ENTRY_POINT 'IB_UDF_bin_xor' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	c e i l i n g
 *
 *****************************************
 *
 * Functional description:
 *	Returns a double value representing
 *	the smallest integer that is greater
 *	than or equal to the input value.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION ceiling
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_ceiling' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	c o s
 *
 *****************************************
 *
 * Functional description:
 *	The cos function returns the cosine
 *	of x. If x is greater than or equal
 *	to 263, or less than or equal to -263,
 *	a loss of significance in the result
 *	of a call to cos occurs, in which case
 *	the function generates a _TLOSS error
 *	and returns an indefinite (same as a
 *	quiet NaN).
 *
 *****************************************
DECLARE EXTERNAL FUNCTION cos
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_cos' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	c o s h
 *
 *****************************************
 *
 * Functional description:
 *	The cosh function returns the hyperbolic cosine
 *	of x. If x is greater than or equal
 *	to 263, or less than or equal to -263,
 *	a loss of significance in the result
 *	of a call to cos occurs, in which case
 *	the function generates a _TLOSS error
 *	and returns an indefinite (same as a
 *	quiet NaN).
 *
 *****************************************
DECLARE EXTERNAL FUNCTION cosh
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_cosh' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	c o t
 *
 *****************************************
 *
 * Functional description:
 *	Returns 1 over the tangent of the
 *	input parameter.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION cot
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_cot' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	d i v
 *
 *****************************************
 *
 * Functional description:
 *	Returns the quotient part of the division
 *	of the two input parameters.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION div
	INTEGER, INTEGER
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_div' MODULE_NAME 'ib_udf';

/*****************************************
 *
 *	f l o o r
 *
 *****************************************
 *
 * Functional description:
 * 	Returns a floating-point value
 * 	representing the largest integer that
 *	is less than or equal to x.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION floor
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_floor' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	u d f _ f r a c
 *
 *****************************************
 *
 * Functional description:
 * 	Returns a floating-point value
 * 	representing the fractional part of x.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION udf_frac
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_frac' MODULE_NAME 'ib_udf';

/*****************************************
 *
 *	l n
 *
 *****************************************
 *
 * Functional description:
 *	Returns the natural log of a number.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION ln
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_ln' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	l o g
 *
 *****************************************
 *
 * Functional description:
 *	log (x,y) returns the logarithm
 *	base x of y.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION log
	DOUBLE PRECISION, DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_log' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	l o g 1 0
 *
 *****************************************
 *
 * Functional description:
 *	Returns the logarithm base 10 of the
 *	input parameter.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION log10
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_log10' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	l o w e r
 *
 *****************************************
 *
 * Functional description:
 *	Returns the input string into lower
 *	case characters.  Note: This function
 *	will not work with international and
 *	non-ascii characters.
 *	Note: This function is NOT limited to
 *	receiving and returning only 255 characters,
 *	rather, it can use as long as 32767
 * 	characters which is the limit on an
 *	INTERBASE character string.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION "LOWER"
	CSTRING(255) NULL
	RETURNS CSTRING(255) FREE_IT
	ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	l p a d
 *
 *****************************************
 *
 * Functional description:
 *	Appends the given character to beginning
 *	of the input string until length of the result
 *	string becomes equal to the given number.
 *	Note: This function is NOT limited to
 *	receiving and returning only 255 characters,
 *	rather, it can use as long as 32767
 * 	characters which is the limit on an
 *	INTERBASE character string.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION lpad
	CSTRING(255) NULL, INTEGER, CSTRING(1) NULL
	RETURNS CSTRING(255) FREE_IT
	ENTRY_POINT 'IB_UDF_lpad' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	l t r i m
 *
 *****************************************
 *
 * Functional description:
 *	Removes leading spaces from the input
 *	string.
 *	Note: This function is NOT limited to
 *	receiving and returning only 255 characters,
 *	rather, it can use as long as 32767
 * 	characters which is the limit on an
 *	INTERBASE character string.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION ltrim
	CSTRING(255) NULL
	RETURNS CSTRING(255) FREE_IT
	ENTRY_POINT 'IB_UDF_ltrim' MODULE_NAME 'ib_udf';

/*****************************************
 *
 *	m o d
 *
 *****************************************
 *
 * Functional description:
 *	Returns the remainder part of the
 *	division of the two input parameters.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION mod
	INTEGER, INTEGER
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_mod' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	p i
 *
 *****************************************
 *
 * Functional description:
 *	Returns the value of pi = 3.1459...
 *
 *****************************************
DECLARE EXTERNAL FUNCTION pi
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_pi' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	r a n d
 *
 *****************************************
 *
 * Functional description:
 *	Returns a random number between 0
 *	and 1.
 *
 *
 * Note: Use srand to seed the
 *	random number generator.
 *	This behavior has been changed.
 *****************************************
DECLARE EXTERNAL FUNCTION rand
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_rand' MODULE_NAME 'ib_udf'; */


/*****************************************
 *
 *	r p a d
 *
 *****************************************
 *
 * Functional description:
 *	Appends the given character to end
 *	of the input string until length of the result
 *	string becomes equal to the given number.
 *	Note: This function is NOT limited to
 *	receiving and returning only 255 characters,
 *	rather, it can use as long as 32767
 * 	characters which is the limit on an
 *	INTERBASE character string.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION rpad
	CSTRING(255) NULL, INTEGER, CSTRING(1) NULL
	RETURNS CSTRING(255) FREE_IT
	ENTRY_POINT 'IB_UDF_rpad' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	r t r i m
 *
 *****************************************
 *
 * Functional description:
 *	Removes trailing spaces from the input
 *	string.
 *	Note: This function is NOT limited to
 *	receiving and returning only 255 characters,
 *	rather, it can use as long as 32767
 * 	characters which is the limit on an
 *	INTERBASE character string.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION rtrim
	CSTRING(255) NULL
	RETURNS CSTRING(255) FREE_IT
	ENTRY_POINT 'IB_UDF_rtrim' MODULE_NAME 'ib_udf';

/*****************************************
 *
 *	s i g n
 *
 *****************************************
 *
 * Functional description:
 *	Returns 1, 0, or -1 depending on whether
 * 	the input value is positive, zero or
 *	negative, respectively.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION sign
	DOUBLE PRECISION
	RETURNS INTEGER BY VALUE
	ENTRY_POINT 'IB_UDF_sign' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	s i n
 *
 *****************************************
 *
 * Functional description:
 *	Returns the sine of x. If x is greater
 *	than or equal to 263, or less than or
 *	equal to -263, a loss of significance
 *	in the result occurs, in which case the
 *	function generates a _TLOSS error and
 *	returns an indefinite (same as a quiet NaN).
 *
 *****************************************
DECLARE EXTERNAL FUNCTION sin
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_sin' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	s i n h
 *
 *****************************************
 *
 * Functional description:
 *	Returns the hyperbolic sine of x. If x is greater
 *	than or equal to 263, or less than or
 *	equal to -263, a loss of significance
 *	in the result occurs, in which case the
 *	function generates a _TLOSS error and
 *	returns an indefinite (same as a quiet NaN).
 *
 *****************************************
DECLARE EXTERNAL FUNCTION sinh
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_sinh' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	s q r t
 *
 *****************************************
 *
 * Functional description:
 *	Returns the square root of a number.
 *
 *****************************************
DECLARE EXTERNAL FUNCTION sqrt
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_sqrt' MODULE_NAME 'ib_udf'; */


/*****************************************
 *
 *	s r a n d
 *
 *****************************************
 *
 * Functional description:
 *	Returns a random number between 0
 *	and 1.  Note the random number
 *	generator is seeded using the current
 *	time.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION srand
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_srand' MODULE_NAME 'ib_udf';


/*****************************************
 *
 *	s u b s t r
 *
 *****************************************
 *
 * Functional description:
 *	substr(s,m,n) returns the substring
 *	of s which starts at position m and
 *	ending at position n.
 *	Note: This function is NOT limited to
 *	receiving and returning only 255 characters,
 *	rather, it can use as long as 32767
 * 	characters which is the limit on an
 *	INTERBASE character string.
 *      Change by Claudio Valderrama: when n>length(s),
 *      the result will be the original string instead
 *      of NULL as it was originally designed.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION substr
	CSTRING(255) NULL, SMALLINT, SMALLINT
	RETURNS CSTRING(255) FREE_IT
	ENTRY_POINT 'IB_UDF_substr' MODULE_NAME 'ib_udf';

/*****************************************
 *
 *	s u b s t r l e n
 *
 *****************************************
 *
 * Functional description:
 *	substrlen(s,i,l) returns the substring
 *	of s which starts at position i and
 *	ends at position i+l-1, being l the length.
 *	Note: This function is NOT limited to
 *	receiving and returning only 255 characters,
 *	rather, it can use as long as 32767
 * 	characters which is the limit on an
 *	INTERBASE character string.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION substrlen
	CSTRING(255) NULL, SMALLINT, SMALLINT
	RETURNS CSTRING(255) FREE_IT
	ENTRY_POINT 'IB_UDF_substrlen' MODULE_NAME 'ib_udf';

/*****************************************
 *
 *	s t r l e n
 *
 *****************************************
 *
 * Functional description:
 *	Returns the length of a given string.
 *
 *****************************************/
DECLARE EXTERNAL FUNCTION strlen
	CSTRING(32767) CHARACTER SET NONE
	RETURNS INTEGER BY VALUE
	ENTRY_POINT 'IB_UDF_strlen' MODULE_NAME 'ib_udf';

/*****************************************
 *
 *	t a n
 *
 *****************************************
 *
 * Functional description:
 * 	Returns the tangent of x. If x is
 *	greater than or equal to 263, or less
 *	than or equal to -263, a loss of
 *	significance in the result occurs, in
 *	which case the function generates a
 *	_TLOSS error and returns an indefinite
 *	(same as a quiet NaN).
 *
 *****************************************
DECLARE EXTERNAL FUNCTION tan
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_tan' MODULE_NAME 'ib_udf'; */

/*****************************************
 *
 *	t a n h
 *
 *****************************************
 *
 * Functional description:
 * 	Returns the tangent of x. If x is
 *	greater than or equal to 263, or less
 *	than or equal to -263, a loss of
 *	significance in the result occurs, in
 *	which case the function generates a
 *	_TLOSS error and returns an indefinite
 *	(same as a quiet NaN).
 *
 *****************************************
DECLARE EXTERNAL FUNCTION tanh
	DOUBLE PRECISION
	RETURNS DOUBLE PRECISION BY VALUE
	ENTRY_POINT 'IB_UDF_tanh' MODULE_NAME 'ib_udf'; */