hit-moodle / moodle-local_onlinejudge

Online Judge plugin for Moodle 2.7-4.2.
http://cms.hit.edu.cn
GNU General Public License v3.0
120 stars 59 forks source link

Problem when upgrading onlinejudge #17

Closed lchorbadjiev closed 12 years ago

lchorbadjiev commented 12 years ago

When upgrading moodle_local_onlinejudge to latest git version I get following error:

Debug info: ERROR: column "stdout" cannot be cast to type bytea ALTER TABLE mdl_onlinejudge_tasks ALTER COLUMN stdout TYPE BYTEA Stack trace:

line 400 of /lib/dml/moodle_database.php: ddl_change_structure_exception thrown
line 232 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
line 573 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
line 88 of /lib/ddl/database_manager.php: call to pgsql_native_moodle_database->change_database_structure()
line 75 of /lib/ddl/database_manager.php: call to database_manager->execute_sql()
line 636 of /lib/ddl/database_manager.php: call to database_manager->execute_sql_arr()
line 58 of /local/onlinejudge/db/upgrade.php: call to database_manager->change_field_type()
line 385 of /lib/upgradelib.php: call to xmldb_local_onlinejudge_upgrade()
line 1466 of /lib/upgradelib.php: call to upgrade_plugins()
line 317 of /admin/index.php: call to upgrade_noncore()
sunner commented 12 years ago

Ah, it is terriable.

You must not use MySQL, do you? If no, please tell me which db engine are you using. (postgres? I guess)

In recent updates, I change the fields related with users' program output and testcase data from text type to binary type. This leads to two benefits:

  1. Ability to process more charsets
  2. Ability to judge programs input/output binary data

It seems that your db engine does not support this kind of alerting. Tell me what it is and perhaps we can find the solution.

lchorbadjiev commented 12 years ago

Yes, you are right: I'm using PostgreSQL 8.4.9. Hopes this helps.

sunner commented 12 years ago

I am sure that this is a problem under postgresql. There is also other people met the same problem, like http://bytes.com/topic/postgresql/answers/174532-cast-text-bytea . PostgreSQL does not support cast a column from text to bytea

I have no idea on how to solve this. Perhaps a totally new installation will work. If you want to reserve current data, you can try edit db/upgrade.php, remove two code blocks begin with "if ($oldversion < 2011092200) {" and "if ($oldversion < 2011102401) {", then upgrade as usual. This will keep the fields in text type.

lchorbadjiev commented 12 years ago

If I want to make fresh install of onlinejudge, which tables I should remove?

sunner commented 12 years ago

You can uninstall it in moodle by accessing http://yoursite.domain/admin/localplugins.php.

If the reinstallation works, please let me know. Thank you.