bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings with dropped cols - Mailing list pgsql-patches
| From | Joe Conway |
|---|---|
| Subject | bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings with dropped cols |
| Date | |
| Msg-id | 3F6E339D.7040802@joeconway.com Whole thread Raw |
| Responses |
Re: bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings
Re: bug fix: TupleDescGetAttInMetadata/BuildTupleFromCStrings |
| List | pgsql-patches |
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';
}
pgsql-patches by date: