在Rails应用程序日志中看到Postgres错误(plpgsql已存在/函数array_accum已存在)

时间:2009-05-20 06:39:34

标签: ruby-on-rails postgresql plpgsql

我在Rails开发日志中经常看到以下postgres错误/警告。它不会导致我的应用程序失败(我希望)。知道可能导致他们的原因吗?我该怎么做才能调试这个?

安装在我的电脑上:   - Ruby 1.8.7(2008-08-11 patchlevel 72)[i486-linux]
  - Rails 2.2.2
  - PostgreSQL 8.3.7

  [4;36;1mSQL (0.1ms)[0m   [0;1mSET client_min_messages TO 'panic'[0m
  [4;35;1mSQL (0.1ms)[0m   [0mSET client_min_messages TO 'notice'[0m
  [4;36;1mSQL (0.7ms)[0m   [0;1mSELECT version FROM schema_migrations[0m
DEPRECATION WARNING: ActionMailer::Base.register_template_extension has been deprecated.Use ActionView::Base.register_template_extension instead. (called from /home/gsmendoza/workspace/idea/georgemendoza/config/environment.rb:104)
  [4;35;1mSQL (0.2ms)[0m   [0mbegin[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1msavepoint ts[0m
  [4;35;1mSQL (0.0ms)[0m   [0mPGError: ERROR: function "array_accum" already exists with same argument types
: CREATE AGGREGATE array_accum (anyelement)
 (
 sfunc = array_append,
 stype = anyarray,
 initcond = '{}'
 );
[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1mrollback to savepoint ts[0m
  [4;35;1mSQL (0.1ms)[0m   [0mrelease savepoint ts[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1mcommit[0m
  [4;35;1mSQL (0.1ms)[0m   [0mbegin[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1msavepoint ts[0m
  [4;35;1mSQL (0.0ms)[0m   [0mPGError: ERROR: language "plpgsql" already exists
: CREATE LANGUAGE 'plpgsql';[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1mrollback to savepoint ts[0m
  [4;35;1mSQL (0.1ms)[0m   [0mrelease savepoint ts[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1mcommit[0m
  [4;35;1mSQL (0.1ms)[0m   [0mbegin[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1msavepoint ts[0m
  [4;35;1mSQL (2.6ms)[0m   [0m CREATE OR REPLACE FUNCTION crc32(word text)
 RETURNS bigint AS $$
 DECLARE tmp bigint;
 DECLARE i int;
 DECLARE j int;
 DECLARE word_array bytea;
 BEGIN
 i = 0;
 tmp = 4294967295;
 word_array = decode(replace(word, E'\\', E'\\\\'), 'escape');
 LOOP
 tmp = (tmp # get_byte(word_array, i))::bigint;
 i = i + 1;
 j = 0;
 LOOP
 tmp = ((tmp >> 1) # (3988292384 * (tmp & 1)))::bigint;
 j = j + 1;
 IF j >= 8 THEN
 EXIT;
 END IF;
 END LOOP;
 IF i >= char_length(word) THEN
 EXIT;
 END IF;
 END LOOP;
 return (tmp # 4294967295);
 END
 $$ IMMUTABLE STRICT LANGUAGE plpgsql;
[0m
  [4;36;1mSQL (0.1ms)[0m   [0;1mrelease savepoint ts[0m
  [4;35;1mSQL (0.8ms)[0m   [0mcommit[0m

2 个答案:

答案 0 :(得分:0)

你不需要做任何事情。看起来Rails只是试图安装一个已安装的plpgsql语言,并创建一个函数,你的PostgreSQL版本已经有了。

Rails已为此做好准备,只是忽略了这些错误。不是一个好的编程示例,但没有什么可担心的。

答案 1 :(得分:0)

我意识到由于我的错误,这个错误出现在我身上

  1. 删除测试数据库
  2. 创建了新的测试数据库
  3. 尝试将开发数据库的结构迁移到测试
  4. 时,列表项反之亦然
      

    长时间工作的副作用;)