s2/rpc_server/wsp: save query row related data
authorNoel Power <noel.power@suse.com>
Thu, 1 Dec 2022 13:09:59 +0000 (13:09 +0000)
committerNoel Power <noel.power@suse.com>
Thu, 7 Sep 2023 11:14:41 +0000 (12:14 +0100)
This commit sets up saving and a method for retrieving information
about the row resuls associated with a query (will be used in future
commit where row data will be manipulated)

source3/rpc_server/wsp/wsp_gss.c

index 52defcdca9eb2aeeb55e44ad4776c1ddb440af57..9d09d5abe28e8620197cad60d61b624d60bac0e7 100644 (file)
@@ -48,10 +48,21 @@ struct client_version_map {
        uint32_t version;
 };
 
+struct query_rows_info {
+       struct query_rows_info *prev, *next;
+       uint32_t handle;
+       uint32_t rowstart_index; /* index where 'rows' starts */
+       uint32_t total_rows;     /* num rows stored*/
+       bool nomorerowstoreturn; /* num rows stored*/
+       /*includes those processed already*/
+       struct wsp_cbasestoragevariant **rows;
+};
+
 struct gss_state {
 
        struct uint32_list *connectedclientsidentifiers;
        struct client_version_map *connectedclientversions;
+       struct query_rows_info *query_info_map;
        enum wsp_server_state wsp_server_state;
        struct tevent_context *ev;
        struct messaging_context *msg_ctx;
@@ -66,6 +77,18 @@ struct wsp_client_data
        uint32_t fid;
 };
 
+static struct query_rows_info *find_query_rows_info(uint32_t handle,
+                                           struct gss_state *gss_state)
+{
+       struct query_rows_info *item;
+       for (item = gss_state->query_info_map; item; item = item->next){
+               if (item->handle == handle) {
+                       return item;
+               }
+       }
+       return NULL;
+}
+
 /* return the abstract inteface implemenation for the specified backend */
 static struct wsp_abstract_interface *get_impl(void)
 {
@@ -389,6 +412,7 @@ static struct tevent_req *handle_createquery(TALLOC_CTX *ctx,
        struct wsp_cpidmapper *pidmapper = NULL;
        struct wsp_ccolumngrouparray *grouparray = NULL;
 
+       struct query_rows_info *info = NULL;
        struct tevent_req *req, *subreq = NULL;
        struct create_query_state *state = NULL;
        NTSTATUS status;
@@ -398,6 +422,26 @@ static struct tevent_req *handle_createquery(TALLOC_CTX *ctx,
        int ndr_flags = NDR_SCALARS | NDR_BUFFERS;
        DATA_BLOB payload = {0};
 
+       info = find_query_rows_info(handle, gss_state);
+
+       /*
+        * #FIXME #TODO need to investigate this a bit, the
+        * query related data here should only be for
+        * running query ??? if so finding an existing
+        * info would be an error. If this information really
+        * is only relevant for a running query then we
+        * don't need to store this in a map!!
+        */
+       if (!info) {
+               info = talloc_zero(gss_state, struct query_rows_info);
+               if (info == NULL) {
+                       DBG_ERR("out of memory\n");
+                       return NULL;
+               }
+               info->handle = handle;
+               DLIST_ADD_END(gss_state->query_info_map, info);
+       }
+
        req = tevent_req_create(gss_state, &state, struct create_query_state);
        if (!req) {
                return NULL;