CUBRID Engine  latest
ddl_log.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * ddl_log.c -
22  */
23 
24 #ident "$Id$"
25 
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include <stdlib.h>
29 #include <time.h>
30 #include <string.h>
31 #include <errno.h>
32 #if defined(WINDOWS)
33 #include <sys/timeb.h>
34 #include <process.h>
35 #include <io.h>
36 #else
37 #include <unistd.h>
38 #include <sys/time.h>
39 #include <sys/timeb.h>
40 #include <signal.h>
41 #endif
42 #include <assert.h>
43 
44 #include "porting.h"
45 #include "cas_common.h"
46 #include "ddl_log.h"
47 #include "parse_tree.h"
48 #include "system_parameter.h"
49 #include "environment_variable.h"
50 #include "broker_config.h"
51 #include "util_func.h"
52 
53 #define DDL_LOG_MSG (256)
54 #define DDL_LOG_PATH "log/ddl_audit"
55 #define DDL_LOG_LOADDB_FILE_PATH "log/ddl_audit/loaddb"
56 #define DDL_LOG_CSQL_FILE_PATH "log/ddl_audit/csql"
57 #define FILE_BUFFER_SIZE (1024)
58 #define TIME_STRING_SIZE (16)
59 #define DDL_TIME_LEN (32)
60 
61 
64 {
69  int br_index;
70  char ip_addr[16];
71  int pid;
72  char *sql_text;
73  char stmt_type;
75  struct timeval qry_exec_begin_time;
78  int err_code;
79  char *err_msg;
81  char load_filename[PATH_MAX];
82  char copy_filename[PATH_MAX];
83  char copy_fullpath[PATH_MAX];
87  char log_filepath[PATH_MAX];
90  bool jsp_mode;
91 };
93 static bool ddl_logging_enabled = false;
94 
95 static int logddl_make_filename (char *filename_buf, size_t buf_size, T_APP_NAME app_name);
96 static int logddl_make_copy_filename (T_APP_NAME app_name, const char *file_full_path, char *copy_filename,
97  size_t buf_size);
98 static int logddl_make_copy_dir (T_APP_NAME app_name, char *copy_filename, char *copy_fullpath, size_t buf_size);
99 static void logddl_backup (const char *path);
100 #if defined(WINDOWS)
101 static void unix_style_path (char *path);
102 #endif /* WINDOWS */
103 static int logddl_create_dir (const char *new_dir);
104 static int logddl_create_log_msg (char *msg);
105 static int logddl_get_current_date_time_string (char *buf, size_t size);
106 static int logddl_file_copy (char *src_file, char *dest_file);
107 static void logddl_remove_char (char *string, char ch);
108 static FILE *logddl_open (T_APP_NAME app_name);
109 static int logddl_get_time_string (char *buf, struct timeval *time_val);
110 static FILE *logddl_fopen_and_lock (const char *path, const char *mode);
111 static void logddl_set_elapsed_time (long sec, long msec);
112 static void logddl_timeval_diff (struct timeval *start, struct timeval *end, long *res_sec, long *res_msec);
113 static const char *logddl_get_app_name (T_APP_NAME app_name);
114 
115 static bool is_executed_ddl_for_trans = false;
116 static bool is_executed_ddl_for_csql = false;
117 
118 void
120 {
121  if (ddl_audit_handle != NULL)
122  {
123  FREE_MEM (ddl_audit_handle->sql_text);
124  FREE_MEM (ddl_audit_handle->err_msg);
125  FREE_MEM (ddl_audit_handle);
126  }
127 
128  ddl_audit_handle = (T_DDL_AUDIT_HANDLE *) MALLOC (sizeof (T_DDL_AUDIT_HANDLE));
129  if (ddl_audit_handle == NULL)
130  {
131  return;
132  }
133 
134  memset (ddl_audit_handle, 0x00, sizeof (T_DDL_AUDIT_HANDLE));
135 
136  ddl_audit_handle->stmt_type = -1;
137  ddl_audit_handle->execute_type = LOGDDL_RUN_EXECUTE_FUNC;
138  ddl_audit_handle->loaddb_file_type = LOADDB_FILE_TYPE_NONE;
139  ddl_audit_handle->csql_input_type = CSQL_INPUT_TYPE_NONE;
140 }
141 
142 void
143 logddl_free (bool all_free)
144 {
145  if (ddl_audit_handle == NULL)
146  {
147  logddl_init ();
148  return;
149  }
150 
151  if (ddl_logging_enabled == false)
152  {
153  return;
154  }
155 
156  FREE_MEM (ddl_audit_handle->sql_text);
157  FREE_MEM (ddl_audit_handle->err_msg);
158 
159  ddl_audit_handle->stmt_type = -1;
160  ddl_audit_handle->execute_type = LOGDDL_RUN_EXECUTE_FUNC;
161  ddl_audit_handle->loaddb_file_type = LOADDB_FILE_TYPE_NONE;
162  ddl_audit_handle->log_filepath[0] = '\0';
163  ddl_audit_handle->str_qry_exec_begin_time[0] = '\0';
164  ddl_audit_handle->elapsed_time[0] = '\0';
165  ddl_audit_handle->file_line_number = 0;
166  ddl_audit_handle->err_code = 0;
167  ddl_audit_handle->msg[0] = '\0';
168 
169  if (all_free)
170  {
172  is_executed_ddl_for_csql = false;
173  ddl_logging_enabled = false;
174  ddl_audit_handle->auto_commit_mode = false;
175  ddl_audit_handle->jsp_mode = false;
176  ddl_audit_handle->csql_input_type = CSQL_INPUT_TYPE_NONE;
177  ddl_audit_handle->load_filename[0] = '\0';
178  ddl_audit_handle->copy_filename[0] = '\0';
179  ddl_audit_handle->copy_fullpath[0] = '\0';
180  ddl_audit_handle->commit_count = 0;
181  }
182 }
183 
184 void
186 {
187  if (ddl_audit_handle != NULL)
188  {
189  FREE_MEM (ddl_audit_handle->sql_text);
190  FREE_MEM (ddl_audit_handle->err_msg);
191  FREE_MEM (ddl_audit_handle);
192  }
193 }
194 
195 void
197 {
198  if (ddl_audit_handle && ddl_logging_enabled)
199  {
200  ddl_audit_handle->app_name = app_name;
201  }
202 }
203 
204 void
206 {
207  char *pstr = NULL;
208  if (ddl_audit_handle == NULL || db_name == NULL || ddl_logging_enabled == false)
209  {
210  return;
211  }
212 
213  snprintf (ddl_audit_handle->db_name, sizeof (ddl_audit_handle->db_name), db_name);
214 
215  pstr = (char *) strchr (ddl_audit_handle->db_name, '@');
216  if (pstr != NULL)
217  {
218  *pstr = '\0';
219  }
220 }
221 
222 void
224 {
225  if (ddl_audit_handle != NULL && user_name != NULL && ddl_logging_enabled)
226  {
227  snprintf (ddl_audit_handle->user_name, sizeof (ddl_audit_handle->user_name), user_name);
228  }
229 }
230 
231 void
232 logddl_set_ip (const char *ip_addr)
233 {
234  if (ddl_audit_handle != NULL && ip_addr != NULL && ddl_logging_enabled)
235  {
236  snprintf (ddl_audit_handle->ip_addr, sizeof (ddl_audit_handle->ip_addr), ip_addr);
237  }
238 }
239 
240 void
241 logddl_set_pid (const int pid)
242 {
243  if (ddl_audit_handle && ddl_logging_enabled)
244  {
245  ddl_audit_handle->pid = pid;
246  }
247 }
248 
249 void
251 {
252  if (ddl_audit_handle != NULL && br_name != NULL && ddl_logging_enabled)
253  {
254  snprintf (ddl_audit_handle->br_name, BROKER_NAME_LEN, br_name);
255  }
256 }
257 
258 void
260 {
261  if (ddl_audit_handle && ddl_logging_enabled)
262  {
263  ddl_audit_handle->br_index = index;
264  }
265 }
266 
267 void
269 {
270  if (ddl_audit_handle == NULL || sql_text == NULL || len < 0 || ddl_logging_enabled == false)
271  {
272  return;
273  }
274 
275  if (ddl_audit_handle->sql_text != NULL)
276  {
277  FREE_MEM (ddl_audit_handle->sql_text);
278  }
279 
280  ddl_audit_handle->sql_text = (char *) MALLOC (len + 1);
281 
282  if (ddl_audit_handle->sql_text != NULL)
283  {
284  strncpy (ddl_audit_handle->sql_text, sql_text, len);
285  ddl_audit_handle->sql_text[len] = '\0';
286  }
287 }
288 
289 
290 void
292 {
293  if (ddl_audit_handle == NULL || ddl_logging_enabled == false)
294  {
295  return;
296  }
297 
298  ddl_audit_handle->stmt_type = stmt_type;
299 
300  if (logddl_is_ddl_type (stmt_type) == true)
301  {
304  }
305 }
306 
307 void
309 {
310  if (ddl_audit_handle && ddl_logging_enabled)
311  {
312  ddl_audit_handle->loaddb_file_type = file_type;
313  }
314 }
315 
316 void
318 {
319  if (ddl_audit_handle && ddl_logging_enabled)
320  {
321  ddl_audit_handle->csql_input_type = input_type;
322  }
323 }
324 
325 void
327 {
328  if (ddl_audit_handle && load_filename && ddl_logging_enabled)
329  {
330  strncpy (ddl_audit_handle->load_filename, load_filename, PATH_MAX);
331  }
332 }
333 
334 void
335 logddl_set_file_line (int file_line)
336 {
337  if (ddl_audit_handle && ddl_logging_enabled)
338  {
339  ddl_audit_handle->file_line_number = file_line;
340  }
341 }
342 
343 void
345 {
346  if (ddl_audit_handle == NULL || msg == NULL || ddl_logging_enabled == false)
347  {
348  return;
349  }
350 
351  if (ddl_audit_handle->err_msg != NULL)
352  {
353  FREE_MEM (ddl_audit_handle->err_msg);
354  }
355 
356  ALLOC_COPY (ddl_audit_handle->err_msg, msg);
357  logddl_remove_char (ddl_audit_handle->err_msg, '\n');
358 }
359 
360 void
362 {
363  if (ddl_audit_handle && ddl_logging_enabled)
364  {
365  ddl_audit_handle->err_code = err_code;
366  }
367 }
368 
369 void
370 logddl_set_start_time (struct timeval *time_val)
371 {
372  if (ddl_audit_handle == NULL || ddl_logging_enabled == false)
373  {
374  return;
375  }
376 
377  if (time_val == NULL)
378  {
379  struct timeval time;
380  gettimeofday (&time, NULL);
381  memcpy (&ddl_audit_handle->qry_exec_begin_time, &time, sizeof (struct timeval));
382  }
383  else
384  {
385  memcpy (&ddl_audit_handle->qry_exec_begin_time, time_val, sizeof (struct timeval));
386  }
387 
388  logddl_get_time_string (ddl_audit_handle->str_qry_exec_begin_time, time_val);
389 }
390 
391 void
392 logddl_set_msg (const char *fmt, ...)
393 {
394  va_list args;
395  if (ddl_audit_handle && ddl_logging_enabled)
396  {
397  va_start (args, fmt);
398  vsnprintf (ddl_audit_handle->msg, DDL_LOG_MSG, fmt, args);
399  va_end (args);
400  }
401 }
402 
403 void
404 logddl_set_execute_type (char exe_type)
405 {
406  if (ddl_audit_handle && ddl_logging_enabled)
407  {
408  ddl_audit_handle->execute_type = exe_type;
409  }
410 }
411 
412 void
414 {
415  if (ddl_audit_handle && ddl_logging_enabled)
416  {
417  ddl_audit_handle->commit_count = count;
418  }
419 }
420 
421 void
423 {
424  if (ddl_audit_handle && ddl_logging_enabled)
425  {
426  ddl_audit_handle->auto_commit_mode = mode;
427  }
428 }
429 
430 void
432 {
433  if (ddl_audit_handle && ddl_logging_enabled)
434  {
435  ddl_audit_handle->jsp_mode = mode;
436  }
437 }
438 
439 bool
441 {
442  bool jsp_mode = false;
443  if (ddl_audit_handle)
444  {
445  jsp_mode = ddl_audit_handle->jsp_mode;
446  }
447  return jsp_mode;
448 }
449 
450 static void
451 logddl_set_elapsed_time (long sec, long msec)
452 {
453  if (ddl_audit_handle && ddl_logging_enabled)
454  {
455  snprintf (ddl_audit_handle->elapsed_time, 20, "elapsed time %ld.%03ld", sec, msec);
456  }
457 }
458 
459 static int
460 logddl_file_copy (char *src_file, char *dest_file)
461 {
462  char buf[FILE_BUFFER_SIZE] = { 0 };
463  size_t size;
464  int retval = 0;
465 
466  if (src_file == NULL || dest_file == NULL)
467  {
468  return -1;
469  }
470 
471  if (access (dest_file, F_OK) == 0)
472  {
473  return -1;
474  }
475 
476  FILE *fsource = fopen (src_file, "r");
477  if (fsource == NULL)
478  {
479  return -1;
480  }
481 
482  FILE *fdest = fopen (dest_file, "w");
483  if (fdest == NULL)
484  {
485  if (fsource != NULL)
486  {
487  fclose (fsource);
488  }
489  return -1;
490  }
491 
492  while (retval == 0)
493  {
494  size = fread (buf, 1, FILE_BUFFER_SIZE, fsource);
495 
496  if (size < 1 || size > FILE_BUFFER_SIZE)
497  {
498  if (feof (fsource))
499  {
500  break;
501  }
502  else
503  {
504  retval = ferror (fsource);
505  }
506  }
507  else
508  {
509  if (fwrite (buf, sizeof (char), size, fdest) != size)
510  {
511  retval = ferror (fdest);
512  break;
513  }
514  }
515  }
516 
517  if (fsource != NULL)
518  {
519  fclose (fsource);
520  }
521 
522  if (fdest != NULL)
523  {
524  fclose (fdest);
525  }
526 
527  return retval;
528 }
529 
530 static int
531 logddl_make_copy_filename (T_APP_NAME app_name, const char *file_full_path, char *copy_filename, size_t buf_size)
532 {
533  const char *env_root = NULL;
534  char time[TIME_STRING_SIZE] = { 0 };
535  const char *name_tmp = NULL;
536  int retval = 0;
537 
538  if (ddl_audit_handle == NULL || file_full_path == NULL || copy_filename == NULL || buf_size < 0)
539  {
540  return -1;
541  }
542 
543  env_root = envvar_root ();
545 
546  name_tmp = strrchr (file_full_path, PATH_SEPARATOR);
547 
548  if (name_tmp == NULL)
549  {
550  name_tmp = file_full_path;
551  }
552  else
553  {
554  name_tmp++;
555  }
556 
557  retval = snprintf (copy_filename, buf_size, "%s_%s_%d", name_tmp, time, getpid ());
558  if (retval < 0)
559  {
560  assert (false);
561  copy_filename[0] = '\0';
562  return retval;
563  }
564 
565  return retval;
566 }
567 
568 static int
570 {
571  const char *env_root = NULL;
572  int retval = 0;
573 
574  if (ddl_audit_handle == NULL || copy_filename == NULL || copy_fullpath == NULL || buf_size < 0)
575  {
576  return -1;
577  }
578 
579  env_root = envvar_root ();
580 
581  if (app_name == APP_NAME_CSQL)
582  {
583  retval = snprintf (copy_fullpath, buf_size, "%s/%s/%s", env_root, DDL_LOG_CSQL_FILE_PATH, copy_filename);
584  }
585  else if (app_name == APP_NAME_LOADDB)
586  {
587  retval = snprintf (copy_fullpath, buf_size, "%s/%s/%s", env_root, DDL_LOG_LOADDB_FILE_PATH, copy_filename);
588  }
589  else
590  {
591  retval = -1;
592  }
593 
594  if (retval < 0)
595  {
596  assert (false);
597  copy_fullpath[0] = '\0';
598  return retval;
599  }
600  retval = logddl_create_dir (copy_fullpath);
601  return retval;
602 }
603 
604 static int
605 logddl_make_filename (char *filename_buf, size_t buf_size, T_APP_NAME app_name)
606 {
607  const char *env_root = NULL;
608  int retval = 0;
609 
610  assert (filename_buf != NULL);
611 
612  env_root = envvar_root ();
613 
614  if (app_name == APP_NAME_CAS)
615  {
616  retval =
617  snprintf (filename_buf, buf_size, "%s/%s/%s_%d_ddl.log", env_root, DDL_LOG_PATH, ddl_audit_handle->br_name,
618  (ddl_audit_handle->br_index + 1));
619  }
620  else if (app_name == APP_NAME_CSQL || app_name == APP_NAME_LOADDB)
621  {
622  retval =
623  snprintf (filename_buf, buf_size, "%s/%s/%s_%s_ddl.log", env_root, DDL_LOG_PATH,
624  logddl_get_app_name (app_name), ddl_audit_handle->db_name);
625  }
626  else
627  {
628  filename_buf[0] = '\0';
629  return -1;
630  }
631 
632  if (retval < 0)
633  {
634  assert (false);
635  filename_buf[0] = '\0';
636  }
637  return retval;
638 }
639 
640 static FILE *
642 {
643  FILE *fp = NULL;
644  int len;
645 
646  len = logddl_make_filename (ddl_audit_handle->log_filepath, PATH_MAX, app_name);
647 
648  if (ddl_audit_handle->log_filepath[0] == '\0' || len < 0)
649  {
650  goto file_error;
651  }
652 
653  if (logddl_create_dir (ddl_audit_handle->log_filepath) < 0)
654  {
655  goto file_error;
656  }
657 
658  /* note: in "a+" mode, output is always appended */
659  fp = logddl_fopen_and_lock (ddl_audit_handle->log_filepath, "a+");
660 
661  return fp;
662 
663 file_error:
664  return NULL;
665 }
666 
667 void
669 {
670  if (ddl_audit_handle == NULL || ddl_logging_enabled == false)
671  {
672  return;
673  }
674 
676  {
677  goto ddl_log_free;
678  }
679 
680  if (ddl_audit_handle->app_name == APP_NAME_LOADDB)
681  {
682  if (ddl_audit_handle->loaddb_file_type != LOADDB_FILE_TYPE_SCHEMA
683  && ddl_audit_handle->loaddb_file_type != LOADDB_FILE_TYPE_INDEX
684  && ddl_audit_handle->loaddb_file_type != LOADDB_FILE_TYPE_TRIGGER)
685  {
686  goto ddl_log_free;
687  }
688  }
689  else
690  {
691  if (logddl_is_ddl_type (ddl_audit_handle->stmt_type) == false)
692  {
693  goto ddl_log_free;
694  }
695  }
696  if (ddl_audit_handle->execute_type == LOGDDL_RUN_EXECUTE_FUNC)
697  {
698  logddl_write ();
699  }
700 
701 ddl_log_free:
702  logddl_free (false);
703 }
704 
705 void
707 {
708  FILE *fp = NULL;
709  char buf[DDL_LOG_BUFFER_SIZE] = { 0 };
710  int len = 0;
711 
712  if (ddl_audit_handle == NULL || ddl_logging_enabled == false)
713  {
714  return;
715  }
716 
717  if (ddl_audit_handle->app_name == APP_NAME_LOADDB)
718  {
719  if (ddl_audit_handle->loaddb_file_type != LOADDB_FILE_TYPE_SCHEMA
720  && ddl_audit_handle->loaddb_file_type != LOADDB_FILE_TYPE_INDEX
721  && ddl_audit_handle->loaddb_file_type != LOADDB_FILE_TYPE_TRIGGER)
722  {
723  return;
724  }
725  }
726  else
727  {
728  if (logddl_is_ddl_type (ddl_audit_handle->stmt_type) == false)
729  {
730  return;
731  }
732  }
733 
734  fp = logddl_open (ddl_audit_handle->app_name);
735 
736  if (fp != NULL)
737  {
738  if (ddl_audit_handle->app_name == APP_NAME_LOADDB)
739  {
740  if (strlen (ddl_audit_handle->copy_filename) == 0)
741  {
743  (ddl_audit_handle->app_name, ddl_audit_handle->load_filename, ddl_audit_handle->copy_filename,
744  PATH_MAX) < 0)
745  {
746  goto write_error;
747  }
748  }
749 
750  if (strlen (ddl_audit_handle->copy_fullpath) == 0)
751  {
753  (APP_NAME_LOADDB, ddl_audit_handle->copy_filename, ddl_audit_handle->copy_fullpath, PATH_MAX) < 0)
754  {
755  goto write_error;
756  }
757  }
758  logddl_file_copy (ddl_audit_handle->load_filename, ddl_audit_handle->copy_fullpath);
759  }
760 
761  if (ddl_audit_handle->app_name == APP_NAME_CSQL && ddl_audit_handle->csql_input_type == CSQL_INPUT_TYPE_FILE)
762  {
763  if (strlen (ddl_audit_handle->copy_filename) == 0)
764  {
766  (ddl_audit_handle->app_name, ddl_audit_handle->load_filename, ddl_audit_handle->copy_filename,
767  PATH_MAX) < 0)
768  {
769  goto write_error;
770  }
771  }
772 
773  if (strlen (ddl_audit_handle->copy_fullpath) == 0)
774  {
776  (APP_NAME_CSQL, ddl_audit_handle->copy_filename, ddl_audit_handle->copy_fullpath, PATH_MAX) < 0)
777  {
778  goto write_error;
779  }
780  }
781  logddl_file_copy (ddl_audit_handle->load_filename, ddl_audit_handle->copy_fullpath);
782  }
783 
784  len = logddl_create_log_msg (buf);
785  if (len < 0 || fwrite (buf, sizeof (char), len, fp) != (size_t) len)
786  {
787  goto write_error;
788  }
789 
790  if ((UINT64) ftell (fp) > prm_get_bigint_value (PRM_ID_DDL_AUDIT_LOG_SIZE))
791  {
792  fclose (fp);
793  logddl_backup (ddl_audit_handle->log_filepath);
794  fp = NULL;
795  }
796  }
797 
798 write_error:
799  if (fp != NULL)
800  {
801  fclose (fp);
802  fp = NULL;
803  }
804 }
805 
806 void
807 logddl_write_tran_str (const char *fmt, ...)
808 {
809  FILE *fp = NULL;
810  char msg[DDL_LOG_BUFFER_SIZE] = { 0 };
811  int len = 0;
812  struct timeval time_val;
813  va_list args;
814 
815  if (ddl_audit_handle == NULL || ddl_logging_enabled == false)
816  {
817  return;
818  }
819 
820  if (is_executed_ddl_for_trans == false || ddl_audit_handle->auto_commit_mode == true)
821  {
822  goto write_error;
823  }
824 
825  fp = logddl_open (ddl_audit_handle->app_name);
826 
827  if (fp != NULL)
828  {
829  va_start (args, fmt);
830  vsnprintf (ddl_audit_handle->msg, DDL_LOG_MSG, fmt, args);
831  va_end (args);
832 
833  gettimeofday (&time_val, NULL);
834  logddl_get_time_string (ddl_audit_handle->str_qry_exec_begin_time, &time_val);
835 
836  if (ddl_audit_handle->app_name == APP_NAME_CSQL && ddl_audit_handle->csql_input_type == CSQL_INPUT_TYPE_FILE)
837  {
838  if (strlen (ddl_audit_handle->copy_filename) == 0)
839  {
841  (ddl_audit_handle->app_name, ddl_audit_handle->load_filename, ddl_audit_handle->copy_filename,
842  PATH_MAX) < 0)
843  {
844  goto write_error;
845  }
846  }
847 
848  if (strlen (ddl_audit_handle->copy_fullpath) == 0)
849  {
851  (APP_NAME_CSQL, ddl_audit_handle->copy_filename, ddl_audit_handle->copy_fullpath, PATH_MAX) < 0)
852  {
853  goto write_error;
854  }
855  }
856  logddl_file_copy (ddl_audit_handle->load_filename, ddl_audit_handle->copy_fullpath);
857  }
858 
859  if (ddl_audit_handle->app_name == APP_NAME_CAS)
860  {
861  len = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %s|%s|%s\n",
862  ddl_audit_handle->str_qry_exec_begin_time,
863  ddl_audit_handle->ip_addr, ddl_audit_handle->user_name, ddl_audit_handle->msg);
864  }
865  else if (ddl_audit_handle->app_name == APP_NAME_CSQL)
866  {
867  if (ddl_audit_handle->csql_input_type == CSQL_INPUT_TYPE_FILE)
868  {
869  len = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %d|%s|%s|%s\n",
870  ddl_audit_handle->str_qry_exec_begin_time,
871  ddl_audit_handle->pid, ddl_audit_handle->user_name, ddl_audit_handle->msg,
872  ddl_audit_handle->copy_filename);
873  }
874  else
875  {
876  len = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %d|%s|%s\n",
877  ddl_audit_handle->str_qry_exec_begin_time,
878  ddl_audit_handle->pid, ddl_audit_handle->user_name, ddl_audit_handle->msg);
879  }
880  }
881  else
882  {
883  goto write_error;
884  }
885 
886  if (len >= DDL_LOG_BUFFER_SIZE)
887  {
888  msg[DDL_LOG_BUFFER_SIZE - 2] = '\n';
889  len = DDL_LOG_BUFFER_SIZE;
890  }
891 
892  if (len < 0 || fwrite (msg, sizeof (char), len, fp) != len)
893  {
894  goto write_error;
895  }
896 
897  if ((UINT64) ftell (fp) > prm_get_bigint_value (PRM_ID_DDL_AUDIT_LOG_SIZE))
898  {
899  fclose (fp);
900  logddl_backup (ddl_audit_handle->log_filepath);
901  fp = NULL;
902  }
903  }
904 
905 write_error:
906  if (fp != NULL)
907  {
908  fclose (fp);
909  fp = NULL;
910  }
911 
913  logddl_free (false);
914 }
915 
916 void
918 {
919  FILE *fp = NULL;
920  char buf[DDL_LOG_BUFFER_SIZE] = { 0 };
921  int len = 0;
922  struct timeval time_val;
923  va_list args;
924  if (ddl_audit_handle == NULL || ddl_logging_enabled == false)
925  {
926  return;
927  }
928 
929  if (ddl_audit_handle->app_name != APP_NAME_CSQL && ddl_audit_handle->csql_input_type != CSQL_INPUT_TYPE_FILE)
930  {
931  return;
932  }
933 
934  if (is_executed_ddl_for_csql == false)
935  {
936  return;
937  }
938 
939  fp = logddl_open (ddl_audit_handle->app_name);
940 
941  if (fp != NULL)
942  {
943  va_start (args, fmt);
944  vsnprintf (ddl_audit_handle->msg, DDL_LOG_MSG, fmt, args);
945  va_end (args);
946 
947  gettimeofday (&time_val, NULL);
948  logddl_get_time_string (ddl_audit_handle->str_qry_exec_begin_time, &time_val);
949 
950  if (strlen (ddl_audit_handle->copy_filename) == 0)
951  {
953  (ddl_audit_handle->app_name, ddl_audit_handle->load_filename, ddl_audit_handle->copy_filename,
954  PATH_MAX) < 0)
955  {
956  goto write_error;
957  }
958  }
959 
960  if (strlen (ddl_audit_handle->copy_fullpath) == 0)
961  {
963  (APP_NAME_CSQL, ddl_audit_handle->copy_filename, ddl_audit_handle->copy_fullpath, PATH_MAX) < 0)
964  {
965  goto write_error;
966  }
967  }
968  logddl_file_copy (ddl_audit_handle->load_filename, ddl_audit_handle->copy_fullpath);
969 
970  len = logddl_create_log_msg (buf);
971  if (len < 0 || fwrite (buf, sizeof (char), len, fp) != (size_t) len)
972  {
973  goto write_error;
974  }
975 
976  if ((UINT64) ftell (fp) > prm_get_bigint_value (PRM_ID_DDL_AUDIT_LOG_SIZE))
977  {
978  fclose (fp);
979  logddl_backup (ddl_audit_handle->log_filepath);
980  fp = NULL;
981  }
982  }
983 
984 write_error:
985  if (fp != NULL)
986  {
987  fclose (fp);
988  fp = NULL;
989  }
990 
991  logddl_free (true);
992 }
993 
994 extern void
996 {
997  ddl_logging_enabled = enable;
998 }
999 
1000 static int
1002 {
1003  int retval = 0;
1004  char result[20] = { 0 };
1005  struct timeval exec_end, log_time;
1006  long elapsed_sec = 0;
1007  long elapsed_msec = 0;
1008 
1009  if (ddl_audit_handle == NULL || ddl_logging_enabled == false)
1010  {
1011  return -1;
1012  }
1013 
1014  gettimeofday (&exec_end, NULL);
1015  logddl_timeval_diff (&ddl_audit_handle->qry_exec_begin_time, &exec_end, &elapsed_sec, &elapsed_msec);
1016  logddl_set_elapsed_time (elapsed_sec, elapsed_msec);
1017 
1018  if (strlen (ddl_audit_handle->str_qry_exec_begin_time) == 0)
1019  {
1020  gettimeofday (&log_time, NULL);
1021  logddl_get_time_string (ddl_audit_handle->str_qry_exec_begin_time, &log_time);
1022  }
1023 
1024  if (ddl_audit_handle->app_name == APP_NAME_LOADDB)
1025  {
1026  if (ddl_audit_handle->err_code < 0)
1027  {
1028  snprintf (result, sizeof (result), "ERROR:%d", ddl_audit_handle->err_code);
1029  snprintf (ddl_audit_handle->msg, DDL_LOG_MSG, "Commited count %8d, Error line %d",
1030  ddl_audit_handle->commit_count, ddl_audit_handle->file_line_number);
1031  }
1032  else
1033  {
1034  strcpy (result, "OK");
1035  }
1036 
1037  retval = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %d|%s|%s|%s|%s\n",
1038  ddl_audit_handle->str_qry_exec_begin_time,
1039  ddl_audit_handle->pid, ddl_audit_handle->user_name, result, ddl_audit_handle->msg,
1040  ddl_audit_handle->copy_filename);
1041  }
1042  else if (ddl_audit_handle->app_name == APP_NAME_CSQL)
1043  {
1044  if (ddl_audit_handle->csql_input_type == CSQL_INPUT_TYPE_FILE)
1045  {
1046  if (ddl_audit_handle->err_code < 0)
1047  {
1048  snprintf (result, sizeof (result), "ERROR:%d", ddl_audit_handle->err_code);
1049  snprintf (ddl_audit_handle->msg, DDL_LOG_MSG, "Error line %d", ddl_audit_handle->file_line_number);
1050  ddl_audit_handle->elapsed_time[0] = '\0';
1051 
1052  retval = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %d|%s|%s|%s|%s|%s\n",
1053  ddl_audit_handle->str_qry_exec_begin_time,
1054  ddl_audit_handle->pid,
1055  ddl_audit_handle->user_name,
1056  (ddl_audit_handle->auto_commit_mode) ? "autocommit mode on" : "autocommit mode off",
1057  result, ddl_audit_handle->msg, ddl_audit_handle->copy_filename);
1058  }
1059  else
1060  {
1061  strcpy (result, "OK");
1062  retval = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %d|%s|%s|%s|%s|%s\n",
1063  ddl_audit_handle->str_qry_exec_begin_time,
1064  ddl_audit_handle->pid,
1065  ddl_audit_handle->user_name,
1066  (ddl_audit_handle->auto_commit_mode) ? "autocommit mode on" : "autocommit mode off",
1067  result, ddl_audit_handle->msg, ddl_audit_handle->copy_filename);
1068  }
1069  }
1070  else
1071  {
1072  if (ddl_audit_handle->err_code < 0)
1073  {
1074  snprintf (result, sizeof (result), "ERROR:%d", ddl_audit_handle->err_code);
1075  ddl_audit_handle->elapsed_time[0] = '\0';
1076  }
1077  else
1078  {
1079  strcpy (result, "OK");
1080  }
1081 
1082  retval = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %d|%s|%s|%s|%s|%s\n",
1083  ddl_audit_handle->str_qry_exec_begin_time,
1084  ddl_audit_handle->pid,
1085  ddl_audit_handle->user_name,
1086  result, ddl_audit_handle->elapsed_time, ddl_audit_handle->msg, ddl_audit_handle->sql_text);
1087 
1088  }
1089  }
1090  else
1091  {
1092  if (ddl_audit_handle->err_code < 0)
1093  {
1094  snprintf (result, sizeof (result), "ERROR:%d", ddl_audit_handle->err_code);
1095  }
1096  else
1097  {
1098  strcpy (result, "OK");
1099  }
1100 
1101  if (ddl_audit_handle->execute_type == LOGDDL_RUN_EXECUTE_BATCH_FUNC)
1102  {
1103  snprintf (ddl_audit_handle->elapsed_time, sizeof (ddl_audit_handle->elapsed_time), "elapsed time 0.000");
1104  }
1105 
1106  retval = snprintf (msg, DDL_LOG_BUFFER_SIZE, "%s %s|%s|%s|%s|%s|%s\n",
1107  ddl_audit_handle->str_qry_exec_begin_time,
1108  ddl_audit_handle->ip_addr,
1109  ddl_audit_handle->user_name,
1110  result, ddl_audit_handle->elapsed_time, ddl_audit_handle->msg, ddl_audit_handle->sql_text);
1111 
1112  }
1113 
1114  if (retval >= DDL_LOG_BUFFER_SIZE)
1115  {
1116  msg[DDL_LOG_BUFFER_SIZE - 2] = '\n';
1117  retval = DDL_LOG_BUFFER_SIZE;
1118  }
1119  return retval;
1120 }
1121 
1122 static void
1123 logddl_backup (const char *path)
1124 {
1125  char backup_file[PATH_MAX] = { 0 };
1126 #if !defined(WINDOWS)
1127  sigset_t new_mask, old_mask;
1128 #endif /* !WINDOWS */
1129 
1130  snprintf (backup_file, sizeof (backup_file), "%s.bak", path);
1131 
1132 #if !defined(WINDOWS)
1133  sigfillset (&new_mask);
1134  sigdelset (&new_mask, SIGINT);
1135  sigdelset (&new_mask, SIGQUIT);
1136  sigdelset (&new_mask, SIGTERM);
1137  sigdelset (&new_mask, SIGHUP);
1138  sigdelset (&new_mask, SIGABRT);
1139  if (sigprocmask (SIG_SETMASK, &new_mask, &old_mask) == 0)
1140  {
1141  unlink (backup_file);
1142  rename (path, backup_file);
1143  sigprocmask (SIG_SETMASK, &old_mask, NULL);
1144  }
1145 #else /* !WINDOWS */
1146  unlink (backup_file);
1147  rename (path, backup_file);
1148 #endif
1149 }
1150 
1151 static FILE *
1152 logddl_fopen_and_lock (const char *path, const char *mode)
1153 {
1154 #define MAX_RETRY_COUNT 100
1155  int retry_count = 0;
1156  FILE *ddl_log_fp = NULL;
1157 
1158 retry:
1159  ddl_log_fp = fopen (path, mode);
1160  if (ddl_log_fp != NULL)
1161  {
1162  if (lockf (fileno (ddl_log_fp), F_TLOCK, 0) < 0)
1163  {
1164  fclose (ddl_log_fp);
1165  if (retry_count < MAX_RETRY_COUNT)
1166  {
1167  SLEEP_MILISEC (0, 10);
1168  retry_count++;
1169  goto retry;
1170  }
1171  ddl_log_fp = NULL;
1172  }
1173  }
1174 
1175  return ddl_log_fp;
1176 }
1177 
1178 #if defined(WINDOWS)
1179 static void
1180 unix_style_path (char *path)
1181 {
1182  char *p = NULL;
1183  for (p = path; *p; p++)
1184  {
1185  if (*p == '\\')
1186  *p = '/';
1187  }
1188 }
1189 #endif /* WINDOWS */
1190 
1191 static int
1192 logddl_create_dir (const char *new_dir)
1193 {
1194  char *p, path[PATH_MAX] = { 0 };
1195 
1196  if (new_dir == NULL)
1197  return -1;
1198 
1199  strcpy (path, new_dir);
1200  trim (path);
1201 
1202 
1203 #if defined(WINDOWS)
1204  unix_style_path (path);
1205 #endif /* WINDOWS */
1206 
1207  p = path;
1208 #if defined(WINDOWS)
1209  if (path[0] == '/')
1210  p = path + 1;
1211  else if (strlen (path) > 3 && path[2] == '/')
1212  p = path + 3;
1213 #else /* WINDOWS */
1214  if (path[0] == '/')
1215  {
1216  p = path + 1;
1217  }
1218 #endif /* WINDOWS */
1219 
1220  while (p != NULL)
1221  {
1222  p = strchr (p, '/');
1223  if (p == NULL)
1224  return 0;
1225 
1226  if (p != NULL)
1227  *p = '\0';
1228 
1229  if (access (path, F_OK) < 0)
1230  {
1231  if (mkdir (path, 0777) < 0)
1232  {
1233  return -1;
1234  }
1235  }
1236  if (p != NULL)
1237  {
1238  *p = '/';
1239  p++;
1240  }
1241  }
1242  return 0;
1243 }
1244 
1245 static int
1246 logddl_get_current_date_time_string (char *buf, size_t size)
1247 {
1248  struct tm at_tm;
1249  int len = 0;
1250  time_t t = time (NULL);
1251 
1252  localtime_r (&t, &at_tm);
1253  at_tm.tm_year += 1900;
1254  at_tm.tm_mon += 1;
1255  len =
1256  snprintf (buf, size, "%04d%02d%02d_%02d%02d%02d", at_tm.tm_year, at_tm.tm_mon, at_tm.tm_mday, at_tm.tm_hour,
1257  at_tm.tm_min, at_tm.tm_sec);
1258 
1259  return len;
1260 }
1261 
1262 static int
1263 logddl_get_time_string (char *buf, struct timeval *time_val)
1264 {
1265  struct tm tm, *tm_p;
1266  time_t sec;
1267  int millisec;
1268 
1269  if (buf == NULL)
1270  {
1271  return 0;
1272  }
1273 
1274  if (time_val == NULL)
1275  {
1276  /* current time */
1277  util_get_second_and_ms_since_epoch (&sec, &millisec);
1278  }
1279  else
1280  {
1281  sec = time_val->tv_sec;
1282  millisec = time_val->tv_usec / 1000;
1283  }
1284 
1285  tm_p = localtime_r (&sec, &tm);
1286  tm.tm_mon++;
1287 
1288  buf[0] = ((tm.tm_year % 100) / 10) + '0';
1289  buf[1] = (tm.tm_year % 10) + '0';
1290  buf[2] = '-';
1291  buf[3] = (tm.tm_mon / 10) + '0';
1292  buf[4] = (tm.tm_mon % 10) + '0';
1293  buf[5] = '-';
1294  buf[6] = (tm.tm_mday / 10) + '0';
1295  buf[7] = (tm.tm_mday % 10) + '0';
1296  buf[8] = ' ';
1297  buf[9] = (tm.tm_hour / 10) + '0';
1298  buf[10] = (tm.tm_hour % 10) + '0';
1299  buf[11] = ':';
1300  buf[12] = (tm.tm_min / 10) + '0';
1301  buf[13] = (tm.tm_min % 10) + '0';
1302  buf[14] = ':';
1303  buf[15] = (tm.tm_sec / 10) + '0';
1304  buf[16] = (tm.tm_sec % 10) + '0';
1305  buf[17] = '.';
1306  buf[20] = (millisec % 10) + '0';
1307  millisec /= 10;
1308  buf[19] = (millisec % 10) + '0';
1309  millisec /= 10;
1310  buf[18] = (millisec % 10) + '0';
1311  buf[21] = '\0';
1312 
1313  return 21;
1314 }
1315 
1316 static void
1317 logddl_remove_char (char *string, char ch)
1318 {
1319  for (; *string != '\0'; string++)
1320  {
1321  if (*string == ch)
1322  {
1323  strcpy (string, string + 1);
1324  string--;
1325  }
1326  }
1327 }
1328 
1329 bool
1330 logddl_is_ddl_type (int node_type)
1331 {
1332  switch (node_type)
1333  {
1334  case PT_ALTER:
1335  case PT_ALTER_INDEX:
1336  case PT_ALTER_SERIAL:
1338  case PT_ALTER_TRIGGER:
1339  case PT_ALTER_USER:
1340  case PT_CREATE_ENTITY:
1341  case PT_CREATE_INDEX:
1342  case PT_CREATE_SERIAL:
1344  case PT_CREATE_TRIGGER:
1345  case PT_CREATE_USER:
1346  case PT_DROP:
1347  case PT_DROP_INDEX:
1348  case PT_DROP_SERIAL:
1350  case PT_DROP_TRIGGER:
1351  case PT_DROP_USER:
1352  case PT_GRANT:
1353  case PT_RENAME:
1354  case PT_REVOKE:
1355  case PT_REMOVE_TRIGGER:
1356  case PT_RENAME_TRIGGER:
1357  case PT_UPDATE_STATS:
1358  case PT_TRUNCATE:
1359  return true;
1360  default:
1361  break;
1362  }
1363 
1364  return false;
1365 }
1366 
1367 static void
1368 logddl_timeval_diff (struct timeval *start, struct timeval *end, long *res_sec, long *res_msec)
1369 {
1370  long sec, msec;
1371 
1372  assert (start != NULL && end != NULL && res_sec != NULL && res_msec != NULL);
1373 
1374  sec = end->tv_sec - start->tv_sec;
1375  msec = (end->tv_usec / 1000) - (start->tv_usec / 1000);
1376  if (msec < 0)
1377  {
1378  msec += 1000;
1379  sec--;
1380  }
1381  *res_sec = sec;
1382  *res_msec = msec;
1383 }
1384 
1385 static const char *
1387 {
1388  switch (app_name)
1389  {
1390  case APP_NAME_CAS:
1391  return "cas";
1392  case APP_NAME_CSQL:
1393  return "csql";
1394  case APP_NAME_LOADDB:
1395  return "loaddb";
1396  default:
1397  return "";
1398  }
1399 }
static int logddl_make_copy_dir(T_APP_NAME app_name, char *copy_filename, char *copy_fullpath, size_t buf_size)
Definition: ddl_log.c:569
#define SLEEP_MILISEC(sec, msec)
Definition: util_func.h:40
const char * envvar_root(void)
void logddl_set_msg(const char *fmt,...)
Definition: ddl_log.c:392
static int logddl_create_dir(const char *new_dir)
Definition: ddl_log.c:1192
char * trim(char *str)
Definition: porting.c:2260
char br_name[BROKER_NAME_LEN]
Definition: ddl_log.c:68
static FILE * logddl_open(T_APP_NAME app_name)
Definition: ddl_log.c:641
void logddl_write_end_for_csql_fileinput(const char *fmt,...)
Definition: ddl_log.c:917
static FILE * logddl_fopen_and_lock(const char *path, const char *mode)
Definition: ddl_log.c:1152
void logddl_set_db_name(const char *db_name)
Definition: ddl_log.c:205
#define TIME_STRING_SIZE
Definition: ddl_log.c:58
char db_name[DB_MAX_IDENTIFIER_LENGTH]
Definition: ddl_log.c:65
static int logddl_file_copy(char *src_file, char *dest_file)
Definition: ddl_log.c:460
T_APP_NAME app_name
Definition: ddl_log.c:67
bool logddl_is_ddl_type(int node_type)
Definition: ddl_log.c:1330
bool auto_commit_mode
Definition: ddl_log.c:89
#define DDL_LOG_PATH
Definition: ddl_log.c:54
static int logddl_make_filename(char *filename_buf, size_t buf_size, T_APP_NAME app_name)
Definition: ddl_log.c:605
char * err_msg
Definition: ddl_log.c:79
static int logddl_get_time_string(char *buf, struct timeval *time_val)
Definition: ddl_log.c:1263
char load_filename[PATH_MAX]
Definition: ddl_log.c:81
void logddl_set_jsp_mode(bool mode)
Definition: ddl_log.c:431
T_LOADDB_FILE_TYPE
Definition: ddl_log.h:40
void logddl_set_logging_enabled(bool enable)
Definition: ddl_log.c:995
void logddl_set_sql_text(char *sql_text, int len)
Definition: ddl_log.c:268
#define DDL_LOG_MSG
Definition: ddl_log.c:53
void logddl_write_end()
Definition: ddl_log.c:668
void logddl_set_execute_type(char exe_type)
Definition: ddl_log.c:404
UINT64 prm_get_bigint_value(PARAM_ID prm_id)
static void logddl_set_elapsed_time(long sec, long msec)
Definition: ddl_log.c:451
void logddl_set_err_msg(char *msg)
Definition: ddl_log.c:344
char user_name[DB_MAX_USER_LENGTH]
Definition: ddl_log.c:66
char copy_fullpath[PATH_MAX]
Definition: ddl_log.c:83
void logddl_set_csql_input_type(T_CSQL_INPUT_TYPE input_type)
Definition: ddl_log.c:317
static int logddl_create_log_msg(char *msg)
Definition: ddl_log.c:1001
#define assert(x)
T_LOADDB_FILE_TYPE loaddb_file_type
Definition: ddl_log.c:85
static int logddl_get_current_date_time_string(char *buf, size_t size)
Definition: ddl_log.c:1246
T_CSQL_INPUT_TYPE csql_input_type
Definition: ddl_log.c:86
static bool is_executed_ddl_for_csql
Definition: ddl_log.c:116
void logddl_set_commit_count(int count)
Definition: ddl_log.c:413
#define DB_MAX_IDENTIFIER_LENGTH
Definition: dbtype_def.h:495
static bool ddl_logging_enabled
Definition: ddl_log.c:93
static enum scanner_mode mode
static void logddl_remove_char(char *string, char ch)
Definition: ddl_log.c:1317
void logddl_set_load_filename(const char *load_filename)
Definition: ddl_log.c:326
void logddl_destroy()
Definition: ddl_log.c:185
#define NULL
Definition: freelistheap.h:34
#define BROKER_NAME_LEN
Definition: broker_config.h:87
#define LOGDDL_RUN_EXECUTE_FUNC
Definition: ddl_log.h:29
#define DDL_LOG_BUFFER_SIZE
Definition: ddl_log.h:38
void logddl_set_br_index(const int index)
Definition: ddl_log.c:259
#define LOGDDL_RUN_EXECUTE_BATCH_FUNC
Definition: ddl_log.h:30
#define MALLOC(SIZE)
Definition: cas_common.h:53
static const char * logddl_get_app_name(T_APP_NAME app_name)
Definition: ddl_log.c:1386
#define FREE_MEM(PTR)
Definition: cas_common.h:58
int file_line_number
Definition: ddl_log.c:77
char * sql_text
Definition: ddl_log.c:72
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
void logddl_write()
Definition: ddl_log.c:706
void util_get_second_and_ms_since_epoch(time_t *secs, int *msec)
Definition: util_func.c:829
struct timeval qry_exec_begin_time
Definition: ddl_log.c:75
char log_filepath[PATH_MAX]
Definition: ddl_log.c:87
void logddl_init()
Definition: ddl_log.c:119
void logddl_set_br_name(const char *br_name)
Definition: ddl_log.c:250
static void logddl_backup(const char *path)
Definition: ddl_log.c:1123
static int logddl_make_copy_filename(T_APP_NAME app_name, const char *file_full_path, char *copy_filename, size_t buf_size)
Definition: ddl_log.c:531
void logddl_set_pid(const int pid)
Definition: ddl_log.c:241
#define MAX_RETRY_COUNT
char elapsed_time[DDL_TIME_LEN]
Definition: ddl_log.c:76
void logddl_set_loaddb_file_type(T_LOADDB_FILE_TYPE file_type)
Definition: ddl_log.c:308
#define strlen(s1)
Definition: intl_support.c:43
static T_DDL_AUDIT_HANDLE * ddl_audit_handle
Definition: ddl_log.c:92
T_CSQL_INPUT_TYPE
Definition: ddl_log.h:50
void logddl_set_app_name(T_APP_NAME app_name)
Definition: ddl_log.c:196
void logddl_set_commit_mode(bool mode)
Definition: ddl_log.c:422
bool prm_get_bool_value(PARAM_ID prm_id)
#define ALLOC_COPY(PTR, STR)
Definition: cas_common.h:66
#define DDL_TIME_LEN
Definition: ddl_log.c:59
static void logddl_timeval_diff(struct timeval *start, struct timeval *end, long *res_sec, long *res_msec)
Definition: ddl_log.c:1368
char msg[DDL_LOG_MSG]
Definition: ddl_log.c:80
bool logddl_get_jsp_mode()
Definition: ddl_log.c:440
#define DDL_LOG_LOADDB_FILE_PATH
Definition: ddl_log.c:55
void logddl_set_user_name(const char *user_name)
Definition: ddl_log.c:223
T_APP_NAME
Definition: ddl_log.h:58
#define FILE_BUFFER_SIZE
Definition: ddl_log.c:57
void logddl_write_tran_str(const char *fmt,...)
Definition: ddl_log.c:807
void logddl_free(bool all_free)
Definition: ddl_log.c:143
void logddl_set_err_code(int err_code)
Definition: ddl_log.c:361
char str_qry_exec_begin_time[DDL_TIME_LEN]
Definition: ddl_log.c:74
#define DB_MAX_USER_LENGTH
Definition: dbtype_def.h:498
void logddl_set_ip(const char *ip_addr)
Definition: ddl_log.c:232
char ip_addr[16]
Definition: ddl_log.c:70
void logddl_set_stmt_type(int stmt_type)
Definition: ddl_log.c:291
#define PATH_SEPARATOR
Definition: porting.h:347
#define DDL_LOG_CSQL_FILE_PATH
Definition: ddl_log.c:56
const char ** p
Definition: dynamic_load.c:945
void logddl_set_file_line(int file_line)
Definition: ddl_log.c:335
static bool is_executed_ddl_for_trans
Definition: ddl_log.c:115
char copy_filename[PATH_MAX]
Definition: ddl_log.c:82
void logddl_set_start_time(struct timeval *time_val)
Definition: ddl_log.c:370