$Revision: 1.15 $
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/rxroutines.h"
- #include <glib.h>
- #include <pthread.h>
- #include <include/stubs.h>
- #include <include/memwrap.h>
- #include <include/erroutines.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <assert.h>
- #include <time.h>
- #include <stdarg.h>
- #include <strings.h>
- #include <bitmask.h>
- #include <include/er_aspects.h>
- #include <stubs.h>
- #include "include/er_facilities.h"
- #include <stdio.h>
- #include <include/iproutines.h>
- #include <glib.h>
- #include <include/erroutines.h>
- #include <include/rx_globals.h>
- #include <stddef.h>
- #include <glib.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
Execute the query instructions. This is called by a g_list_foreach
function, so each of the sources in the "database source" list can be passed
into this function.
void *database_voidptr Pointer to the database.
void *qis_voidptr Pointer to the query_instructions.
More:
Authors:
ottrey
- Online References:
<LI><A
HREF="http://www.gtk.org/rdp/glib/glib-singly-linked-lists.html#G-SLIST-FOREACH">g_list_foreach</A>
#define RIPE_REG 17
Definition of SQL query to be made
struct _Instruction
struct _Instruction |
|
{ |
|
WK_Type keytype; |
|
const char* sql_primary_query; |
|
const char* sql_inverse_query; |
|
} |
|
Local Variables
Instructions
SQL query to be made for each keytype:
static struct _Instruction Instructions[]
Execute the query instructions. This is called by a g_list_foreach
function, so each of the sources in the "database source" list can be passed
into this function.
More:
Authors:
ottrey
- Online References:
<LI><A
HREF="http://www.gtk.org/rdp/glib/glib-singly-linked-lists.html#G-SLIST-FOREACH">g_list_foreach</A>
void QI_execute ( void* database_voidptr, void* qis_voidptr )
- void* database_voidptr
- Pointer to the database.
- void* qis_voidptr
- Pointer to the query_instructions.
Free the query_instructions.
XXX This isn't working too well at the moment.
More:
Authors:
ottrey
- Online References:
void QI_free ( Query_instructions* qis )
- Query_instructions* qis
- Query_instructions to be freed.
Create a new set of query_instructions.
mask_t bitmap The bitmap of attribute to be converted.
More:
Authors:
ottrey
- Online References:
Query_instructions* QI_new ( const Query_command* qc, unsigned int sock )
- const Query_command* qc
- The query_command that the instructions are created
from.
- unsigned int sock
- The client socket.
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.
More:
Authors:
ottrey
- Online References:
static char* create_query ( WK_Type keytype, const Query_command* qc, mask_t* inv_attrs_bitmap )
- WK_Type keytype
- The matching keytype.
- const Query_command* qc
- The query command.
- mask_t* inv_attrs_bitmap
- The selected inverse attributes.
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
-
- 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
- Online References:
static void instruction_free ( Query_instruction* qi )
- Query_instruction* qi
- query_instruction to be freed.
Log the instruction.
More:
Authors:
ottrey
- Online References:
static void log_inst_print ( char* str )
- char* str
- instruction to be logged.
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.
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 recursive, unsigned int sock )
- MYSQL* sql_connection
-
- 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 recursive
- A recursive query.
- unsigned int sock
- The client socket.
Write the results to the client socket.
SQ_result_set_t *result The result set returned from the sql query.
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, int sock )
- MYSQL_RES* result
-
- int sock
- The socket that the client is connected to.