|
7 | 7 | * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
10 |
| - * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.45 2007/07/12 21:04:45 tgl Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.46 2007/07/13 03:43:23 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -2673,50 +2673,41 @@ map_sql_typecoll_to_xmlschema_types(List *tupdesc_list)
|
2673 | 2673 | List*uniquetypes=NIL;
|
2674 | 2674 | inti;
|
2675 | 2675 | StringInfoDataresult;
|
2676 |
| -ListCell*cell0,*cell1,*cell2; |
| 2676 | +ListCell*cell0; |
2677 | 2677 |
|
2678 |
| -foreach (cell0,tupdesc_list) |
| 2678 | +/* extract all column types used in the set of TupleDescs */ |
| 2679 | +foreach(cell0,tupdesc_list) |
2679 | 2680 | {
|
2680 |
| -TupleDesctupdesc=lfirst(cell0); |
| 2681 | +TupleDesctupdesc=(TupleDesc)lfirst(cell0); |
2681 | 2682 |
|
2682 |
| -for (i=1;i <=tupdesc->natts;i++) |
| 2683 | +for (i=0;i<tupdesc->natts;i++) |
2683 | 2684 | {
|
2684 |
| -boolalready_done= false; |
2685 |
| -Oidtype=SPI_gettypeid(tupdesc,i); |
2686 |
| -foreach (cell1,uniquetypes) |
2687 |
| -if (type==lfirst_oid(cell1)) |
2688 |
| -{ |
2689 |
| -already_done= true; |
2690 |
| -break; |
2691 |
| -} |
2692 |
| -if (already_done) |
| 2685 | +if (tupdesc->attrs[i]->attisdropped) |
2693 | 2686 | continue;
|
2694 |
| - |
2695 |
| -uniquetypes=lappend_oid(uniquetypes,type); |
| 2687 | +uniquetypes=list_append_unique_oid(uniquetypes, |
| 2688 | +tupdesc->attrs[i]->atttypid); |
2696 | 2689 | }
|
2697 | 2690 | }
|
2698 | 2691 |
|
2699 | 2692 | /* add base types of domains */
|
2700 |
| -foreach (cell1,uniquetypes) |
| 2693 | +foreach(cell0,uniquetypes) |
2701 | 2694 | {
|
2702 |
| -boolalready_done= false; |
2703 |
| -Oidtype=getBaseType(lfirst_oid(cell1)); |
2704 |
| -foreach (cell2,uniquetypes) |
2705 |
| -if (type==lfirst_oid(cell2)) |
2706 |
| -{ |
2707 |
| -already_done= true; |
2708 |
| -break; |
2709 |
| -} |
2710 |
| -if (already_done) |
2711 |
| -continue; |
| 2695 | +Oidtypid=lfirst_oid(cell0); |
| 2696 | +Oidbasetypid=getBaseType(typid); |
2712 | 2697 |
|
2713 |
| -uniquetypes=lappend_oid(uniquetypes,type); |
| 2698 | +if (basetypid!=typid) |
| 2699 | +uniquetypes=list_append_unique_oid(uniquetypes,basetypid); |
2714 | 2700 | }
|
2715 | 2701 |
|
| 2702 | +/* Convert to textual form */ |
2716 | 2703 | initStringInfo(&result);
|
2717 | 2704 |
|
2718 |
| -foreach (cell1,uniquetypes) |
2719 |
| -appendStringInfo(&result,"%s\n",map_sql_type_to_xmlschema_type(lfirst_oid(cell1),-1)); |
| 2705 | +foreach(cell0,uniquetypes) |
| 2706 | +{ |
| 2707 | +appendStringInfo(&result,"%s\n", |
| 2708 | +map_sql_type_to_xmlschema_type(lfirst_oid(cell0), |
| 2709 | +-1)); |
| 2710 | +} |
2720 | 2711 |
|
2721 | 2712 | returnresult.data;
|
2722 | 2713 | }
|
|