|
3 | 3 | * procedural language |
4 | 4 | * |
5 | 5 | * IDENTIFICATION |
6 | | - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.115 2004/08/13 18:47:56 tgl Exp $ |
| 6 | + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.116 2004/08/20 22:00:14 tgl Exp $ |
7 | 7 | * |
8 | 8 | * This software is copyrighted by Jan Wieck - Hamburg. |
9 | 9 | * |
|
56 | 56 |
|
57 | 57 | staticconstchar*constraise_skip_msg="RAISE"; |
58 | 58 |
|
59 | | -typedefstruct { |
60 | | -constchar*label; |
61 | | -intsqlerrstate; |
62 | | -}ExceptionLabelMap; |
63 | | - |
64 | | -staticconstExceptionLabelMapexception_label_map[]= { |
65 | | -#include"plerrcodes.h" |
66 | | -{NULL,0 } |
67 | | -}; |
68 | 59 |
|
69 | 60 | /* |
70 | 61 | * All plpgsql function executions within a single transaction share |
@@ -799,40 +790,24 @@ exception_matches_conditions(ErrorData *edata, PLpgSQL_condition *cond) |
799 | 790 | { |
800 | 791 | for (;cond!=NULL;cond=cond->next) |
801 | 792 | { |
802 | | -constchar*condname=cond->condname; |
803 | | -inti; |
| 793 | +intsqlerrstate=cond->sqlerrstate; |
804 | 794 |
|
805 | 795 | /* |
806 | 796 | * OTHERS matches everything *except* query-canceled; |
807 | 797 | * if you're foolish enough, you can match that explicitly. |
808 | 798 | */ |
809 | | -if (strcmp(condname,"others")==0) |
| 799 | +if (sqlerrstate==0) |
810 | 800 | { |
811 | | -if (edata->sqlerrcode==ERRCODE_QUERY_CANCELED) |
812 | | -return false; |
813 | | -else |
| 801 | +if (edata->sqlerrcode!=ERRCODE_QUERY_CANCELED) |
814 | 802 | return true; |
815 | 803 | } |
816 | | -for (i=0;exception_label_map[i].label!=NULL;i++) |
817 | | -{ |
818 | | -if (strcmp(condname,exception_label_map[i].label)==0) |
819 | | -{ |
820 | | -intlabelerrcode=exception_label_map[i].sqlerrstate; |
821 | | - |
822 | | -/* Exact match? */ |
823 | | -if (edata->sqlerrcode==labelerrcode) |
824 | | -return true; |
825 | | -/* Category match? */ |
826 | | -if (ERRCODE_IS_CATEGORY(labelerrcode)&& |
827 | | -ERRCODE_TO_CATEGORY(edata->sqlerrcode)==labelerrcode) |
828 | | -return true; |
829 | | -/* |
830 | | - * You would think we should "break" here, but there are some |
831 | | - * duplicate names in the table, so keep looking. |
832 | | - */ |
833 | | -} |
834 | | -} |
835 | | -/* Should we raise an error if condname is unrecognized?? */ |
| 804 | +/* Exact match? */ |
| 805 | +elseif (edata->sqlerrcode==sqlerrstate) |
| 806 | +return true; |
| 807 | +/* Category match? */ |
| 808 | +elseif (ERRCODE_IS_CATEGORY(sqlerrstate)&& |
| 809 | +ERRCODE_TO_CATEGORY(edata->sqlerrcode)==sqlerrstate) |
| 810 | +return true; |
836 | 811 | } |
837 | 812 | return false; |
838 | 813 | } |
|