Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16454 closed Bug (needsinfo)

sequence for AUTH_PERMISSION.ID

Reported by: alexei.vlassov@… Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Release blocker Keywords: oracle
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

manage.py syncdb fails with ORA-06552

Traceback (most recent call last):
  File "./manage.py", line 20, in <module>
    execute_manager(settings)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/__init__.py", line 442, in execute_manager
    utility.execute()
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/south/management/commands/syncdb.py", line 90, in handle_noargs
    syncdb.Command().execute(**options)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/commands/syncdb.py", line 109, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/core/management/sql.py", line 190, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/dispatch/dispatcher.py", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/contrib/auth/management/__init__.py", line 56, in create_permissions
    content_type=ctype
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/manager.py", line 138, in create
    return self.get_query_set().create(**kwargs)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/query.py", line 360, in create
    obj.save(force_insert=True, using=self.db)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/base.py", line 463, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/base.py", line 556, in save_base
    result = manager._insert(values, return_id=update_pk, using=using)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/manager.py", line 198, in _insert
    return insert_query(self.model, values, **kwargs)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/query.py", line 1456, in insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/sql/compiler.py", line 810, in execute_sql
    cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/models/sql/compiler.py", line 754, in execute_sql
    cursor.execute(sql, params)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/backends/util.py", line 34, in execute
    return self.cursor.execute(sql, params)
  File "/media/sf_workspace_python/djadmin/3rdparty/apps/django/db/backends/oracle/base.py", line 640, in execute
    return self.cursor.execute(query, self._param_generator(params))
django.db.utils.IntegrityError: ORA-01400: cannot insert NULL into ("***"."AUTH_PERMISSION"."ID")

params from django/db/backends/oracle/base.py line 640

INSERT INTO "AUTH_PERMISSION" ("NAME", "CONTENT_TYPE_ID", "CODENAME") VALUES (:arg0, :arg1, :arg2) RETURNING "AUTH_PERMISSION"."ID" INTO :arg3
['Can add permission', 1, 'add_permission', <cx_Oracle.NUMBER with value None>]

Django 1.4 pre-alpha SVN-16538

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)

cx_Oracle 5.0

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0

Change History (5)

comment:1 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Reading the last line of the traceback, I'd say the error is "ORA-01400".

Why did you mention "ORA-06552" in the first line of your message? Is it related to #4140?

comment:2 Changed 4 years ago by aaugustin

  • Resolution set to needsinfo
  • Status changed from new to closed

I couldn't reproduce the problem with the following procedure:

  • django-admin.py startproject test16454
  • vi settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': '',
        'USER': 'django',
        'PASSWORD': 'django',
    }
}
DEFAULT_TABLESPACE = 'test16454'
DEFAULT_INDEX_TABLESPACE = 'test16454'
  • sqlplus
create tablespace test16454 datafile 'test16454.dbf' size 20M;
  • ./manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'aaugustin'): [[[ redacted ]]]
E-mail address: [[[ redacted ]]]
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
No fixtures found.

Oracle Database 10g Express Edition Release 10.2.0.1.0

Since the original report doesn't contain any information about the context, there isn't much more I can do.

comment:3 Changed 4 years ago by alexei.vlassov@…

It's fixed for me with cx_Oracle 5.1

comment:4 Changed 4 years ago by aaugustin

Indeed, I tested with cx_Oracle 5.1. Unfortunately, I couldn't find anything in cx_Oracle's changelog to explain why the problem was fixed between 5.0 and 5.1.

comment:5 Changed 4 years ago by aaugustin

This was reported again and diagnosed in #17015.

Note: See TracTickets for help on using tickets.
Back to Top