Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XbaPy-00008g-UR for pgsql-performance@arkaria.postgresql.org; Tue, 07 Oct 2014 19:27:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XbaPy-00030z-2P for pgsql-performance@arkaria.postgresql.org; Tue, 07 Oct 2014 19:27:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XZpMe-00062k-MO for pgsql-performance@postgresql.org; Thu, 02 Oct 2014 23:00:48 +0000 Received: from resqmta-ch2-12v.sys.comcast.net ([2001:558:fe21:29:69:252:207:44]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XZpMW-0003vs-BQ for pgsql-performance@postgresql.org; Thu, 02 Oct 2014 23:00:47 +0000 Received: from resomta-ch2-01v.sys.comcast.net ([69.252.207.97]) by resqmta-ch2-12v.sys.comcast.net with comcast id yNzr1o00226dK1R01P0cyk; Thu, 02 Oct 2014 23:00:36 +0000 Received: from [192.168.0.3] ([50.164.185.165]) by resomta-ch2-01v.sys.comcast.net with comcast id yP0b1o00N3aYFDu01P0cr0; Thu, 02 Oct 2014 23:00:36 +0000 Message-ID: <542DD92A.9000305@comcast.net> Date: Thu, 02 Oct 2014 19:00:58 -0400 From: George Neuner User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: help: function failing Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1412290836; bh=oHbyJR3JyZcc8g/VCvEYi3PW0v6fnX6yHcmFvhpFfdM=; h=Received:Received:Message-ID:Date:From:MIME-Version:To:Subject: Content-Type; b=Kn8B2OCxIcN+aj7UA225HtDyQbZScP9ood5oBu4rdWrvDVP/snsbLj/iaMUjO4Ic/ deZlJSAuYPc0cD7f2RdcrVaHgj0EfHi6nAkxHHuvzl86vFldmig6rdkihrkeFGsBUC 49PMoZ+ug3bBjRNwSN4lBxpHUiwZelvymHy+IzOynKeCBQSZ0Axbkn+7WQy0jHU8pO nc5Vnjz+bXVzR54KRo58hWHkz6Atrwc5zmoHTmq5Ta3rK/lY+ciGz97KT2OcwsQ1h9 xDR+RyQBJzjZjVj1XSFjEw7TUiDyY33z3dIA3SpgblnKCHdHgrs6HCMR0UOdBxz7vX pPRYhGXBKhMpw== X-Pg-Spam-Score: -2.8 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hi, I am using Postgresql 9.3.5 on Ubuntu and I have a sudden, unexplained failure in a function that has been working for a long time. --------------- code ---------------- CREATE OR REPLACE FUNCTION gen_random() RETURNS double precision AS $BODY$ DECLARE num float8 := 0; den float8 := 281474976710655; -- 0xFFFFFFFFFFFF bytes bytea[6]; BEGIN -- get random bytes from crypto module bytes := ext.gen_random_bytes(6); -- assemble a double precision value num := num + get_byte( bytes, 0 ); FOR i IN 1..5 LOOP num := num * 256; num := num + get_byte( bytes, i ); END LOOP; -- normalize value to range 0.0 .. 1.0 RETURN num / den; END; $BODY$ LANGUAGE plpgsql VOLATILE; --------------- code ---------------- The error is: ERROR: array value must start with "{" or dimension information SQL state: 22P02 Context: PL/pgSQL function gen_random() line 8 at assignment which, if I'm counting correctly, is bytes := ext.gen_random_bytes(6); If I comment out that line, it then tells me get_byte() is undefined, which should be impossible because it's built in. This gen_random() function is in public, the pgcrypto function gen_random_bytes() is in a separate utility schema "ext". This is in a test database which I am in process of modifying, but it works perfectly when dumped and restored to a different computer. This gen_random() function - and its environment - has been working in multiple systems for quite a while. I suspect that the Postgresql installation somehow has been hosed and that I'm looking at a reinstall, but I have no idea how I managed it. I'd like to know what happened so I can (try to) avoid it going forward. There haven't been any recent system updates, and AFAIK there haven't been any crashes either. Occasionally pgAdmin3 does hang up, but that happens very infrequently and has occurred on all the working systems as well. I have been adding new tables and functions to the public schema on this test system, but I haven't touched anything that was already working. It seems like Postgresql just snapped. Any ideas? Anything in particular I might look at for a clue? Thanks, George -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance