Lines Matching defs:Query
52 * Extended Operation that allows to remove a query from the cache
61 /* query cache structs */
62 /* query */
68 } Query;
78 /* struct representing a cached query */
84 struct berval q_uuid; /* query identifier */
86 struct query_template_s *qtemp; /* template of the query */
87 time_t expiry_time; /* time till the query is considered invalid */
88 time_t refresh_time; /* time till the query is refreshed */
90 int bind_refcnt; /* number of bind operation referencing this query */
93 int in_lru; /* query is in LRU list */
95 struct cached_query_s *next; /* next query in the template */
96 struct cached_query_s *prev; /* previous query in the template */
97 struct cached_query_s *lru_up; /* previous query in the LRU list */
98 struct cached_query_s *lru_down; /* next query in the LRU list */
135 /* struct representing a query template
143 CachedQuery* query; /* most recent query cached for the template */
144 CachedQuery* query_last; /* oldest query cached for the template */
183 /* prototypes for functions for 1) query containment
184 * 2) query addition, 3) cache replacement
187 Query*, QueryTemplate*);
189 Query*, QueryTemplate*, pc_caching_reason_t, int wlock);
192 /* LDAP query cache */
202 /* Query cache methods */
203 QCfunc *qcfunc; /* Query containment*/
205 AddQueryfunc *addfunc; /* add query */
208 /* LDAP query cache manager */
214 int check_cacheability; /* check whether a query is cacheable */
218 int num_entries_limit; /* max # of entries in a cacheable query */
235 query_manager* qm; /* query cache managed by the cache manager */
280 "DESC 'ID of query the entry belongs to, formatted as a UUID' "
288 "DESC 'URI describing a cached query' "
346 Query* query,
357 * Turn a cached query into its URL representation
598 * Turn an URL representing a formerly cached query into a cached query,
607 Query query = { 0 };
777 rc = dnNormalize( 0, NULL, NULL, &base, &query.base, NULL );
781 query.scope = lud->lud_scope;
782 query.filter = str2filter( lud->lud_filter );
783 if ( query.filter == NULL ) {
790 if ( filter2template( op, query.filter, &tempstr ) ) {
796 /* check for query containment */
811 cq = add_query( op, qm, &query, qt, PC_NEGATIVE, 0 );
813 cq = add_query( op, qm, &query, qt, PC_POSITIVE, 0 );
824 query.filter = NULL;
832 if ( query.filter != NULL ) filter_free( query.filter );
834 if ( !BER_BVISNULL( &query.base ) ) ch_free( query.base.bv_val );
1042 /* compare filters in each query */
1049 /* add query on top of LRU list */
1065 Debug( pcache_debug, "Base of added query = %s\n",
1318 /* an incoming substr query can only be satisfied by a cached
1319 * substr query.
1325 /* an incoming eq query can be satisfied by a cached eq or substr
1326 * query
1385 query can be
1386 * answered with cached substring query */
1391 /* check if the substring query can be
1392 * answered with cached substring query */
1446 /* check whether query is contained in any of
1451 Query *query,
1459 if (query->filter != NULL) {
1464 qbase.base = query->base;
1466 first = filter_first( query->filter );
1473 tscope = query->scope;
1489 switch ( query->scope ) {
1517 query->filter, first );
1561 /* Add query to query cache, the returned Query is locked for writing */
1566 Query* query,
1615 Debug( pcache_debug, "Added query expires at %ld (%s)\n",
1619 new_cached_query->scope = query->scope;
1620 new_cached_query->filter = query->filter;
1621 new_cached_query->first = first = filter_first( query->filter );
1627 qb.base = query->base;
1629 /* Adding a query */
1642 new_cached_query->next = templ->query;
1645 rc = ldap_tavl_insert( &qbase->scopes[query->scope], new_cached_query,
1649 if (templ->query == NULL)
1652 templ->query->prev = new_cached_query;
1653 templ->query = new_cached_query;
1661 new_cached_query = find_filter( op, qbase->scopes[query->scope],
1662 query->filter, first );
1663 filter_free( query->filter );
1664 query->filter = NULL;
1686 template->query_last = template->query = NULL;
1689 template->query = qc->next;
1708 /* remove bottom query of LRU list from the query cache */
1712 * - if result->bv_val is NULL, the query at the bottom of the LRU
1714 * - otherwise, the query whose UUID is *result is removed
1730 "any query in LRU list\n" );
1747 "Could not find query with uuid=\"%s\""
2011 Query query;
2038 "Removing query UUID %s\n",
2042 "QUERY
2052 "QUERY REMOVED, CACHE ="
2190 * Call that allows to remove a query from the cache.
2202 /* remove the selected query */
2211 * the query indicated by queryid.
2333 Debug( pcache_debug, "UUID for query being added = %s\n",
2375 filter_free( si->query.filter );
2377 /* duplicate query, free it */
2387 CachedQuery *qc = qm->addfunc(op, qm, &si->query,
2431 /* duplicate query, free it */
2441 filter_free( si->query.filter );
2472 /* If we haven't exceeded the limit for this query,
2482 if ( cm->check_cacheability && test_filter( op, rs->sr_entry, si->query.filter ) != LDAP_COMPARE_TRUE ) {
2483 Debug( pcache_debug, "%s: query not cacheable because of schema issues in DN \"%s\"\n",
2493 Debug( pcache_debug, "%s: query not cacheable because of attrs without values in DN \"%s\" (%s)\n",
2559 * perform the remote query without control and cache all results,
2751 filter_free( pbi->bi_si->query.filter );
2754 pbi->bi_si->query.filter = filter_dup( f, NULL );
2879 * populate the query filter to retrieve the cached query. We
2880 * need to check the bindrefresh time in the query.
2943 /* We have a cached query to work with */
2973 Query query;
3018 query.filter = op->ors_filter;
3021 query.base = pbi->bi_templ->bindbase;
3022 query.scope = pbi->bi_templ->bindscope;
3027 answerable = qm->qcfunc(op, qm, &query, qtemp);
3039 Debug( pcache_debug, "query template of incoming query = %s\n",
3045 query.base = op->o_req_ndn;
3046 query.scope = op->ors_scope;
3048 /* check for query containment */
3059 answerable = qm->qcfunc(op, qm, &query, qt);
3077 Debug( pcache_debug, "QUERY ANSWERABLE (answered %lu times)\n",
3087 /* Let Bind know we used a cached query */
3121 Debug( pcache_debug, "QUERY NOT ANSWERABLE\n" );
3136 Debug( pcache_debug, "QUERY CACHEABLE\n" );
3137 query.filter = filter_dup(op->ors_filter, NULL);
3146 si->query = query;
3184 Debug( pcache_debug, "QUERY NOT CACHEABLE\n" );
3264 /* Refresh a cached query:
3265 * 1: Replay the query on the remote DB and merge each entry into
3410 refresh_query( Operation *op, CachedQuery *query, slap_overinst *on )
3422 ldap_pvt_thread_mutex_lock( &query->answerable_cnt_mutex );
3423 query->refcnt = 0;
3424 ldap_pvt_thread_mutex_unlock( &query->answerable_cnt_mutex );
3431 ri.ri_q = query;
3438 op->o_req_dn = query->qbase->base;
3439 op->o_req_ndn = query->qbase->base;
3440 op->ors_scope = query->scope;
3445 op->ors_filter = query->filter;
3446 filter2bv_x( op, query->filter, &op->ors_filterstr );
3447 op->ors_attrs = query->qtemp->t_attrs.attrs;
3457 /* Get the DNs of all entries matching this query */
3466 "(%s=%s)", ad_queryId->ad_cname.bv_val, query->q_uuid.bv_val);
3469 filter.f_av_value = query->q_uuid;
3489 vals[0] = query->q_uuid;
3527 CachedQuery *query, *qprev;
3566 for ( query=templ->query_last; query; query=qprev ) {
3567 qprev = query->prev;
3568 if ( query->refresh_time && query->refresh_time < op->o_time ) {
3569 /* A refresh will extend the expiry if the query has been
3574 if ( query->refcnt )
3575 query->expiry_time = op->o_time + templ->ttl;
3576 if ( query->expiry_time > op->o_time ) {
3582 if (query->expiry_time < op->o_time) {
3584 if ( query != templ->query_last )
3587 if (query->in_lru) {
3588 remove_query(qm, query);
3594 remove_from_template(query, templ);
3597 query->prev = expires;
3598 expires = query;
3599 query->qtemp = NULL;
3600 } else if ( !templ->ttr && query->expiry_time > ttl ) {
3602 * query's expiry is too new, and all subsequent queries
3606 * entire query list.
3614 for ( query=expires; query; query=qprev ) {
3616 qprev = query->prev;
3617 if ( BER_BVISNULL( &query->q_uuid ))
3620 return_val = remove_query_data(op, &query->q_uuid);
3621 Debug( pcache_debug, "STALE QUERY REMOVED, SIZE=%d\n",
3630 "STALE QUERY REMOVED, CACHE ="
3633 ldap_pvt_thread_rdwr_wlock( &query->rwlock );
3634 if ( query->bind_refcnt-- ) {
3639 ldap_pvt_thread_rdwr_wunlock( &query->rwlock );
3640 if ( rem ) free_query(query);
3646 for ( query=templ->query_last; query; query=qprev ) {
3647 qprev = query->prev;
3648 if ( query->refresh_time && query->refresh_time < op->o_time ) {
3649 /* A refresh will extend the expiry if the query has been
3654 if ( query->expiry_time > op->o_time ) {
3655 refresh_query( op, query, on );
3656 query->refresh_time = op->o_time + templ->ttr;
3740 "DESC 'Check whether the results of a query are cacheable, e.g. for schema issues' "
4235 temp->query = temp->query_last = NULL;
4289 Debug( pcache_debug, " query template: %s\n",
4871 for ( qc = tm->query; qc; qc = qc->next ) {
4905 "%sSETTING CACHED QUERY URLS\n",
4951 for ( qc = tm->query; qc; qc = qn ) {
5063 * 1. if baseDN and queryID are present, then the query corresponding
5275 Debug( LDAP_DEBUG_STATS, "%s QUERY DELETE%s\n",
5344 /* remove the selected query */
5364 * It's too much work to find the matching query, so
5439 for ( qc = tm->query; qc; qc = qc->next ) {