problem with plpgsql

From: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
To: pgsql-hackers(at)postgresql(dot)org
Subject: problem with plpgsql
Date: 2005-06-29 17:12:16
Message-ID: Pine.LNX.4.44.0506291845050.18770-100000@kix.fsv.cvut.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

In my code I evaluate expr

select array(select generate_series from generate_series(1,800)

my code
var = (PLpgSQL_var *) (estate->datums[stmt->varno]);
value = exec_eval_expr(estate, stmt->expr, &isnull, &valtype);
exec_eval_cleanup(estate);

and iteration over array

ndim = ARR_NDIM(value);
dims = ARR_DIMS(value);
nitems = ArrayGetNItems(ndim, dims);

element_type = ARR_ELEMTYPE(value);
p = ARR_DATA_PTR(value);

get_typlenbyvalalign(element_type, &typlen, &typbyval, &typalign);

for (i = 0; i < nitems; i++) // tak aby to zvladalo dimenze
{
Datum itemvalue;

itemvalue = fetch_att(p, typbyval, typlen);
exec_assign_value(estate, (PLpgSQL_datum *) var,
itemvalue, element_type, &isnull);

p = att_addlength(p, typlen, PointerGetDatum(p));
p = (char *) att_align(p, typalign);

works fine, but from random index > 300 array is broken

NOTICE: 400
NOTICE: 401
NOTICE: 402
NOTICE: 403
NOTICE: 404
NOTICE: 405
NOTICE: 406
NOTICE: 407
NOTICE: 408
NOTICE: 409
NOTICE: 410
NOTICE: 411
NOTICE: 412
NOTICE: 413
NOTICE: 414
NOTICE: 415
NOTICE: 157207208
NOTICE: 16
NOTICE: 3486004
NOTICE: 419
NOTICE: 420
NOTICE: 421
NOTICE: 157207208
NOTICE: 16

Can you help me, what I do wrong?

Thank You
Pavel Stehule

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2005-06-29 17:18:27 Re: Proposal: associative arrays for plpgsql (concept)
Previous Message David Fetter 2005-06-29 17:07:10 Re: Proposal: associative arrays for plpgsql (concept)