[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-internals
Subject:    Re: Native Functions in mysql 3.23.52 in Win32
From:       "Nick Kostirya" <nick () han ! kherson ! ua>
Date:       2002-09-30 13:47:59
[Download RAW message or body]

> > In my quest to see whether I should use native functions or UDFs I have
> > spent a lot of time reading the mySQL documentation and the mailing
> > lists/groups.  I have seen very little mentioned about native functions
in
> > the groups etc.  I don't know if this is good or bad.  Once again (just
> > like the UDF) I have created a native function .  It's called NOTIFY.  I
> > inserted it in the middle of the sql_functions table in lex.h.
Strangely
> > enough after I compiled and linked the source, any function before
NOTIFY
> > would work.  Any function after NOTIFY would not work. (including
NOTIFY)
> > This tells me that there is probably some sort of index somewhere that I
am
> > not updating.  Unfortunately, if this is true then the manual does not
> > mention it.  Can anyone help me?  I would appreciate it very much.
Despite
> > some lack of information, I am still excited about using mySQL.

> This very much sounds like a bad build.
> If you change files like lex.h, make sure you do a "make clean", etc.
> Indeed there is an index, LEX/YACC assign all keywords a number. A clean
> build however should also rebuild those lists.

It was solve the problem. :-(.
1. unzip mysql-3.23.52-win-src.zip
2. patch < mynf.pache to add Native function
3. build...


mysql> SELECT VERSION() as VERSION;
ERROR 1064: You have an error in your SQL syntax near '() as VERSION' at
line 1
mysql>

mynf.pache attached.

Can anyone help me?

Best.
Nick.


######################
diff -u -x debug -x *.plg -x *.swp sql_old\item_create.cpp
sql\item_create.cpp
--- sql_old\item_create.cpp  Mon Aug 12 09:36:12 2002
+++ sql\item_create.cpp  Mon Sep 30 11:47:57 2002
@@ -22,6 +22,10 @@
 #define M_PI 3.14159265358979323846
 #endif

+Item *create_func_count_first(Item* a)
+{
+  return new Item_func_count_first(a);
+}
 Item *create_func_abs(Item* a)
 {
   return new Item_func_abs(a);
diff -u -x debug -x *.plg -x *.swp sql_old\item_create.h sql\item_create.h
--- sql_old\item_create.h  Mon Aug 12 09:36:12 2002
+++ sql\item_create.h  Mon Sep 30 11:37:17 2002
@@ -16,6 +16,7 @@

 /* Functions to create an item. Used by lex.h */

+Item *create_func_count_first(Item* a);
 Item *create_func_abs(Item* a);
 Item *create_func_acos(Item* a);
 Item *create_func_ascii(Item* a);
diff -u -x debug -x *.plg -x *.swp sql_old\item_func.cpp sql\item_func.cpp
--- sql_old\item_func.cpp  Mon Aug 12 09:36:12 2002
+++ sql\item_func.cpp  Mon Sep 30 11:47:54 2002
@@ -390,6 +390,28 @@
   hybrid_type= args[0]->result_type() == INT_RESULT ? INT_RESULT :
REAL_RESULT;
 }

+double Item_func_count_first ::val()
+{
+  double value=args[0]->val();
+  null_value=args[0]->null_value;
+  return fabs(value);
+}
+
+longlong Item_func_count_first ::val_int()
+{
+  longlong value=args[0]->val_int();
+  null_value=args[0]->null_value;
+  return value >= 0 ? value : -value;
+}
+
+void Item_func_count_first ::fix_length_and_dec()
+{
+  decimals=args[0]->decimals;
+  max_length=args[0]->max_length;
+  hybrid_type= args[0]->result_type() == INT_RESULT ? INT_RESULT :
REAL_RESULT;
+}
+
+
 double Item_func_abs::val()
 {
   double value=args[0]->val();
diff -u -x debug -x *.plg -x *.swp sql_old\item_func.h sql\item_func.h
--- sql_old\item_func.h  Mon Aug 12 09:36:12 2002
+++ sql\item_func.h  Mon Sep 30 11:46:32 2002
@@ -238,6 +238,17 @@
   void fix_length_and_dec();
 };

+class Item_func_count_first :public Item_num_func
+{
+public:
+  Item_func_count_first (Item *a) :Item_num_func(a) {}
+  const char *func_name() const { return "abs"; }
+  double val();
+  longlong val_int();
+  enum Item_result result_type () const
+  { return args[0]->result_type() == INT_RESULT ? INT_RESULT :
REAL_RESULT; }
+  void fix_length_and_dec();
+};

 class Item_func_abs :public Item_num_func
 {
diff -u -x debug -x *.plg -x *.swp sql_old\lex.h sql\lex.h
--- sql_old\lex.h  Mon Aug 12 09:36:10 2002
+++ sql\lex.h  Mon Sep 30 11:22:57 2002
@@ -353,6 +353,7 @@


 static SYMBOL sql_functions[] = {
+  { "COUNT_FIRST",  SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_count_first)},
   { "ABS",    SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_abs)},
   { "ACOS",    SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_acos)},
   { "ADDDATE",    SYM(DATE_ADD_INTERVAL),0,0},




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail internals-thread4840@lists.mysql.com
To unsubscribe, e-mail <internals-unsubscribe@lists.mysql.com>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic