Re: bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | Re: bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings |
Date | |
Msg-id | 200309291822.h8TIMrr24381@candle.pha.pa.us Whole thread Raw |
In response to | bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings with dropped cols (Joe Conway <mail@joeconway.com>) |
List | pgsql-patches |
Patch applied. Thanks. --------------------------------------------------------------------------- Joe Conway wrote: > I discovered that TupleDescGetAttInMetadata and BuildTupleFromCStrings > don't deal well with tuples having dropped columns. The attached fixes > the issue. Please apply. > > Thanks, > > Joe > Index: src/backend/executor/execTuples.c > =================================================================== > RCS file: /opt/src/cvs/pgsql-server/src/backend/executor/execTuples.c,v > retrieving revision 1.71 > diff -c -r1.71 execTuples.c > *** src/backend/executor/execTuples.c 8 Aug 2003 21:41:40 -0000 1.71 > --- src/backend/executor/execTuples.c 21 Sep 2003 23:23:02 -0000 > *************** > *** 674,689 **** > * Gather info needed later to call the "in" function for each > * attribute > */ > ! attinfuncinfo = (FmgrInfo *) palloc(natts * sizeof(FmgrInfo)); > ! attelems = (Oid *) palloc(natts * sizeof(Oid)); > ! atttypmods = (int32 *) palloc(natts * sizeof(int32)); > > for (i = 0; i < natts; i++) > { > ! atttypeid = tupdesc->attrs[i]->atttypid; > ! getTypeInputInfo(atttypeid, &attinfuncid, &attelems[i]); > ! fmgr_info(attinfuncid, &attinfuncinfo[i]); > ! atttypmods[i] = tupdesc->attrs[i]->atttypmod; > } > attinmeta->tupdesc = tupdesc; > attinmeta->attinfuncs = attinfuncinfo; > --- 674,693 ---- > * Gather info needed later to call the "in" function for each > * attribute > */ > ! attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo)); > ! attelems = (Oid *) palloc0(natts * sizeof(Oid)); > ! atttypmods = (int32 *) palloc0(natts * sizeof(int32)); > > for (i = 0; i < natts; i++) > { > ! /* Ignore dropped attributes */ > ! if (!tupdesc->attrs[i]->attisdropped) > ! { > ! atttypeid = tupdesc->attrs[i]->atttypid; > ! getTypeInputInfo(atttypeid, &attinfuncid, &attelems[i]); > ! fmgr_info(attinfuncid, &attinfuncinfo[i]); > ! atttypmods[i] = tupdesc->attrs[i]->atttypmod; > ! } > } > attinmeta->tupdesc = tupdesc; > attinmeta->attinfuncs = attinfuncinfo; > *************** > *** 712,733 **** > dvalues = (Datum *) palloc(natts * sizeof(Datum)); > nulls = (char *) palloc(natts * sizeof(char)); > > ! /* Call the "in" function for each non-null attribute */ > for (i = 0; i < natts; i++) > { > ! if (values[i] != NULL) > { > ! attelem = attinmeta->attelems[i]; > ! atttypmod = attinmeta->atttypmods[i]; > ! > ! dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i], > ! CStringGetDatum(values[i]), > ! ObjectIdGetDatum(attelem), > ! Int32GetDatum(atttypmod)); > ! nulls[i] = ' '; > } > else > { > dvalues[i] = (Datum) 0; > nulls[i] = 'n'; > } > --- 716,747 ---- > dvalues = (Datum *) palloc(natts * sizeof(Datum)); > nulls = (char *) palloc(natts * sizeof(char)); > > ! /* Call the "in" function for each non-null, non-dropped attribute */ > for (i = 0; i < natts; i++) > { > ! if (!tupdesc->attrs[i]->attisdropped) > { > ! /* Non-dropped attributes */ > ! if (values[i] != NULL) > ! { > ! attelem = attinmeta->attelems[i]; > ! atttypmod = attinmeta->atttypmods[i]; > ! > ! dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i], > ! CStringGetDatum(values[i]), > ! ObjectIdGetDatum(attelem), > ! Int32GetDatum(atttypmod)); > ! nulls[i] = ' '; > ! } > ! else > ! { > ! dvalues[i] = (Datum) 0; > ! nulls[i] = 'n'; > ! } > } > else > { > + /* Handle dropped attributes by setting to NULL */ > dvalues[i] = (Datum) 0; > nulls[i] = 'n'; > } > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
pgsql-patches by date: