fix wrong column name usage by pg prop extensions default tip

Fri, 29 Nov 2024 18:10:26 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 29 Nov 2024 18:10:26 +0100
changeset 564
f19fd264c69c
parent 563
6ca97c99173e

fix wrong column name usage by pg prop extensions

src/server/plugins/postgresql/vfs.c file | annotate | diff | comparison | revisions
src/server/plugins/postgresql/webdav.c file | annotate | diff | comparison | revisions
src/server/safs/service.c file | annotate | diff | comparison | revisions
--- a/src/server/plugins/postgresql/vfs.c	Wed Nov 27 23:00:07 2024 +0100
+++ b/src/server/plugins/postgresql/vfs.c	Fri Nov 29 18:10:26 2024 +0100
@@ -846,7 +846,7 @@
 off_t pg_vfs_io_seek(SYS_FILE fd, off_t offset, int whence) {
     PgVFS *pgvfs = fd->ctx->vfs->instance;
     PgFile *pg = fd->data;
-    if(pg->fd < 0) return-1;
+    if(pg->fd < 0) return-1;  
     return lo_lseek64(pgvfs->connection, pg->fd, offset, whence);
 }
 
--- a/src/server/plugins/postgresql/webdav.c	Wed Nov 27 23:00:07 2024 +0100
+++ b/src/server/plugins/postgresql/webdav.c	Fri Nov 29 18:10:26 2024 +0100
@@ -604,7 +604,9 @@
             PgPropfindExtCol *c = &ext[i];
             //c->field_num = PQfnumber(result, c->ext->column);
             int *fieldnum = cxMapGet(fieldmap, c->ext->column);
-            c->field_num = *fieldnum;
+            if(fieldnum) {
+                c->field_num = *fieldnum;
+            }
         }
         
         cxMapDestroy(fieldmap);
@@ -736,7 +738,7 @@
                     PgPropfindExtCol ext = pg->ext[extc];
                     int fieldnum = ext.field_num;
                     
-                    if(!PQgetisnull(result, r, fieldnum)) {
+                    if(fieldnum >= 0 && !PQgetisnull(result, r, fieldnum)) {
                         char *ext_value = PQgetvalue(result, r, fieldnum);
                         int ext_value_len = PQgetlength(result, r, fieldnum);
                         char ext_xmlns_prefix[32];
@@ -1217,7 +1219,7 @@
         }
         
         pg_params[i] = value_str;
-        cx_bprintf(sql, " %s = $%d,\n", prop->column->name, ++i);
+        cx_bprintf(sql, " %s = $%d,\n", prop->column->column, ++i);
     }
     
     for(PgProppatchExtProp *prop=ext->remove_begin;prop;prop=prop->next)  {
--- a/src/server/safs/service.c	Wed Nov 27 23:00:07 2024 +0100
+++ b/src/server/safs/service.c	Fri Nov 29 18:10:26 2024 +0100
@@ -111,7 +111,7 @@
     // TODO: check if vfs can seek
     pblock_kvinsert(pb_key_accept_ranges, "bytes", 5, rq->srvhdrs);
 
-    // start response
+    // everything ok for now
     protocol_status(sn, rq, 200, NULL);
 
     return fd;

mercurial