File modules/sq/mysql_driver.c

  $Revision: 1.18 $

SQL module (sq) - this is a MySQL implementation of the SQL module.
Status: NOT REVUED, NOT TESTED

Included Files


Preprocessor definitions

String sizes

#define STR_S 63

#define STR_M 255

#define STR_L 1023

#define STR_XL 4095

#define STR_XXL 16383


Global Function SQ_close_connection()

  Call this function to close a connection to the server

SQ_connection_t *sql_connection The connection to the database.
More:
  Authors:
        ottrey
Online References:
void SQ_close_connection ( MYSQL* sql_connection )
Prototyped in: modules/sq/mysql_driver.h
Calls: mysql_close()
Called by: AC_acc_load()modules/ac/access_control.c
  AC_commit()modules/ac/access_control.c
  QI_execute()modules/qi/query_instructions.c
  command_sql()modules/pc/protocol_config.c

Global Function SQ_errno()

  Get the error number for the last error.

SQ_connection_t *sql_connection The connection to the database.
More:
  Authors:
        ottrey
Online References:
int SQ_errno ( MYSQL* sql_connection )
Prototyped in: modules/sq/mysql_driver.h
Called by: AC_acc_load()modules/ac/access_control.c

Global Function SQ_error()

  Get the error string for the last error.

SQ_connection_t *sql_connection The connection to the database.
More:
  Authors:
        ottrey
Online References:
char* SQ_error ( MYSQL* sql_connection )
Prototyped in: modules/sq/mysql_driver.h
Called by: AC_acc_load()modules/ac/access_control.c

Global Function SQ_execute_query()

  Execute the sql query.

SQ_connection_t *sql_connection Connection to database.
More:
  Authors:
        ottrey
Online References:
MYSQL_RES* SQ_execute_query ( int store_or_not, MYSQL* sql_connection, const char* query )
int store_or_not
 
MYSQL* sql_connection
 
const char* query
SQL query.
Prototyped in: modules/sq/mysql_driver.h
Calls: mysql_free_result(), mysql_query(), mysql_store_result()
Called by: AC_acc_load()modules/ac/access_control.c
  AC_commit()modules/ac/access_control.c
  QI_execute()modules/qi/query_instructions.c
  command_sql()modules/pc/protocol_config.c
  insert_radix_serials()modules/qi/query_instructions.c
  run_referral()modules/qi/query_instructions.c
  write_objects()modules/qi/query_instructions.c

Global Function SQ_free_result()

  Free the result set.

SQ_result_set_t *result The results.
More:
  Authors:
        ottrey
Online References:
void SQ_free_result ( MYSQL_RES* result )
Prototyped in: modules/sq/mysql_driver.h
Calls: mysql_free_result()
Called by: AC_acc_load()modules/ac/access_control.c
  AC_commit()modules/ac/access_control.c
  QI_execute()modules/qi/query_instructions.c
  command_sql()modules/pc/protocol_config.c
  run_referral()modules/qi/query_instructions.c
  write_objects()modules/qi/query_instructions.c

Global Function SQ_get_column_count()

  Get the column count.

SQ_result_set_t *result The results from the query.
More:
  Authors:
        ottrey
Online References:
int SQ_get_column_count ( MYSQL_RES* result )
Prototyped in: modules/sq/mysql_driver.h

Global Function SQ_get_column_int()

  Get an integer from the column.

SQ_result_set_t *result The results.
SQ_row_t *current_row The current row.
This uses atoi. So it may be advisable not to use it.
More:
  Authors:
        ottrey
Online References:
int SQ_get_column_int ( MYSQL_RES* result, MYSQL_ROW* current_row, unsigned int column )
MYSQL_RES* result
 
MYSQL_ROW* current_row
 
unsigned int column
The column index.
Prototyped in: modules/sq/mysql_driver.h
Calls: atoi()

Global Function SQ_get_column_label()

  Get the column label.

SQ_result_set_t *result The results from the query.
More:
  Authors:
        ottrey
Online References:
char* SQ_get_column_label ( MYSQL_RES* result, unsigned int column )
MYSQL_RES* result
 
unsigned int column
The column index.
Prototyped in: modules/sq/mysql_driver.h
Calls: fprintf(), strcpy(), strlen(), wr_real_malloc()
Called by: SQ_result_to_string()modules/sq/mysql_driver.c

Global Function SQ_get_column_max_length()

  Get the max length of the column.

SQ_result_set_t *result The results from the query.
More:
  Authors:
        ottrey
Online References:
unsigned int SQ_get_column_max_length ( MYSQL_RES* result, unsigned int column )
MYSQL_RES* result
 
unsigned int column
The column index.
Prototyped in: modules/sq/mysql_driver.h
Called by: SQ_result_to_string()modules/sq/mysql_driver.c

