$Revision: 1.41 $
Sql module (sq). This is a mysql implementation of an sql module.
Status: NOT REVUED, NOT TESTED
Note: this code has been heavily coupled to MySQL, and may need to be changed
(to improve performance) if a new RDBMS is used.
Included Files
- #include "include/rp.h"
- #include <stddef.h>
- #include <glib.h>
- #include <defs.h>
- #include <iproutines.h>
- #include <erroutines.h>
- #include <rxroutines.h>
- #include <mysql_driver.h>
Preprocessor definitions
String sizes
#define STR_S 63
#define STR_M 255
#define STR_L 1023
#define STR_XL 4095
#define STR_XXL 16383
#define RIPE_REG 17
Execute the query instructions. This is called for each source.
void *qis_voidptr Pointer to the query_instructions.
More:
Authors:
ottrey
er_ret_t QI_execute ( void* database_voidptr, Query_instructions* qis, Query_environ* qe, acc_st* acc_credit, acl_st* acl )
- void* database_voidptr
- Pointer to the database.
- Query_instructions* qis
- &nbs;
- Query_environ* qe
- &nbs;
- acc_st* acc_credit
- &nbs;
- acl_st* acl
- &nbs;
Free the query_instructions.
XXX This isn't working too well at the moment.
More:
Authors:
ottrey
void QI_free ( Query_instructions* qis )
- Query_instructions* qis
- Query_instructions to be freed.
Create a new set of query_instructions.
Query_instructions* QI_new ( const Query_command* qc, const Query_environ* qe )
- const Query_command* qc
- The query_command that the instructions are created
from.
- const Query_environ* qe
- The environmental variables that they query is being
performed under.
More:
Authors:
ottrey
char* QI_queries_to_string ( Query_instructions* qis )
This is for the '-F' flag.
It assumes lines starting with ' ', '\t' or '+' belong to the prior attribute.
Fast isn't fast anymore - it's just there for compatibility reasons.
This could be speed up if there were breaks out of the loops, once it matched something.
(Wanna add a goto Marek? :-) ).
More:
Authors:
ottrey
- Online References:
char* fast_output ( const char* str )
- const char* str
- ng The string to be "fast outputed".
Basically it's for the '-K' flag for non-set (and non-radix) objects.
It assumes lines starting with ' ', '\t' or '+' belong to the prior attribute.
This could be speed up if there were breaks out of the loops, once it matched something.
(Wanna add a goto Marek? :-) ).
More:
Authors:
ottrey
- Online References:
char* filter ( const char* str )
- const char* str
- ng The string to be filtered.
void run_referral ( MYSQL* sql_connection, Query_instructions* qis, Query_environ* qe, int qi_index )
Calls:
| ER_dbg_va() | modules/er/er.c
|
| SK_cd_puts(), SQ_execute_query(), SQ_free_result(), SQ_get_column_string(), SQ_num_rows(), SQ_row_next(), WH_sock(), __eprintf(), fprintf(), index(), snprintf(), sprintf(), sscanf(), strcat(), strcmp(), strcpy(), strlen()
|
Called by:
| qi_collect_ids() | modules/qi/query_instructions.c
|
References Variables:
| Query | modules/df/defs.c
|
static void add_filter ( char* query_str, const Query_command* qc )
static void add_ref_name ( MYSQL* sql_connection, char* rectable, char* allnames )
create_asblock_query:
given a string like: AS1
AS1 - AS10
AS1-AS10
construct a range query for the as_block table
static int create_asblock_query ( char* query_str, const char* sql_query, const char* keys )
Create an sql query for the names table.
More:
Authors:
ottrey
- Online References:
static void create_name_query ( char* query_str, const char* sql_query, const char* keys )
Create an sql query from the query_command and the matching keytype and the
selected inverse attributes.
Note this clears the first inv_attribute it sees, so is called sequentially
until there are no inv_attributes left.
WK_Type keytype The matching keytype.
mask_t *inv_attrs_bitmap The selected inverse attributes.
More:
Authors:
ottrey
- Online References:
static char* create_query ( const Query_t q, const Query_command* qc )
- const Query_t q
- &nbs;
- const Query_command* qc
- The query command.
Insert the radix serial numbers into a temporary table in the database.
mask_t bitmap The bitmap of attribute to be converted.
SQ_connection_t *sql_connection The connection to the database.
XXX Hmmmmm this isn't really a good place to free things... infact it's quite nasty. :-(
More:
Authors:
ottrey
- Online References:
<LI><A HREF="http://www.gtk.org/rdp/glib/glib-doubly-linked-lists.html">Glist</A>
static void insert_radix_serials ( MYSQL* sql_connection, char* id_table, GList* datlist )
- MYSQL* sql_connection
- &nbs;
- char* id_table
- The id of the temporary table (This is a result of the hacky
way we've tried to get MySQL to do sub-selects.)
- GList* datlist
- The list of data from the radix tree.
Free the instruction.
More:
Authors:
ottrey
static void instruction_free ( Query_instruction* qi )
- Query_instruction* qi
- query_instruction to be freed.
The mapping between a query_command and a radix query.
More:
Authors:
ottrey
- Online References:
static int map_qc2rx ( Query_instruction* qi, const Query_command* qc )
- Query_instruction* qi
- The Query Instruction to be created from the mapping
of the query command.
- const Query_command* qc
- The query command to be mapped.
static void qi_collect_ids ( MYSQL* sql_connection, Query_instructions* qis, Query_environ* qe, char* id_table, GList** datlist, acc_st* acc_credit )
static void qi_fetch_references ( MYSQL* sql_connection, char* id_table, acc_st* acc_credit )
Determine if this query should be conducted or not.
If it was an inverse query - it the attribute appears in the query command's bitmap.
If it was a lookup query - if the attribute appears in the object type bitmap or
disregard if there is no object_type bitmap (Ie object filter).
mask_t bitmap The bitmap of attribute to be converted.
static int valid_query ( const Query_command* qc, const Query_t q )
- const Query_command* qc
- The query_command that the instructions are created
from.
- const Query_t q
- The query being investigated.
This is linked into MySQL by the fact that MySQL doesn't have sub selects
(yet). The queries are done in two stages. Make some temporary tables and
insert into them. Then use them in the next select.
SQ_connection_t *sql_connection The connection to the database.
More:
Authors:
ottrey
static void write_objects ( MYSQL* sql_connection, char* id_table, unsigned int filtered, unsigned int fast, sk_conn_st* condat, acc_st* acc_credit, acl_st* acl )
- MYSQL* sql_connection
- &nbs;
- char* id_table
- The id of the temporary table (This is a result of the hacky
way we've tried to get MySQL to do sub-selects.)
- unsigned int filtered
- &nbs;
- unsigned int fast
- &nbs;
- sk_conn_st* condat
- Connection data for the client
- acc_st* acc_credit
- &nbs;
- acl_st* acl
- &nbs;
Display the immediate data carried with the objects returned by the
radix tree.
More:
Authors:
marek
- Online References:
Also free the list of answers.
static void write_radix_immediate ( GList* datlist, sk_conn_st* condat, acc_st* acc_credit )
- GList* datlist
- The linked list of dataleaf copies
sk_conn_st *condat Connection data for the client
acc_st *acc_credit Accounting struct
- sk_conn_st* condat
- &nbs;
- acc_st* acc_credit
- &nbs;
Write the results to the client socket.
SQ_result_set_t *result The result set returned from the sql query.
unsigned filtered if the objects should go through a filter (-K)
sk_conn_st *condat Connection data for the client
int maxobjects max # of objects to write
XXX NB. this is very dependendant on what rows are returned in the result!!!
More:
Authors:
ottrey
- Online References:
static int write_results ( MYSQL_RES* result, unsigned filtered, unsigned fast, sk_conn_st* condat, acc_st* acc_credit, acl_st* acl )