~ttx/openldap/lucid-gssapi-495418

« back to all changes in this revision

Viewing changes to servers/slapd/back-sql/search.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-07-28 10:17:15 UTC
  • mto: (0.3.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20090728101715-g0isvetelfeqm48k
Tags: upstream-2.4.17
ImportĀ upstreamĀ versionĀ 2.4.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $OpenLDAP: pkg/ldap/servers/slapd/back-sql/search.c,v 1.117.2.10 2009/02/17 19:14:41 quanah Exp $ */
 
1
/* $OpenLDAP: pkg/ldap/servers/slapd/back-sql/search.c,v 1.117.2.11 2009/06/02 22:28:46 quanah Exp $ */
2
2
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3
3
 *
4
4
 * Copyright 1999-2009 The OpenLDAP Foundation.
48
48
   and the other 26 for ldap_entries ID number. If your max(oc_map_id) is more
49
49
   than 63, you will need to steal more bits from ldap_entries ID number and
50
50
   put them into the OC ID part of the cookie. */
 
51
 
 
52
/* NOTE: not supported when BACKSQL_ARBITRARY_KEY is defined */
 
53
#ifndef BACKSQL_ARBITRARY_KEY
51
54
#define SQL_TO_PAGECOOKIE(id, oc) (((id) << 6 ) | ((oc) & 0x3F))
52
55
#define PAGECOOKIE_TO_SQL_ID(pc) ((pc) >> 6)
53
56
#define PAGECOOKIE_TO_SQL_OC(pc) ((pc) & 0x3F)
58
61
        Operation *op,
59
62
        SlapReply *rs,
60
63
        ID  *lastid );
 
64
#endif /* ! BACKSQL_ARBITRARY_KEY */
61
65
 
62
66
static int
63
67
backsql_attrlist_add( backsql_srch_info *bsi, AttributeDescription *ad )
1551
1555
                assert( 0 );
1552
1556
        }
1553
1557
 
 
1558
#ifndef BACKSQL_ARBITRARY_KEY
1554
1559
        /* If paged results are in effect, ignore low ldap_entries.id numbers */
1555
1560
        if ( get_pagedresults(bsi->bsi_op) > SLAP_CONTROL_IGNORED ) {
1556
1561
                unsigned long lowid = 0;
1574
1579
                                        lowidstring );
1575
1580
                }
1576
1581
        }
 
1582
#endif /* ! BACKSQL_ARBITRARY_KEY */
1577
1583
 
1578
1584
        rc = backsql_process_filter( bsi, bsi->bsi_filter );
1579
1585
        if ( rc > 0 ) {
1654
1660
                return BACKSQL_AVL_STOP;
1655
1661
        }
1656
1662
 
 
1663
#ifndef BACKSQL_ARBITRARY_KEY
1657
1664
        /* If paged results have already completed this objectClass, skip it */
1658
1665
        if ( get_pagedresults(op) > SLAP_CONTROL_IGNORED ) {
1659
1666
                if ( oc->bom_id < PAGECOOKIE_TO_SQL_OC( ((PagedResultsState *)op->o_pagedresults_state)->ps_cookie ) )
1661
1668
                        return BACKSQL_AVL_CONTINUE;
1662
1669
                }
1663
1670
        }
 
1671
#endif /* ! BACKSQL_ARBITRARY_KEY */
1664
1672
 
1665
1673
        if ( bsi->bsi_n_candidates == -1 ) {
1666
1674
                Debug( LDAP_DEBUG_TRACE, "backsql_oc_get_candidates(): "
1988
1996
        backsql_srch_info       bsi = { 0 };
1989
1997
        backsql_entryID         *eid = NULL;
1990
1998
        struct berval           nbase = BER_BVNULL;
1991
 
        unsigned long           lastid = 0;
 
1999
#ifndef BACKSQL_ARBITRARY_KEY
 
2000
        ID                      lastid = 0;
 
2001
#endif /* ! BACKSQL_ARBITRARY_KEY */
1992
2002
 
1993
2003
        Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): "
1994
2004
                "base=\"%s\", filter=\"%s\", scope=%d,", 
2125
2135
                ( op->ors_limit->lms_s_unchecked == -1 ? -2 :
2126
2136
                ( op->ors_limit->lms_s_unchecked ) ) );
2127
2137
 
 
2138
#ifndef BACKSQL_ARBITRARY_KEY
2128
2139
        /* If paged results are in effect, check the paging cookie */
2129
2140
        if ( get_pagedresults( op ) > SLAP_CONTROL_IGNORED ) {
2130
2141
                rs->sr_err = parse_paged_cookie( op, rs );
2133
2144
                        goto done;
2134
2145
                }
2135
2146
        }
 
2147
#endif /* ! BACKSQL_ARBITRARY_KEY */
2136
2148
 
2137
2149
        switch ( bsi.bsi_scope ) {
2138
2150
        case LDAP_SCOPE_BASE:
2409
2421
 
2410
2422
                if ( test_filter( op, e, op->ors_filter ) == LDAP_COMPARE_TRUE )
2411
2423
                {
 
2424
#ifndef BACKSQL_ARBITRARY_KEY
2412
2425
                        /* If paged results are in effect, see if the page limit was exceeded */
2413
2426
                        if ( get_pagedresults(op) > SLAP_CONTROL_IGNORED ) {
2414
2427
                                if ( rs->sr_nentries >= ((PagedResultsState *)op->o_pagedresults_state)->ps_size )
2419
2432
                                }
2420
2433
                                lastid = SQL_TO_PAGECOOKIE( eid->eid_id, eid->eid_oc_id );
2421
2434
                        }
 
2435
#endif /* ! BACKSQL_ARBITRARY_KEY */
2422
2436
                        rs->sr_attrs = op->ors_attrs;
2423
2437
                        rs->sr_operational_attrs = NULL;
2424
2438
                        rs->sr_entry = e;
2466
2480
 
2467
2481
send_results:;
2468
2482
        if ( rs->sr_err != SLAPD_ABANDON ) {
 
2483
#ifndef BACKSQL_ARBITRARY_KEY
2469
2484
                if ( get_pagedresults(op) > SLAP_CONTROL_IGNORED ) {
2470
2485
                        send_paged_response( op, rs, NULL );
2471
 
                } else {
 
2486
                } else
 
2487
#endif /* ! BACKSQL_ARBITRARY_KEY */
 
2488
                {
2472
2489
                        send_ldap_result( op, rs );
2473
2490
                }
2474
2491
        }
2663
2680
        return 0;
2664
2681
}
2665
2682
 
2666
 
 
 
2683
#ifndef BACKSQL_ARBITRARY_KEY
2667
2684
/* This function is copied verbatim from back-bdb/search.c */
2668
2685
static int
2669
2686
parse_paged_cookie( Operation *op, SlapReply *rs )
2716
2733
send_paged_response( 
2717
2734
        Operation       *op,
2718
2735
        SlapReply       *rs,
2719
 
        unsigned long   *lastid )
 
2736
        ID              *lastid )
2720
2737
{
2721
2738
        LDAPControl     ctrl, *ctrls[2];
2722
2739
        BerElementBuffer berbuf;
2767
2784
done:
2768
2785
        (void) ber_free_buf( ber );
2769
2786
}
 
2787
#endif /* ! BACKSQL_ARBITRARY_KEY */