src/server/plugins/postgresql/webdav.c

changeset 564
f19fd264c69c
parent 562
69fc4ecc5f60
equal deleted inserted replaced
563:6ca97c99173e 564:f19fd264c69c
602 // get field_nums for all property extensions 602 // get field_nums for all property extensions
603 for(int i=0;i<numext;i++) { 603 for(int i=0;i<numext;i++) {
604 PgPropfindExtCol *c = &ext[i]; 604 PgPropfindExtCol *c = &ext[i];
605 //c->field_num = PQfnumber(result, c->ext->column); 605 //c->field_num = PQfnumber(result, c->ext->column);
606 int *fieldnum = cxMapGet(fieldmap, c->ext->column); 606 int *fieldnum = cxMapGet(fieldmap, c->ext->column);
607 c->field_num = *fieldnum; 607 if(fieldnum) {
608 c->field_num = *fieldnum;
609 }
608 } 610 }
609 611
610 cxMapDestroy(fieldmap); 612 cxMapDestroy(fieldmap);
611 } 613 }
612 614
734 if(pg->ext) { 736 if(pg->ext) {
735 for(int extc=0;extc<pg->numext;extc++) { 737 for(int extc=0;extc<pg->numext;extc++) {
736 PgPropfindExtCol ext = pg->ext[extc]; 738 PgPropfindExtCol ext = pg->ext[extc];
737 int fieldnum = ext.field_num; 739 int fieldnum = ext.field_num;
738 740
739 if(!PQgetisnull(result, r, fieldnum)) { 741 if(fieldnum >= 0 && !PQgetisnull(result, r, fieldnum)) {
740 char *ext_value = PQgetvalue(result, r, fieldnum); 742 char *ext_value = PQgetvalue(result, r, fieldnum);
741 int ext_value_len = PQgetlength(result, r, fieldnum); 743 int ext_value_len = PQgetlength(result, r, fieldnum);
742 char ext_xmlns_prefix[32]; 744 char ext_xmlns_prefix[32];
743 snprintf(ext_xmlns_prefix, 32, "x%d", ext.ext->tableindex); 745 snprintf(ext_xmlns_prefix, 32, "x%d", ext.ext->tableindex);
744 746
1215 return NULL; 1217 return NULL;
1216 } 1218 }
1217 } 1219 }
1218 1220
1219 pg_params[i] = value_str; 1221 pg_params[i] = value_str;
1220 cx_bprintf(sql, " %s = $%d,\n", prop->column->name, ++i); 1222 cx_bprintf(sql, " %s = $%d,\n", prop->column->column, ++i);
1221 } 1223 }
1222 1224
1223 for(PgProppatchExtProp *prop=ext->remove_begin;prop;prop=prop->next) { 1225 for(PgProppatchExtProp *prop=ext->remove_begin;prop;prop=prop->next) {
1224 cx_bprintf(sql, " %s = NULL,\n", prop->column->name); 1226 cx_bprintf(sql, " %s = NULL,\n", prop->column->name);
1225 } 1227 }

mercurial