home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win.exe / DATA1.CAB / Examples / examples / tests / udf_test.res < prev    next >
Text File  |  2000-11-22  |  2KB  |  152 lines

  1. --------------
  2. CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so"
  3. --------------
  4.  
  5. Query OK, 0 rows affected
  6.  
  7. --------------
  8. CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so"
  9. --------------
  10.  
  11. Query OK, 0 rows affected
  12.  
  13. --------------
  14. CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so"
  15. --------------
  16.  
  17. Query OK, 0 rows affected
  18.  
  19. --------------
  20. CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so"
  21. --------------
  22.  
  23. Query OK, 0 rows affected
  24.  
  25. --------------
  26. CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so"
  27. --------------
  28.  
  29. Query OK, 0 rows affected
  30.  
  31. --------------
  32. CREATE AGGREGATE FUNCTION avgcost RETURNS REAL SONAME "udf_example.so"
  33. --------------
  34.  
  35. Query OK, 0 rows affected
  36.  
  37. --------------
  38. select metaphon("hello")
  39. --------------
  40.  
  41. metaphon("hello")
  42. HL
  43. 1 row in set
  44.  
  45. --------------
  46. select myfunc_double("hello","world")
  47. --------------
  48.  
  49. myfunc_double("hello","world")
  50. 108.40
  51. 1 row in set
  52.  
  53. --------------
  54. select myfunc_int(1,2,3),myfunc_int("1","11","111")
  55. --------------
  56.  
  57. myfunc_int(1,2,3)    myfunc_int("1","11","111")
  58. 6    6
  59. 1 row in set
  60.  
  61. --------------
  62. select lookup("localhost")
  63. --------------
  64.  
  65. lookup("localhost")
  66. 127.0.0.1
  67. 1 row in set
  68.  
  69. --------------
  70. select reverse_lookup("127.0.0.1")
  71. --------------
  72.  
  73. reverse_lookup("127.0.0.1")
  74. localhost
  75. 1 row in set
  76.  
  77. --------------
  78. create temporary table t1 (a int,b double)
  79. --------------
  80.  
  81. Query OK, 0 rows affected
  82.  
  83. --------------
  84. insert into t1 values (1,5),(1,4),(2,8),(3,9),(4,11)
  85. --------------
  86.  
  87. Query OK, 5 rows affected
  88. Records: 0  Duplicates: 5  Warnings: 0
  89.  
  90. --------------
  91. select avgcost(a,b) from t1
  92. --------------
  93.  
  94. avgcost(a,b)
  95. 8.7273
  96. 1 row in set
  97.  
  98. --------------
  99. select avgcost(a,b) from t1 group by a
  100. --------------
  101.  
  102. avgcost(a,b)
  103. 4.5000
  104. 8.0000
  105. 9.0000
  106. 11.0000
  107. 4 rows in set
  108.  
  109. --------------
  110. drop table t1
  111. --------------
  112.  
  113. Query OK, 0 rows affected
  114.  
  115. --------------
  116. DROP FUNCTION metaphon
  117. --------------
  118.  
  119. Query OK, 0 rows affected
  120.  
  121. --------------
  122. DROP FUNCTION myfunc_double
  123. --------------
  124.  
  125. Query OK, 0 rows affected
  126.  
  127. --------------
  128. DROP FUNCTION myfunc_int
  129. --------------
  130.  
  131. Query OK, 0 rows affected
  132.  
  133. --------------
  134. DROP FUNCTION lookup
  135. --------------
  136.  
  137. Query OK, 0 rows affected
  138.  
  139. --------------
  140. DROP FUNCTION reverse_lookup
  141. --------------
  142.  
  143. Query OK, 0 rows affected
  144.  
  145. --------------
  146. DROP FUNCTION avgcost
  147. --------------
  148.  
  149. Query OK, 0 rows affected
  150.  
  151. Bye
  152.