|
15 | 15 | *
|
16 | 16 | *
|
17 | 17 | * IDENTIFICATION
|
18 |
| - * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.71 2003/08/08 21:41:40 momjian Exp $ |
| 18 | + * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.72 2003/09/29 18:22:48 momjian Exp $ |
19 | 19 | *
|
20 | 20 | *-------------------------------------------------------------------------
|
21 | 21 | */
|
@@ -674,16 +674,20 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc)
|
674 | 674 | * Gather info needed later to call the "in" function for each
|
675 | 675 | * attribute
|
676 | 676 | */
|
677 |
| -attinfuncinfo= (FmgrInfo*)palloc(natts*sizeof(FmgrInfo)); |
678 |
| -attelems= (Oid*)palloc(natts*sizeof(Oid)); |
679 |
| -atttypmods= (int32*)palloc(natts*sizeof(int32)); |
| 677 | +attinfuncinfo= (FmgrInfo*)palloc0(natts*sizeof(FmgrInfo)); |
| 678 | +attelems= (Oid*)palloc0(natts*sizeof(Oid)); |
| 679 | +atttypmods= (int32*)palloc0(natts*sizeof(int32)); |
680 | 680 |
|
681 | 681 | for (i=0;i<natts;i++)
|
682 | 682 | {
|
683 |
| -atttypeid=tupdesc->attrs[i]->atttypid; |
684 |
| -getTypeInputInfo(atttypeid,&attinfuncid,&attelems[i]); |
685 |
| -fmgr_info(attinfuncid,&attinfuncinfo[i]); |
686 |
| -atttypmods[i]=tupdesc->attrs[i]->atttypmod; |
| 683 | +/* Ignore dropped attributes */ |
| 684 | +if (!tupdesc->attrs[i]->attisdropped) |
| 685 | +{ |
| 686 | +atttypeid=tupdesc->attrs[i]->atttypid; |
| 687 | +getTypeInputInfo(atttypeid,&attinfuncid,&attelems[i]); |
| 688 | +fmgr_info(attinfuncid,&attinfuncinfo[i]); |
| 689 | +atttypmods[i]=tupdesc->attrs[i]->atttypmod; |
| 690 | +} |
687 | 691 | }
|
688 | 692 | attinmeta->tupdesc=tupdesc;
|
689 | 693 | attinmeta->attinfuncs=attinfuncinfo;
|
@@ -712,22 +716,32 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
|
712 | 716 | dvalues= (Datum*)palloc(natts*sizeof(Datum));
|
713 | 717 | nulls= (char*)palloc(natts*sizeof(char));
|
714 | 718 |
|
715 |
| -/* Call the "in" function for each non-null attribute */ |
| 719 | +/* Call the "in" function for each non-null, non-dropped attribute */ |
716 | 720 | for (i=0;i<natts;i++)
|
717 | 721 | {
|
718 |
| -if (values[i]!=NULL) |
| 722 | +if (!tupdesc->attrs[i]->attisdropped) |
719 | 723 | {
|
720 |
| -attelem=attinmeta->attelems[i]; |
721 |
| -atttypmod=attinmeta->atttypmods[i]; |
722 |
| - |
723 |
| -dvalues[i]=FunctionCall3(&attinmeta->attinfuncs[i], |
724 |
| -CStringGetDatum(values[i]), |
725 |
| -ObjectIdGetDatum(attelem), |
726 |
| -Int32GetDatum(atttypmod)); |
727 |
| -nulls[i]=' '; |
| 724 | +/* Non-dropped attributes */ |
| 725 | +if (values[i]!=NULL) |
| 726 | +{ |
| 727 | +attelem=attinmeta->attelems[i]; |
| 728 | +atttypmod=attinmeta->atttypmods[i]; |
| 729 | + |
| 730 | +dvalues[i]=FunctionCall3(&attinmeta->attinfuncs[i], |
| 731 | +CStringGetDatum(values[i]), |
| 732 | +ObjectIdGetDatum(attelem), |
| 733 | +Int32GetDatum(atttypmod)); |
| 734 | +nulls[i]=' '; |
| 735 | +} |
| 736 | +else |
| 737 | +{ |
| 738 | +dvalues[i]= (Datum)0; |
| 739 | +nulls[i]='n'; |
| 740 | +} |
728 | 741 | }
|
729 | 742 | else
|
730 | 743 | {
|
| 744 | +/* Handle dropped attributes by setting to NULL */ |
731 | 745 | dvalues[i]= (Datum)0;
|
732 | 746 | nulls[i]='n';
|
733 | 747 | }
|
|