Query_t Query[] = {

  {
    R_SQL,
    Q_LOOKUP,
    WK_KEY_CERT,
    A_KC,
    C_KC,
    "SELECT object_id FROM key_cert WHERE key_cert = '%s' AND thread_id = 0",
    "SQL:kc/kc/WK_KEY_CERT"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_PEERINGSET,
    A_PS,
    C_PS,
    "SELECT object_id FROM peering_set WHERE peering_set='%s' AND thread_id=0",
    "SQL:ps/ps/WK_PEERINGSET"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_NAME,
    A_PN,
    C_PN,
    "SELECT N00.object_id FROM %s WHERE %s AND N00.object_type = 10 AND N00.thread_id = 0",
    "SQL:pn/pn/WK_NAME"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_EMAIL,
    A_EM,
    -1,
    "SELECT object_id FROM e_mail i WHERE i.e_mail = '%s' AND i.thread_id = 0",
    "SQL:ANY/em/WK_EMAIL"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_AUTNUM,
    A_OR,
    C_RT,
    "SELECT object_id FROM route WHERE origin = '%s' AND thread_id = 0",
    "SQL:rt/or/WK_AUTNUM"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_DOMAIN,
    A_DN,
    C_DN,
    "SELECT object_id FROM domain WHERE domain = '%s' AND thread_id = 0",
    "SQL:dn/dn/WK_DOMAIN"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPRANGE,
    A_DN,
    C_DN,
    "",
    "RADIX:dn/WK_IPRANGE"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPPREFIX,
    A_DN,
    C_DN,
    "",
    "RADIX:dn/WK_IPPREFIX"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPADDRESS,
    A_DN,
    C_DN,
    "",
    "RADIX:dn/WK_IPADDRESS"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NAME,
    A_ZC,
    -1,
    "SELECT i.object_id FROM zone_c i, %s WHERE %s AND i.pe_ro_id = N00.object_id AND i.thread_id = 0",
    "SQL:ANY/zc/WK_NAME"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NIC_HDL,
    A_ZC,
    -1,
    "SELECT i.object_id FROM zone_c i, person_role WHERE i.pe_ro_id = person_role.object_id AND person_role.nic_hdl = '%s' AND i.thread_id = 0",
    "SQL:ANY/zc/WK_NIC_HDL"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_RTRSET,
    A_IS,
    C_IS,
    "SELECT object_id FROM rtr_set WHERE rtr_set='%s' AND thread_id=0",
    "SQL:is/is/WK_RTRSET"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_DOMAIN,
    A_IR,
    C_IR,
    "SELECT object_id FROM inet_rtr WHERE inet_rtr = '%s' AND thread_id = 0",
    "SQL:ir/ir/WK_DOMAIN"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPRANGE,
    A_IN,
    C_IN,
    "",
    "RADIX:in/WK_IPRANGE"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPPREFIX,
    A_IN,
    C_IN,
    "",
    "RADIX:in/WK_IPPREFIX"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPADDRESS,
    A_IN,
    C_IN,
    "",
    "RADIX:in/WK_IPADDRESS"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_EMAIL,
    A_NY,
    -1,
    "SELECT object_id FROM notify i WHERE i.notify = '%s' AND i.thread_id = 0",
    "SQL:ANY/ny/WK_EMAIL"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_IPADDRESS,
    A_IF,
    C_IR,
    "SELECT object_id FROM ifaddr WHERE ifaddr >= %u AND ifaddr <= %u AND thread_id = 0",
    "SQL:ir/if/WK_IPADDRESS"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NAME,
    A_TC,
    -1,
    "SELECT i.object_id FROM tech_c i, %s WHERE %s AND i.pe_ro_id = N00.object_id AND i.thread_id = 0",
    "SQL:ANY/tc/WK_NAME"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NIC_HDL,
    A_TC,
    -1,
    "SELECT i.object_id FROM tech_c i, person_role WHERE i.pe_ro_id = person_role.object_id AND person_role.nic_hdl = '%s' AND i.thread_id = 0",
    "SQL:ANY/tc/WK_NIC_HDL"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_MNTNER,
    A_CT,
    -1,
    "SELECT i.object_id FROM mntner, cross_mnt i WHERE mntner.object_id = i.mnt_id AND mntner.mntner = '%s' AND i.thread_id = 0",
    "SQL:ANY/ct/WK_MNTNER"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_DOMAIN,
    A_NS,
    C_DN,
    "SELECT object_id FROM nserver WHERE host = '%s' AND thread_id = 0",
    "SQL:dn/ns/WK_DOMAIN"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_IPADDRESS,
    A_NS,
    C_DN,
    "SELECT object_id FROM nserver WHERE host = '%s' AND thread_id = 0",
    "SQL:dn/ns/WK_IPADDRESS"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NIC_HDL,
    A_CN,
    -1,
    "SELECT i.object_id FROM person_role, cross_nfy i WHERE person_role.object_id = i.pe_ro_id AND person_role.nic_hdl = '%s' AND i.thread_id = 0",
    "SQL:ANY/cn/WK_NIC_HDL"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_NIC_HDL,
    A_NH,
    C_PN,
    "SELECT object_id FROM person_role WHERE nic_hdl = '%s' AND object_type = 10 AND thread_id = 0",
    "SQL:pn/nh/WK_NIC_HDL"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_NIC_HDL,
    A_NH,
    C_RO,
    "SELECT object_id FROM person_role WHERE nic_hdl = '%s' AND object_type = 11 AND thread_id = 0",
    "SQL:ro/nh/WK_NIC_HDL"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_NETNAME,
    A_NA,
    C_IN,
    "SELECT object_id FROM inetnum WHERE netname = '%s' AND thread_id = 0",
    "SQL:in/na/WK_NETNAME"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_NET6NAME,
    A_NA,
    C_I6,
    "SELECT object_id FROM inet6num WHERE netname = '%s' AND thread_id = 0",
    "SQL:i6/na/WK_NET6NAME"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_DOMAIN,
    A_SD,
    C_DN,
    "SELECT object_id FROM sub_dom WHERE domain = '%s' AND thread_id = 0",
    "SQL:dn/sd/WK_DOMAIN"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_MNTNER,
    A_MU,
    -1,
    "SELECT i.object_id FROM mntner, mnt_routes i WHERE mntner.object_id = i.mnt_id AND mntner.mntner = '%s'",
    "SQL:ANY/mu/WK_MNTNER"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_MNTNER,
    A_MT,
    C_MT,
    "SELECT object_id FROM mntner WHERE mntner = '%s' AND thread_id = 0",
    "SQL:mt/mt/WK_MNTNER"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_ROUTESETNAME,
    A_MO,
    C_IR,
    "SELECT member_of.object_id FROM mbrs_by_ref, member_of, route_set LEFT OUTER JOIN mnt_by ON member_of.object_id = mnt_by.object_id /* an old object might have no mntner at all */ WHERE (mbrs_by_ref.mnt_id = 0 OR mbrs_by_ref.mnt_id = mnt_by.mnt_id) /* mbrs_by_ref is any or matches the mnt_by of a member */ AND member_of.set_id = mbrs_by_ref.object_id AND route_set.object_id = member_of.set_id AND route_set.route_set = '%s' AND route_set.thread_id = 0",
    "SQL:ir/mo/WK_ROUTESETNAME"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_ASSETNAME,
    A_MO,
    C_IR,
    "SELECT member_of.object_id FROM as_set, member_of, mbrs_by_ref LEFT OUTER JOIN mnt_by ON member_of.object_id = mnt_by.object_id WHERE (mbrs_by_ref.mnt_id = 0 OR mbrs_by_ref.mnt_id = mnt_by.mnt_id) AND member_of.set_id = mbrs_by_ref.object_id AND as_set.object_id = member_of.set_id AND as_set = '%s' AND as_set.thread_id = 0",
    "SQL:ir/mo/WK_ASSETNAME"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IP6PREFIX,
    A_I6,
    C_I6,
    "",
    "RADIX:i6/WK_IP6PREFIX"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_MNTNER,
    A_ML,
    -1,
    "SELECT i.object_id FROM mntner, mnt_lower i WHERE mntner.object_id = i.mnt_id AND mntner.mntner = '%s' AND i.thread_id = 0",
    "SQL:ANY/ml/WK_MNTNER"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_DOMAIN,
    A_RZ,
    C_IN,
    "SELECT object_id FROM rev_srv WHERE rev_srv = '%s' AND thread_id = 0",
    "SQL:in/rz/WK_DOMAIN"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPRANGE,
    A_RT,
    C_RT,
    "",
    "RADIX:rt/WK_IPRANGE"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPPREFIX,
    A_RT,
    C_RT,
    "",
    "RADIX:rt/WK_IPPREFIX"
    },
  {
    R_RADIX,
    Q_LOOKUP,
    WK_IPADDRESS,
    A_RT,
    C_RT,
    "",
    "RADIX:rt/WK_IPADDRESS"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_MNTNER,
    A_MB,
    -1,
    "SELECT i.object_id FROM mntner, mnt_by i WHERE mntner.object_id = i.mnt_id AND mntner.mntner = '%s' AND i.thread_id = 0",
    "SQL:ANY/mb/WK_MNTNER"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_ROUTESETNAME,
    A_RS,
    C_RS,
    "SELECT object_id FROM route_set WHERE route_set = '%s' AND thread_id = 0",
    "SQL:rs/rs/WK_ROUTESETNAME"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_NAME,
    A_RO,
    C_RO,
    "SELECT N00.object_id FROM %s WHERE %s AND N00.object_type = 11 AND N00.thread_id = 0",
    "SQL:ro/ro/WK_NAME"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_MNTNER,
    A_RB,
    -1,
    "SELECT i.object_id FROM mntner, referral_by i WHERE mntner.object_id = i.mnt_id AND mntner.mntner = '%s' AND i.thread_id = 0",
    "SQL:ANY/rb/WK_MNTNER"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_ASSETNAME,
    A_AS,
    C_AS,
    "SELECT object_id FROM as_set WHERE as_set = '%s' AND thread_id = 0",
    "SQL:as/as/WK_ASSETNAME"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_AUTNUM,
    A_AN,
    C_AN,
    "SELECT object_id FROM aut_num WHERE aut_num = '%s' AND thread_id = 0",
    "SQL:an/an/WK_AUTNUM"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_ASRANGE,
    A_AK,
    C_AK,
    "SELECT object_id FROM as_block WHERE begin_as <= %u AND end_as >= %u AND thread_id = 0",
    "SQL:ak/ak/WK_ASRANGE"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_LIMERICK,
    A_LI,
    C_LI,
    "SELECT object_id FROM limerick WHERE limerick = '%s' AND thread_id = 0",
    "SQL:li/li/WK_LIMERICK"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NAME,
    A_AH,
    -1,
    "SELECT i.object_id FROM author i, %s WHERE %s AND i.pe_ro_id = N00.object_id AND i.thread_id = 0",
    "SQL:ANY/ah/WK_NAME"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NIC_HDL,
    A_AH,
    -1,
    "SELECT i.object_id FROM person_role, author i WHERE person_role.object_id = i.pe_ro_id AND person_role.nic_hdl = '%s' AND i.thread_id = 0",
    "SQL:ANY/ah/WK_NIC_HDL"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NAME,
    A_AC,
    -1,
    "SELECT i.object_id FROM admin_c i, %s WHERE %s AND i.pe_ro_id = N00.object_id AND i.thread_id = 0",
    "SQL:ANY/ac/WK_NAME"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_NIC_HDL,
    A_AC,
    -1,
    "SELECT i.object_id FROM admin_c i, person_role WHERE i.pe_ro_id = person_role.object_id AND person_role.nic_hdl = '%s' AND i.thread_id = 0",
    "SQL:ANY/ac/WK_NIC_HDL"
    },
  {
    R_SQL,
    Q_INVERSE,
    WK_AUTNUM,
    A_LA,
    C_IR,
    "SELECT object_id FROM inet_rtr WHERE local_as = '%s' AND thread_id = 0",
    "SQL:ir/la/WK_AUTNUM"
    },
  {
    R_SQL,
    Q_LOOKUP,
    WK_FILTERSET,
    A_FS,
    C_FS,
    "SELECT object_id FROM filter_set WHERE filter_set='%s' AND thread_id=0",
    "SQL:fs/fs/WK_FILTERSET"
    },
  {
    0,
    0,
    0,
    0,
    0,
    NULL
  }
}; /* Query[] */

