X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9EBD1D1D803 for ; Thu, 15 Apr 2004 13:13:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 99399-09 for ; Thu, 15 Apr 2004 13:13:48 -0300 (ADT) Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) by svr1.postgresql.org (Postfix) with ESMTP id 06CF4D1D5E4 for ; Thu, 15 Apr 2004 13:13:43 -0300 (ADT) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 1407038; Thu, 15 Apr 2004 09:08:00 -0700 Message-ID: <407EB3DF.6010304@joeconway.com> Date: Thu, 15 Apr 2004 09:10:07 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dennis Cc: Tom Lane , postgres SQL Subject: Re: function returning array References: <29772.1081913447@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/142 X-Sequence-Number: 17517 Dennis wrote: > pg 7.4.1 > > I should have listed the source for the function. Here is a simplified > parseString function and the foo that calls it. > > dennis=# create or replace function parseString (varchar, varchar) > dennis-# RETURNS varchar[] AS ' > dennis'# DECLARE > dennis'# pParsed varchar[]; Make that last line: pParsed varchar[] := ''{}''; That initializes pParsed to an *empty* array. Otherwise pParsed is NULL, and when you attempt to extend a NULL array, e.g. "pParsed[1] = ''blah''" you still get NULL. It is similar to this: regression=# select NULL || 'blah'; ?column? ---------- (1 row) HTH, Joe