lithium3

Check-in [126306b9f8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:lithium-access_log: create dedicated tables for string values
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 126306b9f80f20a5c7aaef9fdd11eefece9cc130
User & Date: nat 2017-01-24 21:54:48
Context
2017-01-25
20:18
lithium-access_log: insert string values into the dedicated tables check-in: 16ac076d4f user: nat tags: trunk
2017-01-24
21:54
lithium-access_log: create dedicated tables for string values check-in: 126306b9f8 user: nat tags: trunk
2017-01-23
22:38
lithium-access_log: refactor SQL table creation into a procedure check-in: eee45bf240 user: nat tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/lithium-access_log.adb.

116
117
118
119
120
121
122



123
124
125
126
127
128
129
      Stmt : in out SQLite3.SQLite3_Statement;
      Stmt_Ready : in out Boolean;
      Input : in Input_Type;
      SQL_String : in String;
      Name : in String);
      --  Run one attempt of the given statement and handle errors





   protected Queue is
      entry Append (Values : in Log_Entry);
      procedure Next (Values : out Extended_Log_Entry);
   private
      Task_Waiting : Boolean := True;
      List : Log_Queue.List;







>
>
>







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
      Stmt : in out SQLite3.SQLite3_Statement;
      Stmt_Ready : in out Boolean;
      Input : in Input_Type;
      SQL_String : in String;
      Name : in String);
      --  Run one attempt of the given statement and handle errors

   function Table_Name (T : in String_Tables.Enum) return String;
      --  Return the SQL table name associated with T


   protected Queue is
      entry Append (Values : in Log_Entry);
      procedure Next (Values : out Extended_Log_Entry);
   private
      Task_Waiting : Boolean := True;
      List : Log_Queue.List;
228
229
230
231
232
233
234
235








236
237
238
239
240
241
242
            "Unable to open """ & Name & """: "
            & SQLite3.Error_Code'Image (Status));
         raise SQLite_Error;
      end if;

      Create_Tables :
      begin
         Run_Simple_SQL (Handle, Create_SQL, "create");








      exception
         when SQLite_Error =>
            SQLite3.Close (Handle, Status);
            raise;
      end Create_Tables;
   end Initialize;








|
>
>
>
>
>
>
>
>







231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
            "Unable to open """ & Name & """: "
            & SQLite3.Error_Code'Image (Status));
         raise SQLite_Error;
      end if;

      Create_Tables :
      begin
         Run_Simple_SQL (Handle, Create_SQL, "main create");

         for T in String_Tables.Enum loop
            Run_Simple_SQL
              (Handle,
               "CREATE TABLE IF NOT EXISTS " & Table_Name (T)
                 & " (value TEXT PRIMARY KEY);",
               Table_Name (T) & " create");
         end loop;
      exception
         when SQLite_Error =>
            SQLite3.Close (Handle, Status);
            raise;
      end Create_Tables;
   end Initialize;

366
367
368
369
370
371
372


















373
374
375
376
377
378
379
               end if;
         end Run_Statement;

         exit Retry_Loop when Stmt_Ready;
      end loop Retry_Loop;
   end Run_SQL;





















   ----------------------
   -- Public Interface --
   ----------------------

   procedure Log







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
               end if;
         end Run_Statement;

         exit Retry_Loop when Stmt_Ready;
      end loop Retry_Loop;
   end Run_SQL;


   function Table_Name (T : in String_Tables.Enum) return String is
      use String_Tables;
   begin
      case T is
         when Peer_Name =>     return "peer_names";
         when Method =>        return "methods";
         when Path =>          return "paths";
         when Http_Version =>  return "http_versions";
         when Referrer =>      return "referrers";
         when User_Agent =>    return "user_agents";
         when Cookies =>       return "cookies";
         when Host =>          return "hosts";
         when Real_IP =>       return "real_ips";
         when Forwarded_For => return "forwarded_fors";
      end case;
   end Table_Name;



   ----------------------
   -- Public Interface --
   ----------------------

   procedure Log