Skip to content

Current monetdbe (0.11) has an issue with function creation #158

@gijzelaerr

Description

@gijzelaerr
SQLException:sql.create_func:42000!CREATE FUNCTION: name 'afunkyfunc' (double) already in use
Traceback (most recent call last):
  File "/home/niels/y.py", line 14, in <module>
    res = cursor.execute(q)
  File "/home/niels/.local/lib/python3.9/site-packages/monetdbe/cursors.py", line 142, in execute
    return self._execute_monetdbe(operation, parameters)
  File "/home/niels/.local/lib/python3.9/site-packages/monetdbe/cursors.py", line 127, in _execute_monetdbe
    self.connection.result, self.rowcount = execute(statement, make_result=True)
  File "/home/niels/.local/lib/python3.9/site-packages/monetdbe/_cffi/internal.py", line 79, in execute
    check_error(lib.monetdbe_execute(statement, p_result, affected_rows))
  File "/home/niels/.local/lib/python3.9/site-packages/monetdbe/_cffi/errors.py", line 59, in check_error
    raise exception(msg)
monetdbe.exceptions.OperationalError: CREATE FUNCTION: name 'afunkyfunc' (double) already in use

ie the current monetdbe (0.11) has an issue with function creation, I seem to remember I fixed something for this (on default this is fixed, not sure how the status on jul branch is).

import monetdbe
import os
database = '/tmp/test.mdbe'
# Removes the database if it already exists
if os.path.exists(database):
    os.system(f'rm -rf {database}')
with monetdbe.connect(database) as conn:
    #conn.set_autocommit(True)
    cursor = conn.cursor()
    q = "create function afunkyfunc(a double) returns double begin return a/2; end"
    res = cursor.execute(q)
    res = cursor.execute("select afunkyfunc(1.0);")
    print(cursor.fetchone()[0])

is the test I used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions