$Revision: 1.30 $
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 </space/dbdev/marek/include/glib.h>
- #include </space/dbdev/marek/lib/glib/include/glibconfig.h>
- #include <limits.h>
- #include <float.h>
- #include <stdarg.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.
This function has bloated itself. Can we split it up Marek? (ottrey 13/12/99)
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
Local Variables
Query
static struct _Query_t Query[]
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.
This function has bloated itself. Can we split it up Marek? (ottrey 13/12/99)
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>
void 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
-
- Query_environ* qe
-
- acc_st* acc_credit
-
- acl_st* acl
-
Prototyped in:
| modules/qi/query_instructions.h
|
Calls:
| CO_get_database_port() | modules/co/constants.c
|
| CO_get_host() | modules/co/constants.c
|
| CO_get_password() | modules/co/constants.c
|
| CO_get_user() | modules/co/constants.c
|
| DF_get_attribute_code() | modules/df/defs.c
|
| DF_get_class_code() | modules/df/defs.c
|
| insert_radix_serials() | modules/qi/query_instructions.c
|
| log_inst_print() | modules/qi/query_instructions.c
|
| run_referral() | modules/qi/query_instructions.c
|
| write_objects() | modules/qi/query_instructions.c
|
| write_radix_immediate() | modules/qi/query_instructions.c
|
| RX_asc_search(), SK_cd_puts(), SQ_close_connection(), SQ_execute_query(), SQ_free_result(), SQ_get_column_string(), SQ_get_connection(), SQ_row_next(), fprintf(), g_list_length(), sprintf(), sscanf()
|
Called by:
| PW_interact() | modules/pw/protocol_whois.c
|
References Variables:
| Query | modules/qi/query_instructions.c
|
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.
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
- Online References:
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.
Log the instruction.
More:
Authors:
ottrey
- Online References:
void log_inst_print ( char* str )
- char* str
- instruction to be logged.
void run_referral ( MYSQL* sql_connection, Query_instructions* qis, Query_environ* qe, int qi_index )
Calls:
| log_inst_print() | modules/qi/query_instructions.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_execute() | modules/qi/query_instructions.c
|
References Variables:
| Query | modules/qi/query_instructions.c
|
static void add_filter ( char* query_str, const Query_command* qc )
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
-
- 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
-
- 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.
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.
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 recursive, unsigned int filtered, unsigned int fast, sk_conn_st* condat, acc_st* acc_credit, acl_st* acl )
- 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 filtered
-
- unsigned int fast
-
- sk_conn_st* condat
- Connection data for the client
- acc_st* acc_credit
-
- acl_st* acl
-
Display the immediate data carried with the objects returned by the
radix tree.
Also free the list of answers.
static void write_radix_immediate ( GList* datlist, sk_conn_st* condat )
- GList* datlist
- sk_conn_st *condat Connection data for the client
More:
Authors:
marek
- Online References:
- sk_conn_st* condat
-
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 )