diff options
| -rw-r--r-- | CHANGELOG | 13 | ||||
| -rw-r--r-- | mod_log_sql.c | 193 |
2 files changed, 188 insertions, 18 deletions
| @@ -1,16 +1,17 @@ | |||
| 1 | $Id: CHANGELOG,v 1.12 2002/05/16 21:35:12 helios Exp $ | 1 | $Id: CHANGELOG,v 1.13 2002/05/24 20:52:39 helios Exp $ |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | TODO: | 4 | TODO: |
| 5 | * Full commenting of the code. | ||
| 6 | * Rethink documentation flow and rewrite? | 5 | * Rethink documentation flow and rewrite? |
| 7 | * Port connection portion to other DBMS? Genericize the module? Start with PostgreSQL. | 6 | * Port connection portion to other DBMS? Genericize the module? Start with PostgreSQL. |
| 8 | * check for mandatory conf directives / syntax quit if not | 7 | * check for mandatory conf directives / syntax quit if not |
| 8 | * GNU autoconf | ||
| 9 | * merge server config into vh config | 9 | * merge server config into vh config |
| 10 | * port to Apache 2.x | 10 | * port to Apache 2.x |
| 11 | * does determining table name in massvirtual mode upon every request | 11 | * does determining table name in massvirtual mode upon every request |
| 12 | cause performance degradation? If so fix. | 12 | cause performance degradation? If so fix. |
| 13 | 13 | ||
| 14 | |||
| 14 | CHANGES: | 15 | CHANGES: |
| 15 | 16 | ||
| 16 | 1.17: | 17 | 1.17: |
| @@ -20,6 +21,9 @@ CHANGES: | |||
| 20 | custom modules that provide loggable info in the notes, e.g. mod_gzip. | 21 | custom modules that provide loggable info in the notes, e.g. mod_gzip. |
| 21 | A new directive MySQLWhichNotes configures which notes to log to the | 22 | A new directive MySQLWhichNotes configures which notes to log to the |
| 22 | notes_log table. | 23 | notes_log table. |
| 24 | * Added capability of logging inbound and outbound headers. New directives | ||
| 25 | LogSQLWhichHeadersIn and LogSQLWhichHeadersOut configure which headers to | ||
| 26 | capture. Headers are stored in their own table or tables. | ||
| 23 | * Fixed potential segfault in preserve file function due to silly pfclose | 27 | * Fixed potential segfault in preserve file function due to silly pfclose |
| 24 | placement. (Only affected user if the preserve file couldn't | 28 | placement. (Only affected user if the preserve file couldn't |
| 25 | be opened.) | 29 | be opened.) |
| @@ -37,7 +41,10 @@ CHANGES: | |||
| 37 | of database inspecificity. More to come. | 41 | of database inspecificity. More to come. |
| 38 | * Simplified error messages. | 42 | * Simplified error messages. |
| 39 | * Table creation now uses safe_mysql_query and checks the result. | 43 | * Table creation now uses safe_mysql_query and checks the result. |
| 40 | 44 | * Config directives used to begin with MySQL, now begin with LogSQL. | |
| 45 | This is for database inspecificity. In your httpd.conf just do | ||
| 46 | a search-and-replace. | ||
| 47 | |||
| 41 | 48 | ||
| 42 | 1.16: | 49 | 1.16: |
| 43 | * Moved all the user DEFINEs inside the .c file -- splitting them | 50 | * Moved all the user DEFINEs inside the .c file -- splitting them |
diff --git a/mod_log_sql.c b/mod_log_sql.c index 6726163..ecdfcf0 100644 --- a/mod_log_sql.c +++ b/mod_log_sql.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $Id: mod_log_sql.c,v 1.13 2002/05/16 21:35:12 helios Exp $ */ | 1 | /* $Id: mod_log_sql.c,v 1.14 2002/05/24 20:52:39 helios Exp $ */ |
| 2 | 2 | ||
| 3 | /* --------* | 3 | /* --------* |
| 4 | * DEFINES * | 4 | * DEFINES * |
| @@ -71,7 +71,11 @@ typedef struct { | |||
| 71 | array_header *transfer_ignore_list; | 71 | array_header *transfer_ignore_list; |
| 72 | array_header *remhost_ignore_list; | 72 | array_header *remhost_ignore_list; |
| 73 | array_header *notes_list; | 73 | array_header *notes_list; |
| 74 | array_header *hout_list; | ||
| 75 | array_header *hin_list; | ||
| 74 | char *notes_table_name; | 76 | char *notes_table_name; |
| 77 | char *hout_table_name; | ||
| 78 | char *hin_table_name; | ||
| 75 | char *transfer_table_name; | 79 | char *transfer_table_name; |
| 76 | char *transfer_log_format; | 80 | char *transfer_log_format; |
| 77 | char *preserve_file; | 81 | char *preserve_file; |
| @@ -718,6 +722,28 @@ const char *set_log_sql_notes_table(cmd_parms *parms, void *dummy, char *arg) | |||
| 718 | return NULL; | 722 | return NULL; |
| 719 | } | 723 | } |
| 720 | 724 | ||
| 725 | const char *set_log_sql_hin_table(cmd_parms *parms, void *dummy, char *arg) | ||
| 726 | { | ||
| 727 | log_sql_state *cls = get_module_config(parms->server->module_config, &mysql_log_module); | ||
| 728 | |||
| 729 | if (massvirtual != 0) | ||
| 730 | ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLHeadersInLogTable when LogSQLMassVirtualHosting is On. Ignoring."); | ||
| 731 | else | ||
| 732 | cls->hin_table_name = arg; | ||
| 733 | return NULL; | ||
| 734 | } | ||
| 735 | |||
| 736 | const char *set_log_sql_hout_table(cmd_parms *parms, void *dummy, char *arg) | ||
| 737 | { | ||
| 738 | log_sql_state *cls = get_module_config(parms->server->module_config, &mysql_log_module); | ||
| 739 | |||
| 740 | if (massvirtual != 0) | ||
| 741 | ap_log_error(APLOG_MARK,WARNINGLEVEL,parms->server,"mod_log_sql: do not set LogSQLHeadersOutLogTable when LogSQLMassVirtualHosting is On. Ignoring."); | ||
| 742 | else | ||
| 743 | cls->hout_table_name = arg; | ||
| 744 | return NULL; | ||
| 745 | } | ||
| 746 | |||
| 721 | const char *set_log_sql_transfer_log_format(cmd_parms *parms, void *dummy, char *arg) | 747 | const char *set_log_sql_transfer_log_format(cmd_parms *parms, void *dummy, char *arg) |
| 722 | { | 748 | { |
| 723 | log_sql_state *cls = get_module_config(parms->server->module_config, &mysql_log_module); | 749 | log_sql_state *cls = get_module_config(parms->server->module_config, &mysql_log_module); |
| @@ -733,7 +759,6 @@ const char *set_log_sql_socket_file(cmd_parms *parms, void *dummy, char *arg) | |||
| 733 | return NULL; | 759 | return NULL; |
| 734 | } | 760 | } |
| 735 | 761 | ||
| 736 | |||
| 737 | const char *add_log_sql_referer_ignore(cmd_parms *parms, void *dummy, char *arg) | 762 | const char *add_log_sql_referer_ignore(cmd_parms *parms, void *dummy, char *arg) |
| 738 | { | 763 | { |
| 739 | char **addme; | 764 | char **addme; |
| @@ -774,6 +799,26 @@ const char *add_log_sql_note(cmd_parms *parms, void *dummy, char *arg) | |||
| 774 | return NULL; | 799 | return NULL; |
| 775 | } | 800 | } |
| 776 | 801 | ||
| 802 | const char *add_log_sql_hout(cmd_parms *parms, void *dummy, char *arg) | ||
| 803 | { | ||
| 804 | char **addme; | ||
| 805 | log_sql_state *cls = get_module_config(parms->server->module_config, &mysql_log_module); | ||
| 806 | |||
| 807 | addme = push_array(cls->hout_list); | ||
| 808 | *addme = pstrdup(cls->hout_list->pool, arg); | ||
| 809 | return NULL; | ||
| 810 | } | ||
| 811 | |||
| 812 | const char *add_log_sql_hin(cmd_parms *parms, void *dummy, char *arg) | ||
| 813 | { | ||
| 814 | char **addme; | ||
| 815 | log_sql_state *cls = get_module_config(parms->server->module_config, &mysql_log_module); | ||
| 816 | |||
| 817 | addme = push_array(cls->hin_list); | ||
| 818 | *addme = pstrdup(cls->hin_list->pool, arg); | ||
| 819 | return NULL; | ||
| 820 | } | ||
| 821 | |||
| 777 | 822 | ||
| 778 | 823 | ||
| 779 | 824 | ||
| @@ -850,12 +895,16 @@ void *log_sql_make_state(pool *p, server_rec *s) | |||
| 850 | cls->transfer_table_name = NULL; | 895 | cls->transfer_table_name = NULL; |
| 851 | cls->transfer_log_format = NULL; | 896 | cls->transfer_log_format = NULL; |
| 852 | cls->notes_table_name = "notes"; | 897 | cls->notes_table_name = "notes"; |
| 898 | cls->hin_table_name = "headers_in"; | ||
| 899 | cls->hout_table_name = "headers_out"; | ||
| 853 | 900 | ||
| 854 | cls->referer_ignore_list = make_array(p, 1, sizeof(char *)); | 901 | cls->referer_ignore_list = make_array(p, 1, sizeof(char *)); |
| 855 | cls->transfer_ignore_list = make_array(p, 1, sizeof(char *)); | 902 | cls->transfer_ignore_list = make_array(p, 1, sizeof(char *)); |
| 856 | cls->remhost_ignore_list = make_array(p, 1, sizeof(char *)); | 903 | cls->remhost_ignore_list = make_array(p, 1, sizeof(char *)); |
| 857 | cls->notes_list = make_array(p, 1, sizeof(char *)); | 904 | cls->notes_list = make_array(p, 1, sizeof(char *)); |
| 858 | cls->table_made = 0; | 905 | cls->hin_list = make_array(p, 1, sizeof(char *)); |
| 906 | cls->hout_list = make_array(p, 1, sizeof(char *)); | ||
| 907 | cls->table_made = 0; | ||
| 859 | 908 | ||
| 860 | cls->preserve_file = "/tmp/sql-preserve"; | 909 | cls->preserve_file = "/tmp/sql-preserve"; |
| 861 | cls->cookie_name = NULL; | 910 | cls->cookie_name = NULL; |
| @@ -874,6 +923,12 @@ command_rec log_sql_cmds[] = { | |||
| 874 | {"LogSQLNotesLogTable", set_log_sql_notes_table, NULL, RSRC_CONF, TAKE1, | 923 | {"LogSQLNotesLogTable", set_log_sql_notes_table, NULL, RSRC_CONF, TAKE1, |
| 875 | "The database table that holds the notes"} | 924 | "The database table that holds the notes"} |
| 876 | , | 925 | , |
| 926 | {"LogSQLHeadersOutLogTable", set_log_sql_hout_table, NULL, RSRC_CONF, TAKE1, | ||
| 927 | "The database table that holds the outbound headers"} | ||
| 928 | , | ||
| 929 | {"LogSQLHeadersInLogTable", set_log_sql_hin_table, NULL, RSRC_CONF, TAKE1, | ||
| 930 | "The database table that holds the inbound headers"} | ||
| 931 | , | ||
| 877 | {"LogSQLTransferLogFormat", set_log_sql_transfer_log_format, NULL, RSRC_CONF, TAKE1, | 932 | {"LogSQLTransferLogFormat", set_log_sql_transfer_log_format, NULL, RSRC_CONF, TAKE1, |
| 878 | "Instruct the module what information to log to the database transfer log"} | 933 | "Instruct the module what information to log to the database transfer log"} |
| 879 | , | 934 | , |
| @@ -908,7 +963,13 @@ command_rec log_sql_cmds[] = { | |||
| 908 | "Name of the file to employ for socket connections to database"} | 963 | "Name of the file to employ for socket connections to database"} |
| 909 | , | 964 | , |
| 910 | {"LogSQLWhichNotes", add_log_sql_note, NULL, RSRC_CONF, ITERATE, | 965 | {"LogSQLWhichNotes", add_log_sql_note, NULL, RSRC_CONF, ITERATE, |
| 911 | "Members of the 'notes' table that you would like to log"} | 966 | "Members of the 'notes' that you would like to log"} |
| 967 | , | ||
| 968 | {"LogSQLWhichHeadersOut", add_log_sql_hout, NULL, RSRC_CONF, ITERATE, | ||
| 969 | "Members of the 'headers out' that you would like to log"} | ||
| 970 | , | ||
| 971 | {"LogSQLWhichHeadersIn", add_log_sql_hin, NULL, RSRC_CONF, ITERATE, | ||
| 972 | "Members of the 'headers in' that you would like to log"} | ||
| 912 | , | 973 | , |
| 913 | {NULL} | 974 | {NULL} |
| 914 | }; | 975 | }; |
| @@ -931,13 +992,19 @@ int log_sql_transaction(request_rec *orig) | |||
| 931 | if ( massvirtual == 1 ) { | 992 | if ( massvirtual == 1 ) { |
| 932 | char *access_base = "access_"; | 993 | char *access_base = "access_"; |
| 933 | char *notes_base = "notes_"; | 994 | char *notes_base = "notes_"; |
| 995 | char *hout_base = "headout_"; | ||
| 996 | char *hin_base = "headin_"; | ||
| 934 | char *a_tablename; | 997 | char *a_tablename; |
| 935 | char *n_tablename; | 998 | char *n_tablename; |
| 999 | char *i_tablename; | ||
| 1000 | char *o_tablename; | ||
| 936 | int i; | 1001 | int i; |
| 937 | 1002 | ||
| 938 | /* Find memory long enough to hold the table name + \0. */ | 1003 | /* Find memory long enough to hold the table name + \0. */ |
| 939 | a_tablename = ap_pstrcat(orig->pool, access_base, ap_get_server_name(orig), NULL); | 1004 | a_tablename = ap_pstrcat(orig->pool, access_base, ap_get_server_name(orig), NULL); |
| 940 | n_tablename = ap_pstrcat(orig->pool, notes_base, ap_get_server_name(orig), NULL); | 1005 | n_tablename = ap_pstrcat(orig->pool, notes_base, ap_get_server_name(orig), NULL); |
| 1006 | i_tablename = ap_pstrcat(orig->pool, hin_base, ap_get_server_name(orig), NULL); | ||
| 1007 | o_tablename = ap_pstrcat(orig->pool, hout_base, ap_get_server_name(orig), NULL); | ||
| 941 | 1008 | ||
| 942 | /* Transform any dots or dashes to underscores */ | 1009 | /* Transform any dots or dashes to underscores */ |
| 943 | for (i = 0; i < strlen(a_tablename); i++) { | 1010 | for (i = 0; i < strlen(a_tablename); i++) { |
| @@ -948,12 +1015,22 @@ int log_sql_transaction(request_rec *orig) | |||
| 948 | if ( (n_tablename[i] == '.') || (n_tablename[i] == '-') ) | 1015 | if ( (n_tablename[i] == '.') || (n_tablename[i] == '-') ) |
| 949 | n_tablename[i] = '_'; | 1016 | n_tablename[i] = '_'; |
| 950 | } | 1017 | } |
| 1018 | for (i = 0; i < strlen(i_tablename); i++) { | ||
| 1019 | if ( (i_tablename[i] == '.') || (i_tablename[i] == '-') ) | ||
| 1020 | i_tablename[i] = '_'; | ||
| 1021 | } | ||
| 1022 | for (i = 0; i < strlen(o_tablename); i++) { | ||
| 1023 | if ( (o_tablename[i] == '.') || (o_tablename[i] == '-') ) | ||
| 1024 | o_tablename[i] = '_'; | ||
| 1025 | } | ||
| 951 | 1026 | ||
| 952 | /* Tell this virtual server its transfer table name, and | 1027 | /* Tell this virtual server its transfer table name, and |
| 953 | * turn on create_tables, which is implied by massvirtual. | 1028 | * turn on create_tables, which is implied by massvirtual. |
| 954 | */ | 1029 | */ |
| 955 | cls->transfer_table_name = a_tablename; | 1030 | cls->transfer_table_name = a_tablename; |
| 956 | cls->notes_table_name = n_tablename; | 1031 | cls->notes_table_name = n_tablename; |
| 1032 | cls->hout_table_name = o_tablename; | ||
| 1033 | cls->hin_table_name = i_tablename; | ||
| 957 | create_tables = 1; | 1034 | create_tables = 1; |
| 958 | } | 1035 | } |
| 959 | 1036 | ||
| @@ -962,16 +1039,20 @@ int log_sql_transaction(request_rec *orig) | |||
| 962 | return DECLINED; | 1039 | return DECLINED; |
| 963 | } else { | 1040 | } else { |
| 964 | const char *thehost; | 1041 | const char *thehost; |
| 965 | const char *thenote; | 1042 | const char *theitem; |
| 966 | char *fields = "", *values = ""; | 1043 | char *fields = "", *values = ""; |
| 967 | char *notesets = ""; | 1044 | char *itemsets = ""; |
| 968 | char *note_query = NULL; | 1045 | char *note_query = NULL; |
| 1046 | char *hin_query = NULL; | ||
| 1047 | char *hout_query = NULL; | ||
| 969 | const char *unique_id; | 1048 | const char *unique_id; |
| 970 | const char *formatted_item; | 1049 | const char *formatted_item; |
| 971 | int i, j, length; | 1050 | int i, j, length; |
| 972 | char *create_access = NULL; | 1051 | char *create_access = NULL; |
| 973 | char *create_notes = NULL; | 1052 | char *create_notes = NULL; |
| 974 | int create_results_access, create_results_notes; | 1053 | char *create_hout = NULL; |
| 1054 | char *create_hin = NULL; | ||
| 1055 | int create_results_access, create_results_notes, create_results_hout, create_results_hin; | ||
| 975 | 1056 | ||
| 976 | for (r = orig; r->next; r = r->next) { | 1057 | for (r = orig; r->next; r = r->next) { |
| 977 | continue; | 1058 | continue; |
| @@ -1057,27 +1138,86 @@ int log_sql_transaction(request_rec *orig) | |||
| 1057 | ptrptr2 = (char **) (cls->notes_list->elts + (cls->notes_list->nelts * cls->notes_list->elt_size)); | 1138 | ptrptr2 = (char **) (cls->notes_list->elts + (cls->notes_list->nelts * cls->notes_list->elt_size)); |
| 1058 | for (ptrptr = (char **) cls->notes_list->elts; ptrptr < ptrptr2; ptrptr = (char **) ((char *) ptrptr + cls->notes_list->elt_size)) { | 1139 | for (ptrptr = (char **) cls->notes_list->elts; ptrptr < ptrptr2; ptrptr = (char **) ((char *) ptrptr + cls->notes_list->elt_size)) { |
| 1059 | /* If the specified note (*ptrptr) exists for the current request... */ | 1140 | /* If the specified note (*ptrptr) exists for the current request... */ |
| 1060 | if ((thenote = ap_table_get(r->notes, *ptrptr))) { | 1141 | if ((theitem = ap_table_get(r->notes, *ptrptr))) { |
| 1061 | notesets = ap_pstrcat(r->pool, notesets, | 1142 | itemsets = ap_pstrcat(r->pool, itemsets, |
| 1062 | (i > 0 ? "," : ""), | 1143 | (i > 0 ? "," : ""), |
| 1063 | "('", | 1144 | "('", |
| 1064 | unique_id, | 1145 | unique_id, |
| 1065 | "','", | 1146 | "','", |
| 1066 | escape_query(*ptrptr, r->pool), | 1147 | escape_query(*ptrptr, r->pool), |
| 1067 | "','", | 1148 | "','", |
| 1068 | escape_query(thenote, r->pool), | 1149 | escape_query(theitem, r->pool), |
| 1069 | "')", | 1150 | "')", |
| 1070 | NULL); | 1151 | NULL); |
| 1071 | i++; | 1152 | i++; |
| 1072 | } | 1153 | } |
| 1073 | } | 1154 | } |
| 1074 | if ( notesets != "" ) { | 1155 | if ( itemsets != "" ) { |
| 1075 | note_query = ap_pstrcat(r->pool, "insert into ", cls->notes_table_name, " (id, item, val) values ", notesets, NULL); | 1156 | note_query = ap_pstrcat(r->pool, "insert into ", cls->notes_table_name, " (id, item, val) values ", itemsets, NULL); |
| 1076 | #ifdef DEBUG | 1157 | #ifdef DEBUG |
| 1077 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: note string: %s", note_query); | 1158 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: note string: %s", note_query); |
| 1078 | #endif | 1159 | #endif |
| 1079 | } | 1160 | } |
| 1080 | 1161 | ||
| 1162 | /* Work through the list of headers-out defined by LogSQLHeadersOutToLog */ | ||
| 1163 | i = 0; | ||
| 1164 | itemsets = ""; | ||
| 1165 | |||
| 1166 | ptrptr2 = (char **) (cls->hout_list->elts + (cls->hout_list->nelts * cls->hout_list->elt_size)); | ||
| 1167 | for (ptrptr = (char **) cls->hout_list->elts; ptrptr < ptrptr2; ptrptr = (char **) ((char *) ptrptr + cls->hout_list->elt_size)) { | ||
| 1168 | /* If the specified note (*ptrptr) exists for the current request... */ | ||
| 1169 | if ((theitem = ap_table_get(r->headers_out, *ptrptr))) { | ||
| 1170 | itemsets = ap_pstrcat(r->pool, itemsets, | ||
| 1171 | (i > 0 ? "," : ""), | ||
| 1172 | "('", | ||
| 1173 | unique_id, | ||
| 1174 | "','", | ||
| 1175 | escape_query(*ptrptr, r->pool), | ||
| 1176 | "','", | ||
| 1177 | escape_query(theitem, r->pool), | ||
| 1178 | "')", | ||
| 1179 | NULL); | ||
| 1180 | i++; | ||
| 1181 | } | ||
| 1182 | } | ||
| 1183 | if ( itemsets != "" ) { | ||
| 1184 | hout_query = ap_pstrcat(r->pool, "insert into ", cls->hout_table_name, " (id, item, val) values ", itemsets, NULL); | ||
| 1185 | #ifdef DEBUG | ||
| 1186 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: header_out string: %s", hout_query); | ||
| 1187 | #endif | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | |||
| 1191 | /* Work through the list of headers-in defined by LogSQLHeadersInToLog */ | ||
| 1192 | i = 0; | ||
| 1193 | itemsets = ""; | ||
| 1194 | |||
| 1195 | ptrptr2 = (char **) (cls->hin_list->elts + (cls->hin_list->nelts * cls->hin_list->elt_size)); | ||
| 1196 | for (ptrptr = (char **) cls->hin_list->elts; ptrptr < ptrptr2; ptrptr = (char **) ((char *) ptrptr + cls->hin_list->elt_size)) { | ||
| 1197 | /* If the specified note (*ptrptr) exists for the current request... */ | ||
| 1198 | if ((theitem = ap_table_get(r->headers_in, *ptrptr))) { | ||
| 1199 | itemsets = ap_pstrcat(r->pool, itemsets, | ||
| 1200 | (i > 0 ? "," : ""), | ||
| 1201 | "('", | ||
| 1202 | unique_id, | ||
| 1203 | "','", | ||
| 1204 | escape_query(*ptrptr, r->pool), | ||
| 1205 | "','", | ||
| 1206 | escape_query(theitem, r->pool), | ||
| 1207 | "')", | ||
| 1208 | NULL); | ||
| 1209 | i++; | ||
| 1210 | } | ||
| 1211 | } | ||
| 1212 | if ( itemsets != "" ) { | ||
| 1213 | hin_query = ap_pstrcat(r->pool, "insert into ", cls->hin_table_name, " (id, item, val) values ", itemsets, NULL); | ||
| 1214 | #ifdef DEBUG | ||
| 1215 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"mod_log_sql: header_in string: %s", hin_query); | ||
| 1216 | #endif | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | |||
| 1220 | |||
| 1081 | /* Is this virtual server's table flagged as made? We flag it as such in order | 1221 | /* Is this virtual server's table flagged as made? We flag it as such in order |
| 1082 | * to avoid extra processing with each request. If it's not flagged as made, | 1222 | * to avoid extra processing with each request. If it's not flagged as made, |
| 1083 | * set up the CREATE string. | 1223 | * set up the CREATE string. |
| @@ -1114,13 +1254,22 @@ int log_sql_transaction(request_rec *orig) | |||
| 1114 | item varchar(80),\ | 1254 | item varchar(80),\ |
| 1115 | val varchar(80))"; | 1255 | val varchar(80))"; |
| 1116 | 1256 | ||
| 1257 | char *headers_suffix = | ||
| 1258 | " (id char(19),\ | ||
| 1259 | item varchar(80),\ | ||
| 1260 | val varchar(80))"; | ||
| 1261 | |||
| 1117 | /* Find memory long enough to hold the whole CREATE string + \0 */ | 1262 | /* Find memory long enough to hold the whole CREATE string + \0 */ |
| 1118 | create_access = ap_pstrcat(orig->pool, createprefix, cls->transfer_table_name, access_suffix, NULL); | 1263 | create_access = ap_pstrcat(orig->pool, createprefix, cls->transfer_table_name, access_suffix, NULL); |
| 1119 | create_notes = ap_pstrcat(orig->pool, createprefix, cls->notes_table_name, notes_suffix, NULL); | 1264 | create_notes = ap_pstrcat(orig->pool, createprefix, cls->notes_table_name, notes_suffix, NULL); |
| 1265 | create_hout = ap_pstrcat(orig->pool, createprefix, cls->hout_table_name, headers_suffix, NULL); | ||
| 1266 | create_hin = ap_pstrcat(orig->pool, createprefix, cls->hin_table_name, headers_suffix, NULL); | ||
| 1120 | 1267 | ||
| 1121 | #ifdef DEBUG | 1268 | #ifdef DEBUG |
| 1122 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_access); | 1269 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_access); |
| 1123 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_notes); | 1270 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_notes); |
| 1271 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_hout); | ||
| 1272 | ap_log_error(APLOG_MARK,DEBUGLEVEL,orig->server,"create string: %s", create_hin); | ||
| 1124 | #endif | 1273 | #endif |
| 1125 | 1274 | ||
| 1126 | } | 1275 | } |
| @@ -1144,7 +1293,13 @@ int log_sql_transaction(request_rec *orig) | |||
| 1144 | * gone and send the entry to the preserve file instead. | 1293 | * gone and send the entry to the preserve file instead. |
| 1145 | * Note that we don't keep logging the db error over and over. */ | 1294 | * Note that we don't keep logging the db error over and over. */ |
| 1146 | preserve_entry(orig, access_query); | 1295 | preserve_entry(orig, access_query); |
| 1147 | preserve_entry(orig, note_query); | 1296 | if ( note_query != NULL ) |
| 1297 | preserve_entry(orig, note_query); | ||
| 1298 | if ( hin_query != NULL ) | ||
| 1299 | preserve_entry(orig, hin_query); | ||
| 1300 | if ( hout_query != NULL ) | ||
| 1301 | preserve_entry(orig, hout_query); | ||
| 1302 | |||
| 1148 | return OK; | 1303 | return OK; |
| 1149 | } else { | 1304 | } else { |
| 1150 | /* Whew, we got the DB link back */ | 1305 | /* Whew, we got the DB link back */ |
| @@ -1159,9 +1314,11 @@ int log_sql_transaction(request_rec *orig) | |||
| 1159 | /* Make the tables if we're supposed to. */ | 1314 | /* Make the tables if we're supposed to. */ |
| 1160 | if ((cls->table_made != 1) && (create_tables != 0)) { | 1315 | if ((cls->table_made != 1) && (create_tables != 0)) { |
| 1161 | create_results_access = safe_mysql_query(orig, create_access); | 1316 | create_results_access = safe_mysql_query(orig, create_access); |
| 1162 | create_results_notes = safe_mysql_query(orig,create_notes); | 1317 | create_results_notes = safe_mysql_query(orig, create_notes); |
| 1318 | create_results_hin = safe_mysql_query(orig, create_hin); | ||
| 1319 | create_results_hout = safe_mysql_query(orig, create_hout); | ||
| 1163 | 1320 | ||
| 1164 | if ( (create_results_access == 0) && (create_results_notes == 0) ) | 1321 | if ( (create_results_access == 0) && (create_results_notes == 0) && (create_results_hin == 0) && (create_results_hout == 0) ) |
| 1165 | cls->table_made = 1; | 1322 | cls->table_made = 1; |
| 1166 | else | 1323 | else |
| 1167 | ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: failed to create all tables, see preserve file"); | 1324 | ap_log_error(APLOG_MARK,ERRLEVEL,orig->server,"mod_log_sql: failed to create all tables, see preserve file"); |
| @@ -1173,6 +1330,12 @@ int log_sql_transaction(request_rec *orig) | |||
| 1173 | /* If notes are available to log, make the notes-table insert */ | 1330 | /* If notes are available to log, make the notes-table insert */ |
| 1174 | if ( note_query != NULL ) | 1331 | if ( note_query != NULL ) |
| 1175 | safe_mysql_query(orig, note_query); | 1332 | safe_mysql_query(orig, note_query); |
| 1333 | |||
| 1334 | if ( hout_query != NULL ) | ||
| 1335 | safe_mysql_query(orig, hout_query); | ||
| 1336 | |||
| 1337 | if ( hin_query != NULL ) | ||
| 1338 | safe_mysql_query(orig, hin_query); | ||
| 1176 | 1339 | ||
| 1177 | return OK; | 1340 | return OK; |
| 1178 | } | 1341 | } |