Global Function SQ_get_column_string()

  Get the column string.

SQ_row_t *current_row The current row (obtained from a SQ_row_next() ).
More:
  Authors:
        ottrey
Online References:
char* SQ_get_column_string ( MYSQL_RES* result, MYSQL_ROW* current_row, unsigned int column )
MYSQL_RES* result
 
MYSQL_ROW* current_row
 
unsigned int column
The column index.
Prototyped in: modules/sq/mysql_driver.h
Calls: fprintf(), memcpy(), mysql_fetch_lengths(), wr_real_malloc()
Called by: AC_acc_load()modules/ac/access_control.c
  AC_commit()modules/ac/access_control.c
  QI_execute()modules/qi/query_instructions.c
  run_referral()modules/qi/query_instructions.c
  write_results()modules/qi/query_instructions.c

Global Function SQ_get_column_strings()

  Get the all the strings in one column.

SQ_result_set_t *result The results.
More:
  Authors:
        ottrey
Online References:
char* SQ_get_column_strings ( MYSQL_RES* result, unsigned int column )
MYSQL_RES* result
 
unsigned int column
The column index.
Prototyped in: modules/sq/mysql_driver.h
Calls: fprintf(), mysql_fetch_row(), sprintf(), strcat(), strcmp(), strcpy(), strlen(), wr_real_malloc()

Global Function SQ_get_connection()

  Get a connection to the database.

More:
  Authors:
        ottrey
Online References:
MYSQL* SQ_get_connection ( const char* host, unsigned int port, const char* db, const char* user, const char* password )
Prototyped in: modules/sq/mysql_driver.h
Calls: mysql_init(), mysql_real_connect(), printf()
Called by: AC_acc_load()modules/ac/access_control.c
  AC_commit()modules/ac/access_control.c
  QI_execute()modules/qi/query_instructions.c
  SQ_get_connection2()modules/sq/mysql_driver.c
  command_sql()modules/pc/protocol_config.c

Global Function SQ_get_connection2()

MYSQL* SQ_get_connection2 ( void )
Prototyped in: modules/sq/mysql_driver.h
Calls: CO_get_database()modules/co/constants.c
  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
  SQ_get_connection()modules/sq/mysql_driver.c

Global Function SQ_info_to_string()

  Convert all available information about the sql server into a string.

SQ_connection_t *sql_connection The connection to the database.
More:
  Authors:
        ottrey
Online References:
char* SQ_info_to_string ( MYSQL* sql_connection )
Prototyped in: modules/sq/mysql_driver.h
Calls: fprintf(), mysql_dump_debug_info(), mysql_get_client_info(), mysql_get_host_info(), mysql_get_proto_info(), mysql_get_server_info(), mysql_list_processes(), mysql_ping(), mysql_stat(), sprintf(), strcat(), strcpy(), strlen(), wr_real_malloc()
Called by: command_sql()modules/pc/protocol_config.c

Global Function SQ_num_rows()

  Call this function to find out how many rows are in a query result

SQ_result_set_t *result The results.
More:
  Authors:
        ottrey
Online References:
int SQ_num_rows ( MYSQL_RES* result )
Prototyped in: modules/sq/mysql_driver.h
Called by: AC_commit()modules/ac/access_control.c
  run_referral()modules/qi/query_instructions.c

Global Function SQ_result_to_string()

  Convert the result set to a string.

SQ_result_set_t *result The results.
More:
  Authors:
        ottrey
Online References:
char* SQ_result_to_string ( MYSQL_RES* result )
Prototyped in: modules/sq/mysql_driver.h
Calls: SQ_get_column_label()modules/sq/mysql_driver.c
  SQ_get_column_max_length()modules/sq/mysql_driver.c
  fprintf(), mysql_fetch_row(), sprintf(), strcat(), strcpy(), strlen(), wr_real_malloc()
Called by: command_sql()modules/pc/protocol_config.c

Global Function SQ_row_next()

  Get the next row.

SQ_result_set_t *result The results from the query.
unsigned int column The column index.
More:
  Authors:
        ottrey
Online References:
MYSQL_ROW* SQ_row_next ( MYSQL_RES* result )
Prototyped in: modules/sq/mysql_driver.h
Calls: mysql_fetch_row()
Called by: AC_acc_load()modules/ac/access_control.c
  AC_commit()modules/ac/access_control.c
  QI_execute()modules/qi/query_instructions.c
  run_referral()modules/qi/query_instructions.c
  write_results()modules/qi/query_instructions.c

Local Function log_query()

  Log the query.  This should/will get merged with a tracing module.

More:
  Authors:
        ottrey
Online References:
static void log_query ( const char* logfile, const char* query, struct timeb* start, struct timeb* stop )
Calls: fclose(), fopen(), fprintf(), printf(), strcmp()