Educational-MySQL / UDFs-written-in-Python

MySQL UDFs written in Python
GNU General Public License v3.0
2 stars 5 forks source link

Wrong result for factorial() function #3

Closed ShahriyarR closed 7 years ago

ShahriyarR commented 7 years ago

Checking result:

master [localhost] {msandbox} ((none)) > create function factorial returns integer soname 'factorial.so';
Query OK, 0 rows affected (0.00 sec)

master [localhost] {msandbox} ((none)) > select factorial(1);
+-----------------+
| factorial(1)    |
+-----------------+
| 139888427179520 |
+-----------------+
1 row in set (0.03 sec)

master [localhost] {msandbox} ((none)) > select factorial(2);
+-----------------+
| factorial(2)    |
+-----------------+
| 139888427179520 |
+-----------------+
1 row in set (0.01 sec)

From error log:

Version: '5.7.16-debug-log-valgrind'  socket: '/tmp/mysql_sandbox19991.sock'  port: 19991  Shahriyar Rzayev's Ubuntu 16.04 MySQL-5.7
python: can't open file 'factorial.py': [Errno 2] No such file or directory
python: can't open file 'factorial.py': [Errno 2] No such file or directory
python: can't open file 'factorial.py': [Errno 2] No such file or directory
python: can't open file 'factorial.py': [Errno 2] No such file or directory
python: can't open file 'factorial.py': [Errno 2] No such file or directory
python: can't open file 'factorial.py': [Errno 2] No such file or directory
python: can't open file 'factorial.py': [Errno 2] No such file or directory
python: can't open file 'factorial.py': [Errno 2] No such file or directory
ShahriyarR commented 7 years ago

After hard coding the full path for python script it works. But it will be great to append plugin_dir/python_script.py dynamically inside code.

ShahriyarR commented 7 years ago

Fixed as: extern char *opt_plugin_dir_ptr is a pointer to plugin_dir. We can use this, by appending 'factorial.py'.

Closing.