modules/qi/query_instructions.h

/* [<][>][^][v][top]
[bottom][index][help] */

FUNCTIONS

This source file includes following functions.

   1 #ifndef READ_QUERY_INSTRUCTIONS
   2 #define READ_QUERY_INSTRUCTIONS
   3 
   4 /***************************************
   5   $Revision: 1.28 $
   6 
   7   Query instruction module (qi)
   8   config module.
   9 
  10   Status: NOT REVUED, NOT TESTED
  11 
  12   ******************/ /******************
  13   Copyright (c) 1999                              RIPE NCC
  14  
  15   All Rights Reserved
  16   
  17   Permission to use, copy, modify, and distribute this software and its
  18   documentation for any purpose and without fee is hereby granted,
  19   provided that the above copyright notice appear in all copies and that
  20   both that copyright notice and this permission notice appear in
  21   supporting documentation, and that the name of the author not be
  22   used in advertising or publicity pertaining to distribution of the
  23   software without specific, written prior permission.
  24   
  25   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  26   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
  27   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
  28   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  29   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  30   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  31   ***************************************/
  32 #include "rxroutines.h"
  33 #include "iproutines.h"
  34 #include "mysql_driver.h"
  35 #include "query_command.h"
  36 #include "defs.h"
  37 #include "which_keytypes.h"
  38 
  39 #include "access_control.h"
  40 
  41 
  42 #include "ca_configFns.h"
  43 #include "ca_dictSyms.h"
  44 #include "ca_macros.h"
  45 #include "ca_srcAttribs.h"
  46 
  47 /*
  48 --- snipped from http://www.tcx.se/Manual/manual.html ---
  49 
  50 5.3 Functionality missing from MySQL
  51 
  52 The following functionality is missing in the current version of MySQL. For a prioritized list indicating when new extensions may be added to MySQL, you should consult the
  53 online MySQL TODO list. That is the latest version of the TODO list in this manual. See section F List of things we want to add to MySQL in the future (The TODO). 
  54 
  55 5.3.1 Sub-selects
  56 
  57 The following will not yet work in MySQL: 
  58 
  59 SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
  60 SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
  61 
  62 However, in many cases you can rewrite the query without a sub select: 
  63 
  64 SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
  65 SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
  66 
  67 For more complicated sub queries you can create temporary tables to hold the sub query. 
  68 
  69 MySQL only supports INSERT ... SELECT ... and REPLACE ... SELECT ... Independent sub-selects will be probably be available in 3.24.0. You can now use the function IN() in other
  70 contexts, however. 
  71 
  72 --- end snip ---
  73 
  74 Ie. Try using a LEFT JOIN to do the "NOT IN"/ "MINUS" equivalent.
  75 
  76 */
  77 
  78 /*
  79   mysql optimizer is sometimes sub-optimal, 
  80   therefore we force the join order with STRAIGHT_JOIN (MB, 2000/05/02)
  81 
  82   
  83 */
  84 
  85 /* RIPE 6 */
  86 #if 1
  87 #define Q_OBJECTS     "SELECT last.object_id, last.sequence_id, last.object ,last.object_type FROM  %s IDS STRAIGHT_JOIN last,object_order WHERE last.object_id=IDS.id AND last.object_type != 100 AND last.object_type = object_order.object_type ORDER BY order_code" 
  88 #else
  89 #define Q_OBJECTS     "SELECT last.object_id, last.sequence_id, last.object ,last.object_type FROM  %s IDS STRAIGHT_JOIN last WHERE last.object_id=IDS.id AND last.object_type != 100 AND last.object_type = %s "
  90 #endif
  91 
  92 
  93 
  94 #define Q_REC         "INSERT INTO %s SELECT pe_ro_id FROM %s IDS STRAIGHT_JOIN %s WHERE object_id = IDS.id"
  95 
  96 #define Q_NO_OBJECTS  "SELECT object_id, sequence_id, object FROM last WHERE object_id = 0"
  97 
  98 #define MAX_INSTRUCTIONS 100
  99 
 100 
 101 typedef struct Query_instruction_t {
 102   R_Type_t search_type;
 103   int  queryindex;/* index into the Query table showing origin of this entry */
 104   char *query_str;
 105   char *rx_keys;
 106   unsigned int rx_srch_mode;
 107   unsigned int rx_par_a;
 108   ip_space_t space;
 109   rx_fam_t family;
 110 } Query_instruction;
 111 
 112 typedef struct Query_instructions_t {
 113   Query_instruction *instruction[MAX_INSTRUCTIONS];
 114   unsigned int filtered;
 115   unsigned int fast;
 116   unsigned int recursive;
 117   const Query_command *qc; /* pointer to the Query_command structure of this query */
 118 } Query_instructions;
 119 
 120 
 121 er_ret_t QI_execute(ca_dbSource_t *dbhdl, Query_instructions *qis, Query_environ *qe, acc_st *acc_credit, acl_st *acl);
 122 void QI_free(Query_instructions *qis);
 123 Query_instructions *QI_new(const Query_command *qc, const Query_environ *qe);
 124 char *QI_queries_to_string(Query_instructions *qis);
 125 char *QI_fast_output(const char *str);
 126 
 127 #endif /* READ_QUERY_INSTRUCTIONS */

/* [<][>][^][v][top][bottom][index][help] */