fix invalid propfind pg queries created for allprop requests on collections

Tue, 01 Nov 2022 15:39:21 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 01 Nov 2022 15:39:21 +0100
changeset 401
d2bfd11d3f8f
parent 400
d814b29e8d96
child 402
712aca08da7f

fix invalid propfind pg queries created for allprop requests on collections

src/server/plugins/postgresql/webdav.c file | annotate | diff | comparison | revisions
--- a/src/server/plugins/postgresql/webdav.c	Tue Nov 01 15:27:48 2022 +0100
+++ b/src/server/plugins/postgresql/webdav.c	Tue Nov 01 15:39:21 2022 +0100
@@ -146,10 +146,10 @@
 where r.resource_id = $1 or r.parent_id = $1\n";
 
 static const char *sql_propfind_order_depth1 = "\
-order by case when r.resource_id = $1 then 0 else 1 end, nodename, resource_id";
+order by case when r.resource_id = $1 then 0 else 1 end, r.nodename, r.resource_id";
 
 static const char *sql_propfind_order_depth_infinity = "\
-order by replace(ppath, '/', chr(1)), resource_id";
+order by replace(ppath, '/', chr(1)), r.resource_id";
 
 /*
  * SQL Queries
@@ -389,7 +389,7 @@
     
     // end
     ucx_buffer_puts(sql, ";\0");
-    
+      
     return 0;
 }
 
@@ -544,6 +544,11 @@
         ucx_buffer_free(pname_buf);
     }
     if(nrows < 1) {
+        // we resolved the path, so the resource exists and nrows should
+        // be >= 1
+        if(PQresultStatus(result) != PGRES_TUPLES_OK) {
+            log_ereport(LOG_FAILURE, "pg_dav_propfind_init: %s", PQerrorMessage(pgdav->connection));
+        }
         PQclear(result);
         return 1;
     }

mercurial