CUBRID Engine  latest
query_dump.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  * query_dump.c - Query processor printer
21  */
22 
23 #ident "$Id$"
24 
25 #include "config.h"
26 #include <stdio.h>
27 
28 #include "jansson.h"
29 #include "query_dump.h"
30 #include "object_primitive.h"
31 #include "system_parameter.h"
32 #include "dbtype.h"
33 #if defined (SERVER_MODE)
34 #include "thread_manager.hpp" // for thread_get_thread_entry_info
35 #endif // SERVER_MODE
36 #include "xasl.h"
37 #include "xasl_aggregate.hpp"
38 #include "xasl_predicate.hpp"
39 
40 #define foutput stdout
41 
42 enum
43 {
44  ARITH_EXP = 0,
45  AGG_EXP = 1
46 };
47 
48 #define HASH_NUMBER 128
49 
50 #define HAVE_SUBQUERY_PROC(xasl_p) \
51  ((xasl_p)->type != MERGELIST_PROC && (xasl_p)->type != UNION_PROC \
52  && (xasl_p)->type != INTERSECTION_PROC && (xasl_p)->type != DIFFERENCE_PROC)
53 
56 {
58  UINTPTR xasl_addr;
61  int reachable;
62 };
63 
64 static bool qdump_print_xasl_type (XASL_NODE * xasl);
65 static bool qdump_print_db_value_array (DB_VALUE ** array, int cnt);
66 static bool qdump_print_column (const char *title_p, int col_count, int *column_p);
72 static const char *qdump_target_type_string (TARGET_TYPE type);
73 static const char *qdump_access_method_string (ACCESS_METHOD access);
74 static bool qdump_print_access_spec (ACCESS_SPEC_TYPE * spec_list);
75 static const char *qdump_key_range_string (RANGE range);
76 static bool qdump_print_key_info (KEY_INFO * key_info);
77 static const char *qdump_range_type_string (RANGE_TYPE range_type);
78 static bool qdump_print_index (INDX_INFO * indexptr);
79 static bool qdump_print_btid (BTID id);
80 static bool qdump_print_class (CLS_SPEC_TYPE * ptr);
81 static bool qdump_print_hfid (HFID id);
82 static bool qdump_print_vfid (VFID id);
83 static bool qdump_print_list (LIST_SPEC_TYPE * ptr);
84 static bool qdump_print_showstmt (SHOWSTMT_SPEC_TYPE * ptr);
85 static bool qdump_print_outlist (const char *title, OUTPTR_LIST * outlist);
86 static bool qdump_print_list_id (QFILE_LIST_ID * idptr);
88 static bool qdump_print_domain_list (int cnt, TP_DOMAIN ** ptr);
89 static bool qdump_print_sort_list (SORT_LIST * sorting_list);
90 static bool qdump_print_attribute_id (ATTR_DESCR attr);
92 static bool qdump_print_value_list (VAL_LIST * vallist);
94 static const char *qdump_option_string (int option);
95 static bool qdump_print_db_value (DB_VALUE * value);
96 static const char *qdump_regu_type_string (REGU_DATATYPE type);
97 static bool qdump_print_regu_type (REGU_VARIABLE * value);
98 static const char *qdump_data_type_string (DB_TYPE type);
99 static bool qdump_print_value (REGU_VARIABLE * value);
100 static bool qdump_print_function_value (REGU_VARIABLE * regu);
101 static bool qdump_print_value_type_addr (REGU_VARIABLE * value);
102 static bool qdump_print_oid (OID * oidptr);
103 static bool qdump_print_predicate (PRED_EXPR * predptr);
104 static const char *qdump_relation_operator_string (int op);
105 static const char *qdump_arith_operator_string (OPERATOR_TYPE opcode);
106 static bool qdump_print_arith_expression (ARITH_TYPE * arith_p);
107 static bool qdump_print_aggregate_expression (AGGREGATE_TYPE * aggptr);
108 static bool qdump_print_arith (int type, void *ptr);
109 static bool qdump_print_term (PRED_EXPR * pred_ptr);
110 static const char *qdump_bool_operator_string (BOOL_OP bool_op);
111 static bool qdump_print_lhs_predicate (PRED_EXPR * pred_p);
112 #if defined(CUBRID_DEBUG)
113 static QDUMP_XASL_CHECK_NODE *qdump_find_check_node_for (XASL_NODE * xasl,
114  QDUMP_XASL_CHECK_NODE * chk_nodes[HASH_NUMBER]);
115 static void qdump_check_node (XASL_NODE * xasl, QDUMP_XASL_CHECK_NODE * chk_nodes[HASH_NUMBER]);
116 static int qdump_print_inconsistencies (QDUMP_XASL_CHECK_NODE * chk_nodes[HASH_NUMBER]);
117 #endif /* CUBRID_DEBUG */
118 
119 /*
120  * qdump_print_xasl_type () -
121  * return:
122  * xasl(in):
123  */
124 static bool
126 {
127  const char *type_string_p;
128 
129  switch (xasl_p->type)
130  {
131  case BUILDLIST_PROC:
132  type_string_p = "buildlist_proc";
133  break;
134  case BUILDVALUE_PROC:
135  type_string_p = "buildvalue_proc";
136  break;
137  case UNION_PROC:
138  type_string_p = "union_proc";
139  break;
140  case DIFFERENCE_PROC:
141  type_string_p = "difference_proc";
142  break;
143  case INTERSECTION_PROC:
144  type_string_p = "intersection_proc";
145  break;
146  case OBJFETCH_PROC:
147  type_string_p = "objfetch_proc";
148  break;
149  case SCAN_PROC:
150  type_string_p = "scan_proc";
151  break;
152  case MERGELIST_PROC:
153  type_string_p = "mergelist_proc";
154  break;
155  case UPDATE_PROC:
156  type_string_p = "update_proc";
157  break;
158  case DELETE_PROC:
159  type_string_p = "delete_proc";
160  break;
161  case INSERT_PROC:
162  type_string_p = "insert_proc";
163  break;
164  case CONNECTBY_PROC:
165  type_string_p = "connectby_proc";
166  break;
167  case MERGE_PROC:
168  type_string_p = "merge_proc";
169  break;
170  case CTE_PROC:
171  type_string_p = "cte_proc";
172  break;
173  default:
174  return false;
175  }
176 
177  fprintf (foutput, "[%s:%p]\n", type_string_p, xasl_p);
178  return true;
179 }
180 
181 /*
182  * qdump_print_db_value_array () -
183  * return:
184  * array(in) :
185  * int cnt(in):
186  */
187 static bool
189 {
190  int i;
191 
192  if (array_p == NULL)
193  {
194  return true;
195  }
196 
197  for (i = 0; i < count; i++, array_p++)
198  {
199  if (!qdump_print_db_value (*array_p))
200  {
201  return false;
202  }
203  fprintf (foutput, "; ");
204  }
205 
206  return true;
207 }
208 
209 static bool
210 qdump_print_column (const char *title_p, int col_count, int *column_p)
211 {
212  int i;
213 
214  fprintf (foutput, "[%s:", title_p);
215 
216  for (i = 0; i < col_count; i++)
217  {
218  fprintf (foutput, "%s%d", (i ? "|" : ""), *(column_p + i));
219  }
220 
221  fprintf (foutput, "]");
222  return true;
223 }
224 
225 /*
226  * qdump_print_list_merge_info () -
227  * return:
228  * ptr(in):
229  */
230 static bool
232 {
233  if (merge_info_p == NULL)
234  {
235  return true;
236  }
237 
238  fprintf (foutput, "[join type:%d]", merge_info_p->join_type);
239  fprintf (foutput, "[single fetch:%d]\n", merge_info_p->single_fetch);
240 
241  qdump_print_column ("outer column position", merge_info_p->ls_column_cnt, merge_info_p->ls_outer_column);
242  qdump_print_column ("outer column is unique", merge_info_p->ls_column_cnt, merge_info_p->ls_outer_unique);
243  qdump_print_column ("inner column position", merge_info_p->ls_column_cnt, merge_info_p->ls_inner_column);
244  qdump_print_column ("inner column is unique", merge_info_p->ls_column_cnt, merge_info_p->ls_inner_unique);
245 
246  fprintf (foutput, "\n[output column count:%d]", merge_info_p->ls_pos_cnt);
247 
248  qdump_print_column ("output columns", merge_info_p->ls_pos_cnt, merge_info_p->ls_pos_list);
249  qdump_print_column ("outer/inner indicators", merge_info_p->ls_pos_cnt, merge_info_p->ls_outer_inner_list);
250 
251  return true;
252 }
253 
254 /*
255  * qdump_print_merge_list_proc_node () -
256  * return:
257  * ptr(in):
258  */
259 static bool
261 {
262  fprintf (foutput, "[outer xasl:%p]\n", node_p->outer_xasl);
263  if (node_p->outer_spec_list)
264  {
265  fprintf (foutput, "-->outer access spec:");
267  fprintf (foutput, "\n");
268  }
269 
270  if (node_p->outer_val_list)
271  {
272  fprintf (foutput, "-->outer val_list:");
274  fprintf (foutput, "\n");
275  }
276 
277  fprintf (foutput, "[inner xasl:%p]\n", node_p->inner_xasl);
278 
279  if (node_p->inner_spec_list)
280  {
281  fprintf (foutput, "-->inner access spec:");
283  fprintf (foutput, "\n");
284  }
285 
286  if (node_p->inner_val_list)
287  {
288  fprintf (foutput, "-->inner val_list:");
290  fprintf (foutput, "\n");
291  }
292 
294  fprintf (foutput, "\n");
295 
296  return true;
297 }
298 
299 static bool
300 qdump_print_attribute (const char *action_p, int attr_count, int *attr_ids_p)
301 {
302  int i;
303 
304  fprintf (foutput, "[number of attributes to %s:%d]", action_p, attr_count);
305  fprintf (foutput, "[ID's of attributes for %s:", action_p);
306 
307  for (i = 0; i < attr_count; i++)
308  {
309  fprintf (foutput, "%d%c", attr_ids_p[i], i == attr_count - 1 ? ']' : ',');
310  }
311 
312  return true;
313 }
314 
315 /*
316  * qdump_print_update_proc_node () -
317  * return:
318  * ptr(in):
319  */
320 static bool
322 {
323  int i = 0, cnt = 0, idx = 0;
324  UPDDEL_CLASS_INFO *cls = NULL;
325 
326  cnt = node_p->num_classes;
327  for (idx = 0; idx < cnt; idx++)
328  {
329  cls = node_p->classes;
330 
331  fprintf (foutput, "[number of HFID's to use:%d]", cls->num_subclasses);
332 
333  for (i = 0; i < cls->num_subclasses; ++i)
334  {
335  qdump_print_oid (&cls->class_oid[i]);
336  }
337 
338  for (i = 0; i < cls->num_subclasses; ++i)
339  {
340  qdump_print_hfid (cls->class_hfid[i]);
341  }
342 
343  qdump_print_attribute ("update", cls->num_attrs, cls->att_id);
344  }
345  fprintf (foutput, "[numer of ORDER BY keys:%d]", node_p->num_orderby_keys);
346 
347  return true;
348 }
349 
350 /*
351  * qdump_print_delete_proc_node () -
352  * return:
353  * ptr(in):
354  */
355 static bool
357 {
358  int i, j;
359  int hfid_count = 0;
360  /* actual number of HFID's is no_classes + number of subclasses for each class */
361 
362 
363  for (i = 0; i < node_p->num_classes; ++i)
364  {
365  hfid_count += node_p->classes[i].num_subclasses;
366  }
367 
368  fprintf (foutput, "[number of HFID's to use:%d]", hfid_count);
369 
370  for (i = 0; i < node_p->num_classes; ++i)
371  {
372  for (j = 0; j < node_p->classes[i].num_subclasses; ++j)
373  {
374  qdump_print_oid (&node_p->classes[i].class_oid[j]);
375  }
376 
377  for (j = 0; j < node_p->classes[i].num_subclasses; ++j)
378  {
379  qdump_print_hfid (node_p->classes[i].class_hfid[j]);
380  }
381  }
382 
383  return true;
384 }
385 
386 /*
387  * qdump_print_insert_proc_node () -
388  * return:
389  * ptr(in):
390  */
391 static bool
393 {
394  fprintf (foutput, "class oid[%d %d %d]", node_p->class_oid.pageid, node_p->class_oid.slotid, node_p->class_oid.volid);
395 
396  qdump_print_hfid (node_p->class_hfid);
397  qdump_print_attribute ("insert", node_p->num_vals, node_p->att_id);
398 
399  return true;
400 }
401 
402 /*
403  * qdump_target_type_string () -
404  * return:
405  * type(in):
406  */
407 static const char *
409 {
410  switch (type)
411  {
412  case TARGET_CLASS:
413  return "class";
414  case TARGET_CLASS_ATTR:
415  return "class_attr";
416  case TARGET_LIST:
417  return "list";
418  case TARGET_SHOWSTMT:
419  return "show";
420  case TARGET_SET:
421  return "set";
422  case TARGET_METHOD:
423  return "method";
424  default:
425  return "undefined";
426  }
427 }
428 
429 /*
430  * qdump_access_method_string () -
431  * return:
432  * access(in):
433  */
434 static const char *
436 {
437  switch (access)
438  {
440  return "sequential";
441  case ACCESS_METHOD_INDEX:
442  return "index";
444  return "sequential record info";
446  return "sequential page scan";
447  default:
448  return "undefined";
449  }
450 }
451 
452 /*
453  * qdump_print_access_spec () -
454  * return:
455  * spec_list(in):
456  */
457 static bool
459 {
460  TARGET_TYPE type;
461 
462  if (spec_list_p == NULL)
463  {
464  return true;
465  }
466 
467  type = spec_list_p->type;
468  fprintf (foutput, " %s", qdump_target_type_string (type));
469 
470  fprintf (foutput, ",%s", qdump_access_method_string (spec_list_p->access));
471 
472  if (IS_ANY_INDEX_ACCESS (spec_list_p->access))
473  {
474  if (qdump_print_index (spec_list_p->indexptr) == false)
475  {
476  return false;
477  }
478  }
479 
480  fprintf (foutput, "\n ");
481 
482  if (type == TARGET_CLASS)
483  {
484  qdump_print_class (&ACCESS_SPEC_CLS_SPEC (spec_list_p));
485  }
486  else if (type == TARGET_SET)
487  {
488  qdump_print_value (ACCESS_SPEC_SET_PTR (spec_list_p));
489  }
490  else if (type == TARGET_LIST)
491  {
492  qdump_print_list (&ACCESS_SPEC_LIST_SPEC (spec_list_p));
493  }
494  else if (type == TARGET_SHOWSTMT)
495  {
497  }
498 
499 
500  if (spec_list_p->where_key)
501  {
502  fprintf (foutput, "\n key filter:");
503  qdump_print_predicate (spec_list_p->where_key);
504  }
505 
506  if (spec_list_p->where_pred)
507  {
508  fprintf (foutput, "\n access pred:");
509  qdump_print_predicate (spec_list_p->where_pred);
510  }
511 
512  if (spec_list_p->where_range)
513  {
514  fprintf (foutput, "\n access range:");
515  qdump_print_predicate (spec_list_p->where_range);
516  }
517 
518 #if defined (SERVER_MODE) || defined (SA_MODE)
519  fprintf (foutput, "\n grouped scan=%d", spec_list_p->grouped_scan);
520  fprintf (foutput, ",fixed scan=%d", spec_list_p->fixed_scan);
521 #endif /* defined (SERVER_MODE) || defined (SA_MODE) */
522  fprintf (foutput, ",single fetch=%d", spec_list_p->single_fetch);
523 
524  if (spec_list_p->s_dbval)
525  {
526  fprintf (foutput, "\n s_dbval:");
527  qdump_print_db_value (spec_list_p->s_dbval);
528  }
529 
530  fprintf (foutput, "\n-->next access spec:");
531  qdump_print_access_spec (spec_list_p->next);
532  fprintf (foutput, "\n");
533 
534  return true;
535 }
536 
537 static const char *
539 {
540  switch (range)
541  {
542  case NA_NA:
543  return "N/A";
544  case GE_LE:
545  return "GE_LE";
546  case GE_LT:
547  return "GE_LT";
548  case GT_LE:
549  return "GT_LE";
550  case GT_LT:
551  return "GT_LT";
552  case GE_INF:
553  return "GE_INF";
554  case GT_INF:
555  return "GT_INF";
556  case INF_LT:
557  return "INF_LT";
558  case INF_LE:
559  return "INF_LE";
560  case INF_INF:
561  return "INF_INF";
562  case EQ_NA:
563  return "EQ";
564  default:
565  return "undefined";
566  }
567 }
568 
569 /*
570  * qdump_print_key_info () -
571  * return:
572  * key_info(in):
573  */
574 static bool
576 {
577  int i;
578 
579  fprintf (foutput, "<key cnt:%d>", key_info_p->key_cnt);
580  fprintf (foutput, "key ranges:");
581  for (i = 0; i < key_info_p->key_cnt; i++)
582  {
583  fprintf (foutput, "<%s>", qdump_key_range_string (key_info_p->key_ranges[i].range));
584 
585  fprintf (foutput, "[");
586  if (!qdump_print_value (key_info_p->key_ranges[i].key1))
587  {
588  return false;
589  }
590 
591  fprintf (foutput, "][");
592 
593  if (!qdump_print_value (key_info_p->key_ranges[i].key2))
594  {
595  return false;
596  }
597  fprintf (foutput, "]");
598  }
599  fprintf (foutput, "<is constant:%d>", key_info_p->is_constant);
600  fprintf (foutput, "<is user given keylimit:%d>", key_info_p->is_user_given_keylimit);
601  fprintf (foutput, "<reset:%d>", key_info_p->key_limit_reset);
602 
603  fprintf (foutput, " key limit: [");
604  qdump_print_value (key_info_p->key_limit_l);
605  fprintf (foutput, "][");
606  qdump_print_value (key_info_p->key_limit_u);
607  fprintf (foutput, "]");
608 
609  return true;
610 }
611 
612 static const char *
614 {
615  switch (range_type)
616  {
617  case R_KEY:
618  return "R_KEY";
619  case R_RANGE:
620  return "R_RANGE";
621  case R_KEYLIST:
622  return "R_KEYLIST";
623  case R_RANGELIST:
624  return "R_RANGELIST";
625  default:
626  return "undefined";
627  }
628 }
629 
630 /*
631  * qdump_print_index () -
632  * return:
633  * index_ptr(in):
634  */
635 static bool
637 {
638  if (index_p == NULL)
639  {
640  return true;
641  }
642 
643  fprintf (foutput, "<index id:");
644  if (!qdump_print_btid (index_p->btid))
645  {
646  return false;
647  }
648  fprintf (foutput, ">");
649 
650  fprintf (foutput, "<%s>", qdump_range_type_string (index_p->range_type));
651 
652  fprintf (foutput, "key info:");
653  if (!qdump_print_key_info (&index_p->key_info))
654  {
655  return false;
656  }
657  fprintf (foutput, ">");
658 
659  return true;
660 }
661 
662 /*
663  * qdump_print_btid () -
664  * return:
665  * id(in):
666  */
667 static bool
669 {
670  fprintf (foutput, "<Btree:(%d;%d;%d)>", id.vfid.fileid, id.vfid.volid, id.root_pageid);
671  return true;
672 }
673 
674 /*
675  * qdump_print_class () -
676  * return:
677  * ptr(in):
678  */
679 static bool
681 {
682  qdump_print_hfid (class_p->hfid);
683  fprintf (foutput, "oid[%d %d %d]", class_p->cls_oid.pageid, class_p->cls_oid.slotid, class_p->cls_oid.volid);
684  fprintf (foutput, "\n regu_list_key:");
686  fprintf (foutput, "\n regu_list_pred:");
688  fprintf (foutput, "\n regu_list_rest:");
690  return true;
691 }
692 
693 /*
694  * qdump_print_hfid () -
695  * return:
696  * id(in):
697  */
698 static bool
700 {
701  fprintf (foutput, "hfid:");
702  qdump_print_vfid (id.vfid);
703  fprintf (foutput, ":%d", id.hpgid);
704  return true;
705 }
706 
707 /*
708  * qdump_print_vfid () -
709  * return:
710  * id(in):
711  */
712 static bool
714 {
715  fprintf (foutput, "vfid(%d;%d)", id.fileid, id.volid);
716  return true;
717 }
718 
719 /*
720  * qdump_print_list () -
721  * return:
722  * ptr(in):
723  */
724 static bool
726 {
727  fprintf (foutput, "list=");
728  fprintf (foutput, "xasl:%p", list_p->xasl_node);
729  fprintf (foutput, "\n regu_list_pred:");
731  fprintf (foutput, "\n regu_list_rest:");
733  fprintf (foutput, "\n regu_list_build:");
735  fprintf (foutput, "\n regu_list_probe:");
737  return true;
738 }
739 
740 /*
741  * qdump_print_showstmt () -
742  * return:
743  * ptr(in):
744  */
745 static bool
747 {
748  fprintf (foutput, "show_type: %d", showstmt_p->show_type);
749  fprintf (foutput, "\n show_args: ");
751  return true;
752 }
753 
754 /*
755  * qdump_print_outlist () -
756  * return:
757  * title(in):
758  * outlist(in):
759  */
760 static bool
761 qdump_print_outlist (const char *title_p, OUTPTR_LIST * outlist_p)
762 {
763  REGU_VARIABLE_LIST nextptr;
764 
765  if (outlist_p == NULL)
766  {
767  return true;
768  }
769 
770  nextptr = outlist_p->valptrp;
771  fprintf (foutput, "-->%s:", title_p);
772 
773  while (nextptr)
774  {
775  fprintf (foutput, "[addr:%p]", &nextptr->value);
776  if (!qdump_print_value (&nextptr->value))
777  {
778  return false;
779  }
780 
781  fprintf (foutput, "; ");
782  nextptr = nextptr->next;
783  }
784 
785  fprintf (foutput, "\n");
786  return true;
787 }
788 
789 /*
790  * qdump_print_list_id () -
791  * return:
792  * idptr(in):
793  */
794 static bool
796 {
797  if (list_id_p == NULL)
798  {
799  return true;
800  }
801 
802  fprintf (foutput, "(address:%p)", list_id_p);
803  fprintf (foutput, "(type_list:");
804 
805  if (!qdump_print_type_list (&list_id_p->type_list))
806  {
807  return false;
808  }
809 
810  fprintf (foutput, ")(tuple_cnt:%d)", list_id_p->tuple_cnt);
811  return true;
812 }
813 
814 /*
815  * qdump_print_type_list () -
816  * return:
817  * typeptr(in):
818  */
819 static bool
821 {
822  fprintf (foutput, "<type_cnt:%d>", type_list_p->type_cnt);
823  if (!qdump_print_domain_list (type_list_p->type_cnt, type_list_p->domp))
824  {
825  return false;
826  }
827  return true;
828 }
829 
830 /*
831  * qdump_print_domain_list () -
832  * return:
833  * cnt(in):
834  * ptr(in):
835  */
836 static bool
837 qdump_print_domain_list (int cnt, TP_DOMAIN ** domains_p)
838 {
839  int i;
840 
841  if (domains_p == NULL)
842  {
843  return true;
844  }
845 
846  for (i = 0; i < cnt; i++)
847  {
848  fprintf (foutput, "%s; ", qdump_data_type_string (TP_DOMAIN_TYPE (domains_p[i])));
849  }
850 
851  return true;
852 }
853 
854 /*
855  * qdump_print_sort_list () -
856  * return:
857  * sorting_list(in):
858  */
859 static bool
861 {
862  if (sort_list_p == NULL)
863  {
864  return true;
865  }
866 
867  fprintf (foutput, "<sorting field(POS):");
868  if (!qdump_print_tuple_value_position (sort_list_p->pos_descr))
869  {
870  return false;
871  }
872 
873  fprintf (foutput, ">");
874  fprintf (foutput, "<sorting order:");
875  if (sort_list_p->s_order == S_ASC)
876  {
877  fprintf (foutput, "ascending>");
878  }
879  else
880  {
881  fprintf (foutput, "descending>");
882  }
883 
884  if (!qdump_print_sort_list (sort_list_p->next))
885  {
886  return false;
887  }
888  return true;
889 }
890 
891 /*
892  * qdump_print_attribute_id () -
893  * return:
894  * attr(in):
895  */
896 static bool
898 {
899  fprintf (foutput, "attr_id:%d|db_type:", (int) attr.id);
900  fprintf (foutput, "%s", qdump_data_type_string (attr.type));
901 
902  return true;
903 }
904 
905 /*
906  * qdump_print_tuple_value_position () -
907  * return:
908  * pos(in):
909  */
910 static bool
912 {
913  fprintf (foutput, "(position %d) (db_type ", pos.pos_no);
914  fprintf (foutput, "%s", qdump_data_type_string (TP_DOMAIN_TYPE (pos.dom)));
915  fprintf (foutput, ")");
916 
917  return true;
918 }
919 
920 /*
921  * qdump_print_value_list () -
922  * return:
923  * vallist(in):
924  */
925 static bool
927 {
928  QPROC_DB_VALUE_LIST dbval_list;
929 
930  if (value_list_p == NULL)
931  {
932  return true;
933  }
934 
935  dbval_list = value_list_p->valp;
936  fprintf (foutput, "(values %d <", value_list_p->val_cnt);
937 
938  while (dbval_list != NULL)
939  {
940  fprintf (foutput, "addr:%p|", dbval_list->val);
941  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (dbval_list->val)));
942  fprintf (foutput, "|value:");
943 
944  if (!qdump_print_db_value (dbval_list->val))
945  {
946  return false;
947  }
948 
949  fprintf (foutput, "; ");
950  dbval_list = dbval_list->next;
951  }
952 
953  fprintf (foutput, ">)");
954  return true;
955 }
956 
957 /*
958  * qdump_print_regu_variable_list () -
959  * return:
960  * varlist(in):
961  */
962 static bool
964 {
965  if (var_list == NULL)
966  {
967  return true;
968  }
969 
970  while (var_list != NULL)
971  {
972  if (!qdump_print_value (&var_list->value))
973  {
974  return false;
975  }
976 
977  fprintf (foutput, "; ");
978  var_list = var_list->next;
979  }
980 
981  return true;
982 }
983 
984 /*
985  * qdump_option_string () -
986  * return:
987  * option(in):
988  */
989 static const char *
991 {
992  switch (option)
993  {
994  case Q_DISTINCT:
995  return "DISTINCT";
996  case Q_ALL:
997  return "ALL";
998  default:
999  return "undefined";
1000  }
1001 }
1002 
1003 /*
1004  * qdump_print_db_value () -
1005  * return:
1006  * value(in):
1007  */
1008 static bool
1010 {
1011  db_value_print (value_p);
1012  return true;
1013 }
1014 
1015 const char *
1017 {
1018  switch (optype)
1019  {
1020  case T_TO_CHAR:
1021  return "TO_CHAR";
1022  /* TODO - fill */
1023  default:
1024  return NULL;
1025  }
1026 }
1027 
1028 static const char *
1030 {
1031  switch (type)
1032  {
1033  case TYPE_DBVAL:
1034  return "TYPE_DBVAL";
1035  case TYPE_CONSTANT:
1036  return "TYPE_CONSTANT";
1037  case TYPE_ORDERBY_NUM:
1038  return "TYPE_ORDERBY_NUM";
1039  case TYPE_INARITH:
1040  return "TYPE_INARITH";
1041  case TYPE_OUTARITH:
1042  return "TYPE_OUTARITH";
1043  case TYPE_ATTR_ID:
1044  return "TYPE_ATTR_ID";
1045  case TYPE_CLASS_ATTR_ID:
1046  return "TYPE_CLASS_ATTR_ID";
1047  case TYPE_SHARED_ATTR_ID:
1048  return "TYPE_SHARED_ATTR_ID";
1049  case TYPE_POSITION:
1050  return "TYPE_POSITION";
1051  case TYPE_LIST_ID:
1052  return "TYPE_LIST_ID";
1053  case TYPE_POS_VALUE:
1054  return "TYPE_POS_VALUE";
1055  case TYPE_OID:
1056  return "TYPE_OID";
1057  case TYPE_CLASSOID:
1058  return "TYPE_CLASSOID";
1059  case TYPE_FUNC:
1060  return "TYPE_FUNC";
1061  case TYPE_REGUVAL_LIST:
1062  return "TYPE_REGUVAL_LIST";
1063  case TYPE_REGU_VAR_LIST:
1064  return "TYPE_REGU_VAR_LIST";
1065  default:
1066  return "undefined";
1067  }
1068 }
1069 
1070 /*
1071  * qdump_print_regu_type () -
1072  * return:
1073  * value(in):
1074  */
1075 static bool
1077 {
1078  DB_TYPE type;
1079 
1080  if (value_p->type == TYPE_DBVAL)
1081  {
1082  type = DB_VALUE_DOMAIN_TYPE (&(value_p->value.dbval));
1083  fprintf (foutput, "%s", qdump_data_type_string (type));
1084  }
1085  else
1086  {
1087  fprintf (foutput, "%s", qdump_regu_type_string (value_p->type));
1088  }
1089 
1090  return true;
1091 }
1092 
1093 /*
1094  * qdump_data_type_string () -
1095  * return:
1096  * type(in):
1097  */
1098 
1099 static const char *
1101 {
1102  switch (type)
1103  {
1104  case DB_TYPE_NULL:
1105  return "NULL";
1106  case DB_TYPE_INTEGER:
1107  return "INTEGER";
1108  case DB_TYPE_BIGINT:
1109  return "BIGINT";
1110  case DB_TYPE_FLOAT:
1111  return "FLOAT";
1112  case DB_TYPE_DOUBLE:
1113  return "DOUBLE";
1114  case DB_TYPE_VARCHAR:
1115  return "VARCHAR";
1116  case DB_TYPE_OBJECT:
1117  return "OBJECT";
1118  case DB_TYPE_SET:
1119  return "SET";
1120  case DB_TYPE_MULTISET:
1121  return "MULTISET";
1122  case DB_TYPE_SEQUENCE:
1123  return "SEQUENCE";
1124  case DB_TYPE_BLOB:
1125  return "BLOB";
1126  case DB_TYPE_CLOB:
1127  return "CLOB";
1128  case DB_TYPE_TIME:
1129  return "TIME";
1130  case DB_TYPE_TIMESTAMP:
1131  return "TIMESTAMP";
1132  case DB_TYPE_TIMESTAMPTZ:
1133  return "TIMESTAMPTZ";
1134  case DB_TYPE_TIMESTAMPLTZ:
1135  return "TIMESTAMPLTZ";
1136  case DB_TYPE_DATETIME:
1137  return "DATETIME";
1138  case DB_TYPE_DATETIMETZ:
1139  return "DATETIMETZ";
1140  case DB_TYPE_DATETIMELTZ:
1141  return "DATETIMELTZ";
1142  case DB_TYPE_DATE:
1143  return "DATE";
1144  case DB_TYPE_MONETARY:
1145  return "MONETARY";
1146  case DB_TYPE_VARIABLE:
1147  return "VARIABLE";
1148  case DB_TYPE_SUB:
1149  return "SUB";
1150  case DB_TYPE_POINTER:
1151  return "POINTER";
1152  case DB_TYPE_ERROR:
1153  return "ERROR";
1154  case DB_TYPE_SMALLINT:
1155  return "SMALLINT";
1156  case DB_TYPE_VOBJ:
1157  return "VOBJ";
1158  case DB_TYPE_OID:
1159  return "OID";
1160  case DB_TYPE_NUMERIC:
1161  return "NUMERIC";
1162  case DB_TYPE_BIT:
1163  return "BIT";
1164  case DB_TYPE_VARBIT:
1165  return "VARBIT";
1166  case DB_TYPE_CHAR:
1167  return "CHAR";
1168  case DB_TYPE_NCHAR:
1169  return "NCHAR";
1170  case DB_TYPE_VARNCHAR:
1171  return "VARNCHAR";
1172  case DB_TYPE_DB_VALUE:
1173  return "DB_VALUE";
1174  case DB_TYPE_RESULTSET:
1175  return "DB_RESULTSET";
1176  case DB_TYPE_MIDXKEY:
1177  return "DB_MIDXKEY";
1178  case DB_TYPE_TABLE:
1179  return "DB_TABLE";
1180  case DB_TYPE_ENUMERATION:
1181  return "ENUM";
1182  case DB_TYPE_JSON:
1183  return "JSON";
1184  default:
1185  return "[***UNKNOWN***]";
1186  }
1187 }
1188 
1189 /*
1190  * qdump_print_value () -
1191  * return:
1192  * value(in):
1193  */
1194 static bool
1196 {
1197  if (value_p == NULL)
1198  {
1199  fprintf (foutput, "NIL");
1200  return true;
1201  }
1202 
1204  {
1205  fprintf (foutput, "[HIDDEN_COLUMN]");
1206  }
1207  if (value_p->xasl)
1208  {
1209  fprintf (foutput, "[xasl:%p]", value_p->xasl);
1210  }
1211 
1212  fprintf (foutput, "[");
1213  qdump_print_value_type_addr (value_p);
1214  fprintf (foutput, "]");
1215 
1216  switch (value_p->type)
1217  {
1218  case TYPE_DBVAL:
1219  fprintf (foutput, "[type:%s]", qdump_data_type_string (value_p->domain->type->id));
1220  qdump_print_db_value (&value_p->value.dbval);
1221  return true;
1222 
1223  case TYPE_CONSTANT:
1224  case TYPE_ORDERBY_NUM:
1225  fprintf (foutput, "[type:%s]", qdump_data_type_string (value_p->domain->type->id));
1226  qdump_print_db_value (value_p->value.dbvalptr);
1227  return true;
1228 
1229  case TYPE_INARITH:
1230  case TYPE_OUTARITH:
1231  if (!qdump_print_arith (ARITH_EXP, (void *) value_p->value.arithptr))
1232  {
1233  return false;
1234  }
1235  return true;
1236  case TYPE_ATTR_ID:
1237  if (!qdump_print_attribute_id (value_p->value.attr_descr))
1238  {
1239  return false;
1240  }
1241  return true;
1242 
1243  case TYPE_LIST_ID:
1244  if (value_p->value.srlist_id->sorted)
1245  {
1246  fprintf (foutput, "[SORTED]");
1247  }
1248  else
1249  {
1250  fprintf (foutput, "[NOT SORTED]");
1251  }
1252 
1253  if (!qdump_print_list_id (value_p->value.srlist_id->list_id))
1254  {
1255  return false;
1256  }
1257 
1258  return true;
1259 
1260  case TYPE_POSITION:
1261  if (!qdump_print_tuple_value_position (value_p->value.pos_descr))
1262  {
1263  return false;
1264  }
1265 
1266  return true;
1267 
1268  case TYPE_POS_VALUE:
1269  case TYPE_OID:
1270  fprintf (foutput, "[type:%s]", qdump_data_type_string (value_p->domain->type->id));
1271  return true;
1272 
1273  case TYPE_FUNC:
1274  qdump_print_function_value (value_p);
1275  return true;
1276 
1277  default:
1278  return true;
1279  }
1280 }
1281 
1282 /*
1283  * qdump_print_function_value () -
1284  * return:
1285  * regu(in):
1286  */
1287 static bool
1289 {
1290  if (regu_var_p == NULL)
1291  {
1292  fprintf (foutput, "NIL");
1293  return true;
1294  }
1295 
1297  {
1298  fprintf (foutput, "[HIDDEN_COLUMN]");
1299  }
1300 
1301  fprintf (foutput, "[TYPE_FUNC]");
1302  fprintf (foutput, "[%s]", fcode_get_uppercase_name (regu_var_p->value.funcp->ftype));
1303  fprintf (foutput, "operand-->");
1304  qdump_print_regu_variable_list (regu_var_p->value.funcp->operand);
1305 
1306  return true;
1307 }
1308 
1309 /*
1310  * qdump_print_value_type_addr () -
1311  * return:
1312  * value(in):
1313  */
1314 static bool
1316 {
1317  void *addr;
1318 
1319  qdump_print_regu_type (regu_var_p);
1320 
1321  switch (regu_var_p->type)
1322  {
1323  case TYPE_DBVAL:
1324  addr = (void *) &regu_var_p->value.dbval;
1325  break;
1326 
1327  case TYPE_CONSTANT:
1328  case TYPE_ORDERBY_NUM:
1329  addr = (void *) regu_var_p->value.dbvalptr;
1330  break;
1331 
1332  case TYPE_INARITH:
1333  case TYPE_OUTARITH:
1334  addr = (void *) regu_var_p->value.arithptr;
1335  break;
1336 
1337  case TYPE_LIST_ID:
1338  addr = (void *) regu_var_p->value.srlist_id->list_id;
1339  break;
1340 
1341  case TYPE_ATTR_ID:
1342  case TYPE_SHARED_ATTR_ID:
1343  case TYPE_CLASS_ATTR_ID:
1344  addr = (void *) &regu_var_p->value.attr_descr;
1345  break;
1346 
1347  case TYPE_POSITION:
1348  addr = (void *) &regu_var_p->value.pos_descr;
1349  break;
1350 
1351  case TYPE_POS_VALUE:
1352  addr = (void *) &regu_var_p->value.val_pos;
1353  break;
1354 
1355  case TYPE_OID:
1356  case TYPE_CLASSOID:
1357  case TYPE_FUNC:
1358  return true;
1359 
1360  default:
1361  return false;
1362  }
1363 
1364  fprintf (foutput, ":%p", addr);
1365 
1366  return true;
1367 }
1368 
1369 
1370 /*
1371  * qdump_print_oid () -
1372  * return:
1373  * id(in):
1374  */
1375 static bool
1377 {
1378  fprintf (foutput, "[OID:%d,%d,%d]", oid_p->pageid, oid_p->slotid, oid_p->volid);
1379  return true;
1380 }
1381 
1382 static bool
1384 {
1385  COMP_EVAL_TERM *et_comp_p = &term_p->et.et_comp;
1386 
1387  fprintf (foutput, "[TYPE:%s]", qdump_data_type_string (et_comp_p->type));
1388 
1389  qdump_print_value (et_comp_p->lhs);
1390  fprintf (foutput, " %s ", qdump_relation_operator_string (et_comp_p->rel_op));
1391 
1392  if (et_comp_p->rhs != NULL)
1393  {
1394  qdump_print_value (et_comp_p->rhs);
1395  }
1396 
1397  return true;
1398 }
1399 
1400 static bool
1402 {
1403  ALSM_EVAL_TERM *et_alsm_p = &term_p->et.et_alsm;
1404 
1405  fprintf (foutput, "[ITEM TYPE:%s]", qdump_data_type_string (et_alsm_p->item_type));
1406 
1407  qdump_print_value (et_alsm_p->elem);
1408  fprintf (foutput, " %s ", qdump_relation_operator_string (et_alsm_p->rel_op));
1409 
1410  switch (et_alsm_p->eq_flag)
1411  {
1412  case F_SOME:
1413  fprintf (foutput, "some ");
1414  break;
1415  case F_ALL:
1416  fprintf (foutput, "all ");
1417  break;
1418  default:
1419  return false;
1420  }
1421 
1422  qdump_print_value (et_alsm_p->elemset);
1423 
1424  return true;
1425 }
1426 
1427 static bool
1429 {
1430  LIKE_EVAL_TERM *et_like_p = &term_p->et.et_like;
1431 
1432  fprintf (foutput, "SOURCE");
1433  qdump_print_value (et_like_p->src);
1434  fprintf (foutput, "PATTERN:");
1435 
1436  if (!qdump_print_value (et_like_p->pattern))
1437  {
1438  return false;
1439  }
1440 
1441  if (et_like_p->esc_char)
1442  {
1443  if (!qdump_print_value (et_like_p->esc_char))
1444  {
1445  return false;
1446  }
1447  }
1448 
1449  return true;
1450 }
1451 
1452 static bool
1454 {
1455  RLIKE_EVAL_TERM *et_rlike_p = &term_p->et.et_rlike;
1456 
1457  fprintf (foutput, "SOURCE");
1458  qdump_print_value (et_rlike_p->src);
1459  fprintf (foutput, (et_rlike_p->case_sensitive->value.dbval.data.i
1460  ? "PATTERN (CASE SENSITIVE):" : "PATTERN (CASE INSENSITIVE):"));
1461 
1462  if (!qdump_print_value (et_rlike_p->pattern))
1463  {
1464  return false;
1465  }
1466 
1467  return true;
1468 }
1469 
1470 static bool
1472 {
1473  EVAL_TERM *term = &pred_p->pe.m_eval_term;
1474 
1475  switch (term->et_type)
1476  {
1477  case T_COMP_EVAL_TERM:
1478  return qdump_print_comp_eval_term (term);
1479 
1480  case T_ALSM_EVAL_TERM:
1481  return qdump_print_alsm_eval_term (term);
1482 
1483  case T_LIKE_EVAL_TERM:
1484  return qdump_print_like_eval_term (term);
1485 
1486  case T_RLIKE_EVAL_TERM:
1487  return qdump_print_rlike_eval_term (term);
1488 
1489  default:
1490  return false;
1491  }
1492 }
1493 
1494 /*
1495  * qdump_print_term () -
1496  * return:
1497  * term(in):
1498  */
1499 static bool
1501 {
1502  if (pred_p == NULL)
1503  {
1504  return true;
1505  }
1506 
1507  switch (pred_p->type)
1508  {
1509  case T_EVAL_TERM:
1510  return qdump_print_eval_term (pred_p);
1511 
1512  case T_NOT_TERM:
1513  fprintf (foutput, "(NOT ");
1514 
1515  if (!qdump_print_predicate (pred_p->pe.m_not_term))
1516  {
1517  return false;
1518  }
1519  fprintf (foutput, ")");
1520 
1521  return true;
1522 
1523  default:
1524  return false;
1525  }
1526 }
1527 
1528 static const char *
1530 {
1531  if (bool_op == B_AND)
1532  {
1533  return "AND";
1534  }
1535  else if (bool_op == B_OR)
1536  {
1537  return "OR";
1538  }
1539  else if (bool_op == B_XOR)
1540  {
1541  return "XOR";
1542  }
1543  else if (bool_op == B_IS)
1544  {
1545  return "IS";
1546  }
1547  else if (bool_op == B_IS_NOT)
1548  {
1549  return "IS NOT";
1550  }
1551  else
1552  {
1553  return "undefined";
1554  }
1555 }
1556 
1557 static bool
1559 {
1560  fprintf (foutput, "(");
1561 
1562  if (!qdump_print_predicate (pred_p->pe.m_pred.lhs))
1563  {
1564  return false;
1565  }
1566 
1567  fprintf (foutput, " %s ", qdump_bool_operator_string (pred_p->pe.m_pred.bool_op));
1568 
1569  return true;
1570 }
1571 
1572 /*
1573  * qdump_print_predicate () -
1574  * return:
1575  * predptr(in):
1576  */
1577 static bool
1579 {
1580  int parn_cnt;
1581 
1582  if (pred_p == NULL)
1583  {
1584  return true;
1585  }
1586 
1587  switch (pred_p->type)
1588  {
1589  case T_PRED:
1590  if (qdump_print_lhs_predicate (pred_p) == false)
1591  {
1592  return false;
1593  }
1594 
1595  parn_cnt = 1;
1596 
1597  /* Traverse right-linear chains of AND/OR terms */
1598  for (pred_p = pred_p->pe.m_pred.rhs; pred_p->type == T_PRED; pred_p = pred_p->pe.m_pred.rhs)
1599  {
1600  if (qdump_print_lhs_predicate (pred_p) == false)
1601  {
1602  return false;
1603  }
1604 
1605  parn_cnt++;
1606  }
1607 
1608  /* rhs */
1609  switch (pred_p->type)
1610  {
1611  case T_EVAL_TERM:
1612  case T_NOT_TERM:
1613  if (!qdump_print_term (pred_p))
1614  {
1615  return false;
1616  }
1617  break;
1618  default:
1619  return false;
1620  }
1621 
1622  while (parn_cnt > 0)
1623  {
1624  fprintf (foutput, ")");
1625  parn_cnt--;
1626  }
1627 
1628  return true;
1629 
1630  case T_EVAL_TERM:
1631  case T_NOT_TERM:
1632  return qdump_print_term (pred_p);
1633 
1634  default:
1635  return false;
1636  }
1637 }
1638 
1639 /*
1640  * qdump_relation_operator_string () -
1641  * return:
1642  * op(in):
1643  */
1644 static const char *
1646 {
1647  switch (op)
1648  {
1649  case R_EQ:
1650  return "=";
1651  case R_NE:
1652  return "<>";
1653  case R_GT:
1654  return ">";
1655  case R_GE:
1656  return ">=";
1657  case R_LT:
1658  return "<";
1659  case R_LE:
1660  return "<=";
1661  case R_NULL:
1662  return "IS NULL";
1663  case R_EXISTS:
1664  return "EXISTS";
1665  case R_NULLSAFE_EQ:
1666  return "<=>";
1667  default:
1668  return "undefined";
1669  }
1670 }
1671 
1672 static const char *
1674 {
1675  switch (opcode)
1676  {
1677  case T_ADD:
1678  return "+";
1679  case T_SUB:
1680  return "-";
1681  case T_MUL:
1682  return "*";
1683  case T_DIV:
1684  return "/";
1685  case T_STRCAT:
1686  return "||";
1687  case T_BIT_NOT:
1688  return "~";
1689  case T_BIT_AND:
1690  return "&";
1691  case T_BIT_OR:
1692  return "|";
1693  case T_BIT_XOR:
1694  return "^";
1695  case T_BITSHIFT_LEFT:
1696  return "<<";
1697  case T_BITSHIFT_RIGHT:
1698  return ">>";
1699  case T_INTDIV:
1700  return "div";
1701  case T_INTMOD:
1702  return "mod";
1703  default:
1704  return "undefined";
1705  }
1706 }
1707 
1708 static bool
1710 {
1711  fprintf (foutput, "[%s]", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (arith_p->value)));
1712 
1713  if (arith_p->opcode == T_UNMINUS
1714 #if defined(ENABLE_UNUSED_FUNCTION)
1715  || arith_p->opcode == T_UNPLUS
1716 #endif /* ENABLE_UNUSED_FUNCTION */
1717  )
1718  {
1719  fprintf (foutput, "(");
1720  if (arith_p->opcode == T_UNMINUS)
1721  {
1722  fprintf (foutput, "-");
1723  }
1724 #if defined(ENABLE_UNUSED_FUNCTION)
1725  else
1726  {
1727  fprintf (foutput, "+");
1728  }
1729 #endif /* ENABLE_UNUSED_FUNCTION */
1730 
1731  if (!qdump_print_value (arith_p->rightptr))
1732  {
1733  return false;
1734  }
1735  fprintf (foutput, ")");
1736  }
1737  else
1738  {
1739  /* binary op */
1740 
1741  fprintf (foutput, "(");
1742  if (!qdump_print_value (arith_p->leftptr))
1743  {
1744  return false;
1745  }
1746 
1747  fprintf (foutput, "%s", qdump_arith_operator_string (arith_p->opcode));
1748 
1749  if (!qdump_print_value (arith_p->rightptr))
1750  {
1751  return false;
1752  }
1753  fprintf (foutput, ")");
1754  }
1755 
1756  return true;
1757 }
1758 
1759 static bool
1761 {
1762  fprintf (foutput, "[%s]", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (aggptr->accumulator.value)));
1763 
1764  fprintf (foutput, "%s(", fcode_get_uppercase_name (aggptr->function));
1765 
1766  fprintf (foutput, "%s ", qdump_option_string (aggptr->option));
1767 
1768  REGU_VARIABLE_LIST operand = NULL;
1769  for (operand = aggptr->operands; operand != NULL; operand = operand->next)
1770  {
1771  if (!qdump_print_value (&operand->value))
1772  {
1773  return false;
1774  }
1775  }
1776 
1777  if (!qdump_print_list_id (aggptr->list_id))
1778  {
1779  return false;
1780  }
1781 
1782  fprintf (foutput, "(optimize:%d)", aggptr->flag_agg_optimize);
1783 
1784  if (!qdump_print_btid (aggptr->btid))
1785  {
1786  return false;
1787  }
1788 
1789  fprintf (foutput, ")");
1790 
1791  if (aggptr->next != NULL)
1792  {
1793  fprintf (foutput, "; ");
1794  if (!qdump_print_arith (AGG_EXP, aggptr->next))
1795  {
1796  return false;
1797  }
1798  }
1799 
1800  return true;
1801 }
1802 
1803 /*
1804  * qdump_print_arith () -
1805  * return:
1806  * type(in):
1807  * ptr(in):
1808  */
1809 static bool
1810 qdump_print_arith (int type, void *ptr)
1811 {
1812  if (ptr == NULL)
1813  {
1814  return true;
1815  }
1816 
1817  if (type == ARITH_EXP)
1818  {
1819  return qdump_print_arith_expression ((ARITH_TYPE *) ptr);
1820  }
1821  else if (type == AGG_EXP)
1822  {
1824  }
1825 
1826  return true;
1827 }
1828 
1829 #if defined(CUBRID_DEBUG)
1830 /*
1831  * qdump_check_xasl_tree () -
1832  * return:
1833  * xasl(in):
1834  */
1835 bool
1836 qdump_check_xasl_tree (xasl_node * xasl_p)
1837 {
1838  QDUMP_XASL_CHECK_NODE *chk_nodes[HASH_NUMBER] = { NULL };
1839 
1840  if (xasl_p == NULL)
1841  {
1842  return true;
1843  }
1844 
1845  /* recursively check the tree */
1846  qdump_check_node (xasl_p, chk_nodes);
1847 
1848  /* print any inconsistencies in the tree */
1849  return qdump_print_inconsistencies (chk_nodes);
1850 }
1851 
1852 /*
1853  * qdump_find_check_node_for () -
1854  * return:
1855  * xasl(in):
1856  * chk_nodes(in):
1857  */
1858 static QDUMP_XASL_CHECK_NODE *
1859 qdump_find_check_node_for (XASL_NODE * xasl_p, QDUMP_XASL_CHECK_NODE * chk_nodes[HASH_NUMBER])
1860 {
1861  UINTPTR access_node_hash;
1862  QDUMP_XASL_CHECK_NODE *check_node_p;
1863 
1864  access_node_hash = (UINTPTR) xasl_p % HASH_NUMBER;
1865 
1866  for (check_node_p = chk_nodes[access_node_hash]; check_node_p; check_node_p = check_node_p->next)
1867  {
1868  if (check_node_p->xasl_addr == (UINTPTR) xasl_p)
1869  {
1870  break;
1871  }
1872  }
1873 
1874  if (!check_node_p)
1875  {
1876  /* forward reference */
1877  check_node_p = (QDUMP_XASL_CHECK_NODE *) malloc (sizeof (QDUMP_XASL_CHECK_NODE));
1878  if (check_node_p == NULL)
1879  {
1880  return NULL;
1881  }
1882  check_node_p->next = chk_nodes[access_node_hash];
1883  chk_nodes[access_node_hash] = check_node_p;
1884  check_node_p->xasl_addr = (UINTPTR) xasl_p;
1885  check_node_p->xasl_type = xasl_p->type;
1886  check_node_p->referenced = 0;
1887  check_node_p->reachable = 0;
1888  }
1889 
1890  return check_node_p;
1891 }
1892 
1893 /*
1894  * qdump_check_node () -
1895  * return:
1896  * xasl(in):
1897  * chk_nodes(in):
1898  */
1899 static void
1900 qdump_check_node (XASL_NODE * xasl_p, QDUMP_XASL_CHECK_NODE * chk_nodes[HASH_NUMBER])
1901 {
1902  UINTPTR addr_hash;
1903  QDUMP_XASL_CHECK_NODE *check_node_p, *check_node1_p;
1904  ACCESS_SPEC_TYPE *spec_p;
1905 
1906  if (!xasl_p)
1907  {
1908  return;
1909  }
1910 
1911  /* get hash number */
1912  addr_hash = (UINTPTR) xasl_p % HASH_NUMBER;
1913 
1914  check_node_p = qdump_find_check_node_for (xasl_p, chk_nodes);
1915  if (check_node_p == NULL)
1916  {
1917  return;
1918  }
1919 
1920  if (check_node_p->reachable)
1921  {
1922  return;
1923  }
1924 
1925  check_node_p->reachable = 1;
1926 
1927  /*
1928  * Mark the node its access spec references. You may need to create
1929  * it if it is a forward reference.
1930  */
1931  for (spec_p = xasl_p->spec_list; spec_p; spec_p = spec_p->next)
1932  {
1933  if (spec_p->type == TARGET_LIST)
1934  {
1935  check_node1_p = qdump_find_check_node_for (ACCESS_SPEC_XASL_NODE (spec_p), chk_nodes);
1936  /* mark as referenced */
1937  if (check_node1_p)
1938  {
1939  check_node1_p->referenced = 1;
1940  }
1941  }
1942  }
1943 
1944  /* recursively check the children of this node */
1945  switch (xasl_p->type)
1946  {
1947  case UNION_PROC:
1948  case DIFFERENCE_PROC:
1949  case INTERSECTION_PROC:
1950  check_node1_p = qdump_find_check_node_for (xasl_p->proc.union_.left, chk_nodes);
1951  if (check_node1_p)
1952  {
1953  check_node1_p->referenced = 1;
1954  }
1955 
1956  check_node1_p = qdump_find_check_node_for (xasl_p->proc.union_.right, chk_nodes);
1957  if (check_node1_p)
1958  {
1959  check_node1_p->referenced = 1;
1960  }
1961  break;
1962 
1963  case MERGELIST_PROC:
1964  check_node1_p = qdump_find_check_node_for (xasl_p->proc.mergelist.inner_xasl, chk_nodes);
1965  if (check_node1_p)
1966  {
1967  check_node1_p->referenced = 1;
1968  }
1969 
1970  check_node1_p = qdump_find_check_node_for (xasl_p->proc.mergelist.inner_xasl, chk_nodes);
1971  if (check_node1_p)
1972  {
1973  check_node1_p->referenced = 1;
1974  }
1975  break;
1976 
1977  case BUILDLIST_PROC:
1978  qdump_check_node (xasl_p->proc.buildlist.eptr_list, chk_nodes);
1979 
1980  default:
1981  break;
1982  }
1983 
1984  qdump_check_node (xasl_p->aptr_list, chk_nodes);
1985  qdump_check_node (xasl_p->bptr_list, chk_nodes);
1986  qdump_check_node (xasl_p->scan_ptr, chk_nodes);
1987  qdump_check_node (xasl_p->dptr_list, chk_nodes);
1988  qdump_check_node (xasl_p->fptr_list, chk_nodes);
1989  qdump_check_node (xasl_p->connect_by_ptr, chk_nodes);
1990  qdump_check_node (xasl_p->next, chk_nodes);
1991 }
1992 
1993 /*
1994  * qdump_print_inconsistencies () -
1995  * return:
1996  * chk_nodes(in):
1997  */
1998 static int
1999 qdump_print_inconsistencies (QDUMP_XASL_CHECK_NODE * chk_nodes[HASH_NUMBER])
2000 {
2001  int i, error = 0;
2002  QDUMP_XASL_CHECK_NODE *check_node_p, *tmp_node_p;
2003 
2004  for (i = 0; i < HASH_NUMBER; i++)
2005  {
2006  for (check_node_p = chk_nodes[i]; check_node_p; check_node_p = check_node_p->next)
2007  {
2008  /* any buildlist procs that are referenced must be reachable */
2009  if (check_node_p->referenced && !check_node_p->reachable)
2010  {
2011  if (!error)
2012  {
2013  fprintf (stdout, "\nSYSTEM ERROR--INCONSISTENT XASL TREE\n\n");
2014  }
2015 
2016  fprintf (stdout, "Referenced node [%lld] is not reachable in the tree\n",
2017  (long long) check_node_p->xasl_addr);
2018  error = 1;
2019  }
2020  }
2021  }
2022 
2023  /* clean up our mallocs */
2024  for (i = 0; i < HASH_NUMBER; i++)
2025  {
2026  for (check_node_p = chk_nodes[i]; check_node_p; /* do nothing */ )
2027  {
2028  tmp_node_p = check_node_p;
2029  check_node_p = check_node_p->next;
2030  free_and_init (tmp_node_p);
2031  }
2032  }
2033 
2034  if (error)
2035  {
2036  fprintf (stdout, "\n");
2037  }
2038 
2039  return !error;
2040 }
2041 #endif /* CUBRID_DEBUG */
2042 
2043 static bool
2045 {
2046  FETCH_PROC_NODE *node_p = &xasl_p->proc.fetch;
2047 
2048  fprintf (foutput, "-->fetch <addr:%p><type:", node_p->arg);
2049  fprintf (foutput, "%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (node_p->arg)));
2050  fprintf (foutput, ">\n fetch_res (%d)\n", (int) node_p->fetch_res);
2051 
2052  if (node_p->set_pred)
2053  {
2054  fprintf (foutput, "-->set predicate:");
2055  qdump_print_predicate (node_p->set_pred);
2056  fprintf (foutput, "\n");
2057  }
2058 
2059  if (node_p->ql_flag)
2060  {
2061  fprintf (foutput, "-->ql_flag on (no null paths)\n");
2062  }
2063 
2064  return true;
2065 }
2066 
2067 static bool
2069 {
2070  BUILDLIST_PROC_NODE *node_p = &xasl_p->proc.buildlist;
2071 
2072  if (xasl_p->outptr_list != NULL)
2073  {
2074  fprintf (foutput, "-->output columns:");
2076  fprintf (foutput, "\n");
2077  }
2078 
2079  if (node_p->g_outptr_list)
2080  {
2081  qdump_print_outlist ("group by output ptrlist", node_p->g_outptr_list);
2082  fprintf (foutput, "\n");
2083  }
2084 
2085  if (node_p->groupby_list)
2086  {
2087  fprintf (foutput, "-->group by list:");
2089  fprintf (foutput, "\n");
2090  }
2091 
2092  if (node_p->g_regu_list)
2093  {
2094  fprintf (foutput, "-->group by regu list:");
2096  fprintf (foutput, "\n");
2097  }
2098 
2099  if (node_p->g_val_list)
2100  {
2101  fprintf (foutput, "-->group by val_list:");
2103  fprintf (foutput, "\n");
2104  }
2105 
2106  if (node_p->g_having_pred)
2107  {
2108  fprintf (foutput, "-->having predicate:");
2110  fprintf (foutput, "\n");
2111  }
2112 
2113  if (node_p->g_grbynum_val)
2114  {
2115  fprintf (foutput, "-->grbynum val:");
2116  fprintf (foutput, "<addr:%p|", node_p->g_grbynum_val);
2117  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (node_p->g_grbynum_val)));
2118  fprintf (foutput, "|value:");
2120  fprintf (foutput, ">\n");
2121  }
2122 
2123  if (node_p->g_grbynum_pred)
2124  {
2125  fprintf (foutput, "-->grbynum predicate:");
2127  fprintf (foutput, "\n");
2128 
2130  {
2131  fprintf (foutput, "-->grbynum CONTINUE\n");
2132  }
2133  }
2134 
2135  if (node_p->g_agg_list)
2136  {
2137  fprintf (foutput, "-->having agg list:");
2138  qdump_print_arith (AGG_EXP, (void *) node_p->g_agg_list);
2139  fprintf (foutput, "\n");
2140  }
2141 
2142  if (node_p->eptr_list)
2143  {
2144  fprintf (foutput, "-->EPTR LIST:%p\n", node_p->eptr_list);
2145  }
2146 
2147  if (node_p->g_with_rollup)
2148  {
2149  fprintf (foutput, "-->WITH ROLLUP\n");
2150  }
2151 
2152  return true;
2153 }
2154 
2155 static bool
2157 {
2158  BUILDVALUE_PROC_NODE *node_p = &xasl_p->proc.buildvalue;
2159  if (xasl_p->proc.buildvalue.having_pred)
2160  {
2161  fprintf (foutput, "-->having predicate:");
2163  fprintf (foutput, "\n");
2164  }
2165 
2166  if (node_p->grbynum_val)
2167  {
2168  fprintf (foutput, "-->grbynum val:");
2169  fprintf (foutput, "<addr:%p|", node_p->grbynum_val);
2170  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (node_p->grbynum_val)));
2171  fprintf (foutput, "|value:");
2173  fprintf (foutput, ">\n");
2174  }
2175 
2176  if (node_p->agg_list)
2177  {
2178  fprintf (foutput, "-->agg list:");
2179  qdump_print_arith (AGG_EXP, (void *) node_p->agg_list);
2180  fprintf (foutput, "\n");
2181  }
2182 
2183  if (node_p->outarith_list)
2184  {
2185  fprintf (foutput, "-->outarith list:");
2186  qdump_print_arith (ARITH_EXP, (void *) node_p->outarith_list);
2187  }
2188 
2189  if (node_p->is_always_false)
2190  {
2191  fprintf (foutput, "-->always-false\n");
2192  }
2193 
2194  return true;
2195 }
2196 
2197 static bool
2199 {
2200  CONNECTBY_PROC_NODE *node_p = &xasl_p->proc.connect_by;
2201 
2202  if (node_p->start_with_pred)
2203  {
2204  fprintf (foutput, "-->start with predicate:");
2206  fprintf (foutput, "\n");
2207  }
2208 
2209  if (node_p->after_connect_by_pred)
2210  {
2211  fprintf (foutput, "-->after connect by predicate:");
2213  fprintf (foutput, "\n");
2214  }
2215 
2216  if (node_p->input_list_id)
2217  {
2218  fprintf (foutput, "-->input list id:");
2220  fprintf (foutput, "\n");
2221  }
2222 
2223  if (node_p->start_with_list_id)
2224  {
2225  fprintf (foutput, "-->start with list id:");
2227  fprintf (foutput, "\n");
2228  }
2229 
2230  if (node_p->regu_list_pred)
2231  {
2232  fprintf (foutput, "-->connect by regu list pred:");
2234  fprintf (foutput, "\n");
2235  }
2236 
2237  if (node_p->regu_list_rest)
2238  {
2239  fprintf (foutput, "-->connect by regu list rest:");
2241  fprintf (foutput, "\n");
2242  }
2243 
2244  if (node_p->prior_val_list)
2245  {
2246  fprintf (foutput, "-->prior val list:");
2248  fprintf (foutput, "\n");
2249  }
2250 
2251  if (node_p->prior_outptr_list)
2252  {
2253  qdump_print_outlist ("prior output ptrlist", node_p->prior_outptr_list);
2254  fprintf (foutput, "\n");
2255  }
2256 
2257  if (node_p->prior_regu_list_pred)
2258  {
2259  fprintf (foutput, "-->prior regu list pred:");
2261  fprintf (foutput, "\n");
2262  }
2263 
2264  if (node_p->prior_regu_list_rest)
2265  {
2266  fprintf (foutput, "-->prior regu list rest:");
2268  fprintf (foutput, "\n");
2269  }
2270 
2271  if (node_p->after_cb_regu_list_pred)
2272  {
2273  fprintf (foutput, "-->after connect by regu list pred:");
2275  fprintf (foutput, "\n");
2276  }
2277 
2278  if (node_p->after_cb_regu_list_rest)
2279  {
2280  fprintf (foutput, "-->after connect by regu list rest:");
2282  fprintf (foutput, "\n");
2283  }
2284 
2285  return true;
2286 }
2287 
2288 /*
2289  * qdump_print_xasl () -
2290  * return:
2291  * xasl(in):
2292  */
2293 bool
2295 {
2296  VAL_LIST *single_tuple_p;
2297  QPROC_DB_VALUE_LIST value_list;
2298  int i;
2299 
2300  if (xasl_p == NULL)
2301  {
2302  return true;
2303  }
2304 
2305  fprintf (foutput, "\n<start of xasl structure %p>\n", xasl_p);
2306  qdump_print_xasl_type (xasl_p);
2307 
2308  if (xasl_p->flag)
2309  {
2310  int save_flag, nflag;
2311 
2312  save_flag = xasl_p->flag;
2313  nflag = 0;
2314 
2315  fprintf (foutput, "-->[flag=");
2316 
2318  {
2320  fprintf (foutput, "%sXASL_LINK_TO_REGU_VARIABLE", (nflag ? "|" : ""));
2321  nflag++;
2322  }
2323 
2324  if (XASL_IS_FLAGED (xasl_p, XASL_SKIP_ORDERBY_LIST))
2325  {
2327  fprintf (foutput, "%sXASL_SKIP_ORDERBY_LIST", (nflag ? "|" : ""));
2328  nflag++;
2329  }
2330 
2331  if (XASL_IS_FLAGED (xasl_p, XASL_ZERO_CORR_LEVEL))
2332  {
2334  fprintf (foutput, "%sXASL_ZERO_CORR_LEVEL", (nflag ? "|" : ""));
2335  nflag++;
2336  }
2337 
2338  if (XASL_IS_FLAGED (xasl_p, XASL_TOP_MOST_XASL))
2339  {
2341  fprintf (foutput, "%sXASL_TOP_MOST_XASL", (nflag ? "|" : ""));
2342  nflag++;
2343  }
2344 
2345  if (xasl_p->flag)
2346  {
2347  fprintf (foutput, "%d%s", xasl_p->flag, (nflag ? "|" : ""));
2348  nflag++;
2349  }
2350 
2351  fprintf (foutput, "]\n");
2352 
2353  xasl_p->flag = save_flag;
2354  }
2355 
2356  if (xasl_p->next)
2357  {
2358  fprintf (foutput, "-->next:%p\n", xasl_p->next);
2359  }
2360 
2361  if (xasl_p->list_id)
2362  {
2363  fprintf (foutput, "-->list id:");
2364  qdump_print_list_id (xasl_p->list_id);
2365  fprintf (foutput, "\n");
2366  }
2367 
2368  if (xasl_p->orderby_list)
2369  {
2370  fprintf (foutput, "-->order by list:");
2372  fprintf (foutput, "\n");
2373  }
2374 
2375  if (xasl_p->ordbynum_val)
2376  {
2377  fprintf (foutput, "-->ordbynum val:");
2378  fprintf (foutput, "<addr:%p|", xasl_p->ordbynum_val);
2379  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (xasl_p->ordbynum_val)));
2380  fprintf (foutput, "|value:");
2382  fprintf (foutput, ">\n");
2383  }
2384 
2385  if (xasl_p->ordbynum_pred)
2386  {
2387  fprintf (foutput, "-->ordbynum predicate:");
2389  fprintf (foutput, "\n");
2391  fprintf (foutput, "-->ordbynum CONTINUE\n");
2392  }
2393 
2394  if (xasl_p->orderby_limit)
2395  {
2396  fprintf (foutput, "-->orderby limit:");
2397  qdump_print_value (xasl_p->orderby_limit);
2398  fprintf (foutput, " (optimization %s)",
2399  prm_get_bool_value (PRM_ID_USE_ORDERBY_SORT_LIMIT) ? "enabled" : "disabled");
2400  fprintf (foutput, "\n");
2401  }
2402 
2403  if (xasl_p->is_single_tuple)
2404  {
2405  fprintf (foutput, "-->single tuple:");
2406  single_tuple_p = xasl_p->single_tuple;
2407  if (single_tuple_p)
2408  {
2409  fprintf (foutput, "[value list]:");
2410  for (value_list = single_tuple_p->valp, i = 0; i < single_tuple_p->val_cnt;
2411  value_list = value_list->next, i++)
2412  {
2413  qdump_print_db_value (value_list->val);
2414  fprintf (foutput, "\t");
2415  }
2416  }
2417  fprintf (foutput, "\n");
2418  }
2419 
2420  if (xasl_p->option == Q_DISTINCT)
2421  {
2422  fprintf (foutput, "-->query DISTINCT\n");
2423  }
2424 
2425  if (xasl_p->outptr_list)
2426  {
2427  qdump_print_outlist ("outptr list", xasl_p->outptr_list);
2428  fprintf (foutput, "\n");
2429  }
2430 
2431  if (xasl_p->spec_list)
2432  {
2433  fprintf (foutput, "-->access spec:");
2435  fprintf (foutput, "\n");
2436  }
2437 
2438  if (xasl_p->merge_spec)
2439  {
2440  fprintf (foutput, "-->merge spec:");
2442  fprintf (foutput, "\n");
2443  }
2444 
2445  if (xasl_p->val_list)
2446  {
2447  fprintf (foutput, "-->val_list:");
2448  qdump_print_value_list (xasl_p->val_list);
2449  fprintf (foutput, "\n");
2450  }
2451 
2452  if (xasl_p->aptr_list)
2453  {
2454  fprintf (foutput, "-->aptr list:%p\n", xasl_p->aptr_list);
2455  }
2456 
2457  if (xasl_p->bptr_list)
2458  {
2459  fprintf (foutput, "-->bptr list:%p\n", xasl_p->bptr_list);
2460  }
2461 
2462  if (xasl_p->scan_ptr)
2463  {
2464  fprintf (foutput, "-->scan ptr:%p\n", xasl_p->scan_ptr);
2465  }
2466 
2467  if (xasl_p->dptr_list)
2468  {
2469  fprintf (foutput, "-->dptr list:%p\n", xasl_p->dptr_list);
2470  }
2471 
2472  if (xasl_p->fptr_list)
2473  {
2474  fprintf (foutput, "-->fptr list:%p\n", xasl_p->fptr_list);
2475  }
2476 
2477  if (xasl_p->connect_by_ptr)
2478  {
2479  fprintf (foutput, "-->connect_by ptr:%p\n", xasl_p->connect_by_ptr);
2480  }
2481 
2482  if (xasl_p->after_join_pred)
2483  {
2484  fprintf (foutput, "-->after_join predicate:");
2486  fprintf (foutput, "\n");
2487  }
2488 
2489  if (xasl_p->if_pred)
2490  {
2491  fprintf (foutput, "-->if predicate:");
2492  qdump_print_predicate (xasl_p->if_pred);
2493  fprintf (foutput, "\n");
2494  }
2495 
2496  if (xasl_p->instnum_val)
2497  {
2498  fprintf (foutput, "-->instnum val:");
2499  fprintf (foutput, "<addr:%p|", xasl_p->instnum_val);
2500  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (xasl_p->instnum_val)));
2501  fprintf (foutput, "|value:");
2503  fprintf (foutput, ">\n");
2504  }
2505 
2506  if (xasl_p->save_instnum_val)
2507  {
2508  fprintf (foutput, "-->old instnum val:");
2509  fprintf (foutput, "<addr:%p|", xasl_p->save_instnum_val);
2510  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (xasl_p->save_instnum_val)));
2511  fprintf (foutput, "|value:");
2513  fprintf (foutput, ">\n");
2514  }
2515 
2516  if (xasl_p->instnum_pred)
2517  {
2518  fprintf (foutput, "-->instnum predicate:");
2520  fprintf (foutput, "\n");
2522  {
2523  fprintf (foutput, "-->instnum CONTINUE\n");
2524  }
2525  }
2526 
2527  if (xasl_p->level_val)
2528  {
2529  fprintf (foutput, "-->level val:");
2530  fprintf (foutput, "<addr:%p|", xasl_p->level_val);
2531  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (xasl_p->level_val)));
2532  fprintf (foutput, "|value:");
2533  qdump_print_db_value (xasl_p->level_val);
2534  fprintf (foutput, ">\n");
2535  }
2536 
2537  if (xasl_p->level_regu)
2538  {
2539  fprintf (foutput, "-->level regu:");
2540  qdump_print_value (xasl_p->level_regu);
2541  fprintf (foutput, "\n");
2542  }
2543 
2544  if (xasl_p->isleaf_val)
2545  {
2546  fprintf (foutput, "-->isleaf val:");
2547  fprintf (foutput, "<addr:%p|", xasl_p->isleaf_val);
2548  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (xasl_p->isleaf_val)));
2549  fprintf (foutput, "|value:");
2550  qdump_print_db_value (xasl_p->isleaf_val);
2551  fprintf (foutput, ">\n");
2552  }
2553 
2554  if (xasl_p->isleaf_regu)
2555  {
2556  fprintf (foutput, "-->isleaf regu:");
2557  qdump_print_value (xasl_p->isleaf_regu);
2558  fprintf (foutput, "\n");
2559  }
2560 
2561  if (xasl_p->iscycle_val)
2562  {
2563  fprintf (foutput, "-->iscycle val:");
2564  fprintf (foutput, "<addr:%p|", xasl_p->iscycle_val);
2565  fprintf (foutput, "type:%s", qdump_data_type_string (DB_VALUE_DOMAIN_TYPE (xasl_p->iscycle_val)));
2566  fprintf (foutput, "|value:");
2568  fprintf (foutput, ">\n");
2569  }
2570 
2571  if (xasl_p->iscycle_regu)
2572  {
2573  fprintf (foutput, "-->iscycle regu:");
2574  qdump_print_value (xasl_p->iscycle_regu);
2575  fprintf (foutput, "\n");
2576  }
2577 
2578  fprintf (foutput, "-->current spec:");
2580  fprintf (foutput, "\n");
2581  fprintf (foutput, "-->[next scan on=%d]", xasl_p->next_scan_on);
2582  fprintf (foutput, "[next scan block on=%d]", xasl_p->next_scan_block_on);
2583  fprintf (foutput, "-->[cat fetched=%d]", xasl_p->cat_fetched);
2584  fprintf (foutput, "\n");
2585 
2586  switch (xasl_p->type)
2587  {
2588  case OBJFETCH_PROC:
2589  qdump_print_fetch_node (xasl_p);
2590  break;
2591 
2592  case BUILDLIST_PROC:
2593  qdump_print_build_list_node (xasl_p);
2594  break;
2595 
2596  case BUILDVALUE_PROC:
2598  break;
2599 
2600  case UNION_PROC:
2601  case DIFFERENCE_PROC:
2602  case INTERSECTION_PROC:
2603  fprintf (foutput, "left xasl:%p\n", xasl_p->proc.union_.left);
2604  fprintf (foutput, "right xasl:%p\n", xasl_p->proc.union_.right);
2605  break;
2606 
2607  case MERGELIST_PROC:
2608  fprintf (foutput, "inner xasl:%p\n", xasl_p->proc.mergelist.inner_xasl);
2609  fprintf (foutput, "outer xasl:%p\n", xasl_p->proc.mergelist.outer_xasl);
2611  break;
2612 
2613  case CONNECTBY_PROC:
2615  break;
2616 
2617  case SCAN_PROC:
2618  break;
2619 
2620  case UPDATE_PROC:
2621  fprintf (foutput, "-->update info:");
2623  fprintf (foutput, "\n");
2624  break;
2625 
2626  case DELETE_PROC:
2627  fprintf (foutput, "-->delete info:");
2629  fprintf (foutput, "\n");
2630  break;
2631 
2632  case INSERT_PROC:
2633  fprintf (foutput, "-->insert info:");
2635  fprintf (foutput, "\n");
2636  break;
2637 
2638  case MERGE_PROC:
2639  fprintf (foutput, "-->merge info:");
2640  if (xasl_p->proc.merge.update_xasl)
2641  {
2642  fprintf (foutput, "\n---->update:");
2644  fprintf (foutput, "\n");
2645  }
2646  if (xasl_p->proc.merge.insert_xasl)
2647  {
2648  fprintf (foutput, "\n---->insert:");
2650  fprintf (foutput, "\n");
2651  }
2652  break;
2653 
2654  case CTE_PROC:
2655  fprintf (foutput, "non_recursive_part xasl:%p\n", xasl_p->proc.cte.non_recursive_part);
2656  fprintf (foutput, "recursive_part xasl:%p\n", xasl_p->proc.cte.recursive_part);
2657  /* TODO - dump anchor and recursive part of CTE when we need */
2658  break;
2659 
2660  default:
2661  return false;
2662  }
2663 
2664  fprintf (foutput, "end of internals of ");
2665  qdump_print_xasl_type (xasl_p);
2666  qdump_print_xasl (xasl_p->aptr_list);
2667  qdump_print_xasl (xasl_p->bptr_list);
2668  qdump_print_xasl (xasl_p->scan_ptr);
2669  qdump_print_xasl (xasl_p->dptr_list);
2670  qdump_print_xasl (xasl_p->fptr_list);
2671  qdump_print_xasl (xasl_p->connect_by_ptr);
2672 
2673  if (xasl_p->type == BUILDLIST_PROC)
2674  {
2676  }
2677 
2678  qdump_print_xasl (xasl_p->next);
2679  fprintf (foutput, "creator OID:");
2680  qdump_print_oid (&xasl_p->creator_oid);
2681 
2682  fprintf (foutput, "\nclass/serial OID, #pages list:%d ", xasl_p->n_oid_list);
2683  for (i = 0; i < xasl_p->n_oid_list; ++i)
2684  {
2685  qdump_print_oid (&xasl_p->class_oid_list[i]);
2686  fprintf (foutput, "/%s ", LOCK_TO_LOCKMODE_STRING (xasl_p->class_locks[i]));
2687  fprintf (foutput, "/%d ", xasl_p->tcard_list[i]);
2688  }
2689 
2690  fprintf (foutput, "\ndbval_cnt:%d", xasl_p->dbval_cnt);
2691  fprintf (foutput, "\nquery_alias:%s\n", xasl_p->query_alias ? xasl_p->query_alias : "(NULL)");
2692  fprintf (foutput, "<end of xasl structure %p>\n", xasl_p);
2693  fflush (foutput);
2694 
2695  return true;
2696 }
2697 
2698 /*
2699  * query trace dump for profile
2700  */
2701 
2702 #if defined (SERVER_MODE)
2703 
2704 /*
2705  * qdump_xasl_type_string () -
2706  * return:
2707  * xasl_p(in):
2708  */
2709 static const char *
2710 qdump_xasl_type_string (XASL_NODE * xasl_p)
2711 {
2712  switch (xasl_p->type)
2713  {
2714  case BUILDLIST_PROC:
2715  case BUILDVALUE_PROC:
2716  return "SELECT";
2717  case SCAN_PROC:
2718  return "SCAN";
2719  case INSERT_PROC:
2720  return "INSERT";
2721  case UPDATE_PROC:
2722  return "UPDATE";
2723  case DELETE_PROC:
2724  return "DELETE";
2725  case MERGE_PROC:
2726  return "MERGE";
2727  case UNION_PROC:
2728  return "UNION";
2729  case DIFFERENCE_PROC:
2730  return "DIFFERENCE";
2731  case INTERSECTION_PROC:
2732  return "INTERSECTION";
2733  case MERGELIST_PROC:
2734  return "MERGELIST";
2735  case CONNECTBY_PROC:
2736  return "CONNECTBY";
2737  case OBJFETCH_PROC:
2738  return "OBJFETCH";
2739  case BUILD_SCHEMA_PROC:
2740  return "SCHEMA";
2741  case DO_PROC:
2742  return "DO";
2743  case CTE_PROC:
2744  return "CTE";
2745  default:
2746  assert (false);
2747  return "";
2748  }
2749 }
2750 
2751 /*
2752  * qdump_print_access_spec_stats () -
2753  * return:
2754  * spec_list_p(in):
2755  * proc(in):
2756  */
2757 static json_t *
2758 qdump_print_access_spec_stats_json (ACCESS_SPEC_TYPE * spec_list_p)
2759 {
2760  TARGET_TYPE type;
2761  char *class_name = NULL, *index_name = NULL;
2762  CLS_SPEC_TYPE *cls_node;
2763  ACCESS_SPEC_TYPE *spec;
2764  json_t *scan = NULL, *scan_array = NULL;
2765  int num_spec = 0;
2766  char spec_name[1024];
2767  THREAD_ENTRY *thread_p;
2768 
2769  thread_p = thread_get_thread_entry_info ();
2770 
2771  for (spec = spec_list_p; spec != NULL; spec = spec->next)
2772  {
2773  num_spec++;
2774  }
2775 
2776  if (num_spec > 1)
2777  {
2778  scan_array = json_array ();
2779  }
2780 
2781  for (spec = spec_list_p; spec != NULL; spec = spec->next)
2782  {
2783  scan = json_object ();
2784  type = spec->type;
2785 
2786  if (type == TARGET_CLASS)
2787  {
2788  cls_node = &ACCESS_SPEC_CLS_SPEC (spec);
2789  if (heap_get_class_name (thread_p, &(cls_node->cls_oid), &class_name) != NO_ERROR)
2790  {
2791  /* ignore */
2792  er_clear ();
2793  }
2794 
2795  spec_name[0] = '\0';
2796 
2797  if (spec->access == ACCESS_METHOD_SEQUENTIAL)
2798  {
2799  if (class_name != NULL)
2800  {
2801  sprintf (spec_name, "table (%s)", class_name);
2802  }
2803  else
2804  {
2805  sprintf (spec_name, "table (unknown)");
2806  }
2807  }
2808  else if (spec->access == ACCESS_METHOD_INDEX)
2809  {
2810  if (heap_get_indexinfo_of_btid (thread_p, &cls_node->cls_oid, &spec->indexptr->btid, NULL, NULL, NULL,
2811  NULL, &index_name, NULL) == NO_ERROR)
2812  {
2813  if (class_name != NULL && index_name != NULL)
2814  {
2815  sprintf (spec_name, "index (%s.%s)", class_name, index_name);
2816  }
2817  else
2818  {
2819  sprintf (spec_name, "index (unknown)");
2820  }
2821  }
2822  }
2823 
2824  json_object_set_new (scan, "access", json_string (spec_name));
2825 
2826  if (class_name != NULL)
2827  {
2828  free_and_init (class_name);
2829  }
2830  if (index_name != NULL)
2831  {
2832  free_and_init (index_name);
2833  }
2834  }
2835  else if (type == TARGET_LIST)
2836  {
2837  json_object_set_new (scan, "access", json_string ("temp"));
2838  }
2839  else if (type == TARGET_SHOWSTMT)
2840  {
2841  json_object_set_new (scan, "access", json_string ("show"));
2842  }
2843  else if (type == TARGET_SET)
2844  {
2845  json_object_set_new (scan, "access", json_string ("set"));
2846  }
2847  else if (type == TARGET_METHOD)
2848  {
2849  json_object_set_new (scan, "access", json_string ("method"));
2850  }
2851  else if (type == TARGET_CLASS_ATTR)
2852  {
2853  json_object_set_new (scan, "access", json_string ("class_attr"));
2854  }
2855 
2856  scan_print_stats_json (&spec->s_id, scan);
2857 
2858  if (scan_array != NULL)
2859  {
2860  json_array_append_new (scan_array, scan);
2861  }
2862  }
2863 
2864  if (scan_array != NULL)
2865  {
2866  return scan_array;
2867  }
2868  else
2869  {
2870  return scan;
2871  }
2872 }
2873 
2874 /*
2875  * qdump_print_stats_json () -
2876  * return:
2877  * xasl_p(in):
2878  */
2879 void
2880 qdump_print_stats_json (xasl_node * xasl_p, json_t * parent)
2881 {
2882  ORDERBY_STATS *ostats;
2883  GROUPBY_STATS *gstats;
2884  json_t *proc, *scan = NULL;
2885  json_t *subquery, *groupby, *orderby;
2886  json_t *left, *right, *outer, *inner;
2887  json_t *cte_non_recursive_part, *cte_recursive_part;
2888 
2889  if (xasl_p == NULL || parent == NULL)
2890  {
2891  return;
2892  }
2893 
2894  if (xasl_p->type == SCAN_PROC)
2895  {
2896  proc = parent;
2897  }
2898  else
2899  {
2900  proc = json_object ();
2901  json_object_set_new (parent, qdump_xasl_type_string (xasl_p), proc);
2902  }
2903 
2904  switch (xasl_p->type)
2905  {
2906  case BUILDLIST_PROC:
2907  case BUILDVALUE_PROC:
2908  case UPDATE_PROC:
2909  case DELETE_PROC:
2910  case INSERT_PROC:
2911  case CONNECTBY_PROC:
2912  case BUILD_SCHEMA_PROC:
2913  json_object_set_new (proc, "time", json_integer (TO_MSEC (xasl_p->xasl_stats.elapsed_time)));
2914  json_object_set_new (proc, "fetch", json_integer (xasl_p->xasl_stats.fetches));
2915  json_object_set_new (proc, "ioread", json_integer (xasl_p->xasl_stats.ioreads));
2916  break;
2917 
2918  case UNION_PROC:
2919  case DIFFERENCE_PROC:
2920  case INTERSECTION_PROC:
2921  left = json_object ();
2922  right = json_object ();
2923 
2924  qdump_print_stats_json (xasl_p->proc.union_.left, left);
2925  qdump_print_stats_json (xasl_p->proc.union_.right, right);
2926 
2927  json_object_set_new (proc, "left", left);
2928  json_object_set_new (proc, "right", right);
2929  break;
2930 
2931  case MERGELIST_PROC:
2932  outer = json_object ();
2933  inner = json_object ();
2934 
2935  qdump_print_stats_json (xasl_p->proc.mergelist.outer_xasl, outer);
2936  qdump_print_stats_json (xasl_p->proc.mergelist.inner_xasl, inner);
2937 
2938  json_object_set_new (proc, "outer", outer);
2939  json_object_set_new (proc, "inner", inner);
2940  break;
2941 
2942  case MERGE_PROC:
2943  inner = json_object ();
2944  outer = json_object ();
2945 
2946  qdump_print_stats_json (xasl_p->proc.merge.update_xasl, inner);
2947  qdump_print_stats_json (xasl_p->proc.merge.insert_xasl, outer);
2948 
2949  json_object_set_new (proc, "update", inner);
2950  json_object_set_new (proc, "insert", outer);
2951  break;
2952 
2953  case CTE_PROC:
2954  cte_non_recursive_part = json_object ();
2955  qdump_print_stats_json (xasl_p->proc.cte.non_recursive_part, cte_non_recursive_part);
2956  json_object_set_new (proc, "non_recursive_part", cte_non_recursive_part);
2957 
2958  if (xasl_p->proc.cte.recursive_part != NULL)
2959  {
2960  cte_recursive_part = json_object ();
2961  qdump_print_stats_json (xasl_p->proc.cte.recursive_part, cte_recursive_part);
2962  json_object_set_new (proc, "recursive_part", cte_recursive_part);
2963  }
2964  break;
2965 
2966  case SCAN_PROC:
2967  case OBJFETCH_PROC:
2968  default:
2969  break;
2970  }
2971 
2972  if (xasl_p->spec_list != NULL)
2973  {
2974  scan = qdump_print_access_spec_stats_json (xasl_p->spec_list);
2975  }
2976  else if (xasl_p->merge_spec != NULL)
2977  {
2978  scan = qdump_print_access_spec_stats_json (xasl_p->merge_spec);
2979  }
2980 
2981  if (scan != NULL)
2982  {
2983  json_object_set_new (proc, "SCAN", scan);
2984  qdump_print_stats_json (xasl_p->scan_ptr, scan);
2985  }
2986  else
2987  {
2988  qdump_print_stats_json (xasl_p->scan_ptr, proc);
2989  }
2990 
2991  qdump_print_stats_json (xasl_p->connect_by_ptr, proc);
2992 
2993  gstats = &xasl_p->groupby_stats;
2994  if (gstats->run_groupby)
2995  {
2996  groupby = json_object ();
2997 
2998  json_object_set_new (groupby, "time", json_integer (TO_MSEC (gstats->groupby_time)));
2999 
3000  if (gstats->groupby_hash == HS_ACCEPT_ALL)
3001  {
3002  json_object_set_new (groupby, "hash", json_true ());
3003  }
3004  else if (gstats->groupby_hash == HS_REJECT_ALL)
3005  {
3006  json_object_set_new (groupby, "hash", json_string ("partial"));
3007  }
3008  else
3009  {
3010  json_object_set_new (groupby, "hash", json_false ());
3011  }
3012 
3013  if (gstats->groupby_sort)
3014  {
3015  json_object_set_new (groupby, "sort", json_true ());
3016  json_object_set_new (groupby, "page", json_integer (gstats->groupby_pages));
3017  json_object_set_new (groupby, "ioread", json_integer (gstats->groupby_ioreads));
3018  }
3019  else
3020  {
3021  json_object_set_new (groupby, "sort", json_false ());
3022  }
3023 
3024  json_object_set_new (groupby, "rows", json_integer (gstats->rows));
3025  json_object_set_new (proc, "GROUPBY", groupby);
3026  }
3027 
3028  ostats = &xasl_p->orderby_stats;
3029  if (ostats->orderby_filesort || ostats->orderby_topnsort || XASL_IS_FLAGED (xasl_p, XASL_SKIP_ORDERBY_LIST))
3030  {
3031  orderby = json_object ();
3032 
3033  json_object_set_new (orderby, "time", json_integer (TO_MSEC (ostats->orderby_time)));
3034 
3035  if (ostats->orderby_filesort)
3036  {
3037  json_object_set_new (orderby, "sort", json_true ());
3038  json_object_set_new (orderby, "page", json_integer (ostats->orderby_pages));
3039  json_object_set_new (orderby, "ioread", json_integer (ostats->orderby_ioreads));
3040  }
3041  else if (ostats->orderby_topnsort)
3042  {
3043  json_object_set_new (orderby, "topnsort", json_true ());
3044  }
3045  else
3046  {
3047  json_object_set_new (orderby, "skipsort", json_true ());
3048  }
3049 
3050  json_object_set_new (proc, "ORDERBY", orderby);
3051  }
3052 
3053  if (HAVE_SUBQUERY_PROC (xasl_p) && xasl_p->aptr_list != NULL)
3054  {
3055  if (HAVE_SUBQUERY_PROC (xasl_p->aptr_list))
3056  {
3057  subquery = json_object ();
3058  qdump_print_stats_json (xasl_p->aptr_list, subquery);
3059  json_object_set_new (proc, "SUBQUERY (uncorrelated)", subquery);
3060  }
3061  else
3062  {
3063  qdump_print_stats_json (xasl_p->aptr_list, proc);
3064  }
3065  }
3066 
3067  if (xasl_p->dptr_list != NULL)
3068  {
3069  subquery = json_object ();
3070  qdump_print_stats_json (xasl_p->dptr_list, subquery);
3071  json_object_set_new (proc, "SUBQUERY (correlated)", subquery);
3072  }
3073 }
3074 
3075 /*
3076  * qdump_print_access_spec_stats_text () -
3077  * return:
3078  * fp(in):
3079  * spec_list_p(in):
3080  */
3081 static void
3082 qdump_print_access_spec_stats_text (FILE * fp, ACCESS_SPEC_TYPE * spec_list_p, int indent)
3083 {
3084  TARGET_TYPE type;
3085  char *class_name = NULL, *index_name = NULL;
3086  CLS_SPEC_TYPE *cls_node;
3087  ACCESS_SPEC_TYPE *spec;
3088  int i, multi_spec_indent;
3089  THREAD_ENTRY *thread_p;
3090 
3091  if (spec_list_p == NULL)
3092  {
3093  return;
3094  }
3095 
3096  thread_p = thread_get_thread_entry_info ();
3097 
3098  multi_spec_indent = fprintf (fp, "%*cSCAN ", indent, ' ');
3099 
3100  for (spec = spec_list_p, i = 0; spec != NULL; spec = spec->next, i++)
3101  {
3102  if (i > 0)
3103  {
3104  fprintf (fp, "%*c", multi_spec_indent, ' ');
3105  }
3106 
3107  type = spec->type;
3108  if (type == TARGET_CLASS)
3109  {
3110  cls_node = &ACCESS_SPEC_CLS_SPEC (spec);
3111  if (heap_get_class_name (thread_p, &(cls_node->cls_oid), &class_name) != NO_ERROR)
3112  {
3113  /* ignore */
3114  er_clear ();
3115  }
3116 
3117  if (spec->access == ACCESS_METHOD_SEQUENTIAL)
3118  {
3119  if (class_name != NULL)
3120  {
3121  fprintf (fp, "(table: %s), ", class_name);
3122  }
3123  else
3124  {
3125  fprintf (fp, "(table: unknown), ");
3126  }
3127  }
3128  else if (spec->access == ACCESS_METHOD_INDEX)
3129  {
3130  if (heap_get_indexinfo_of_btid (thread_p, &cls_node->cls_oid, &spec->indexptr->btid, NULL, NULL, NULL,
3131  NULL, &index_name, NULL) == NO_ERROR)
3132  {
3133  if (class_name != NULL && index_name != NULL)
3134  {
3135  fprintf (fp, "(index: %s.%s), ", class_name, index_name);
3136  }
3137  else
3138  {
3139  fprintf (fp, "(index: unknown), ");
3140  }
3141  }
3142  }
3143 
3144  scan_print_stats_text (fp, &spec->s_id);
3145 
3146  if (class_name != NULL)
3147  {
3148  free_and_init (class_name);
3149  }
3150  if (index_name != NULL)
3151  {
3152  free_and_init (index_name);
3153  }
3154  }
3155  else
3156  {
3157  scan_print_stats_text (fp, &spec->s_id);
3158  }
3159 
3160  fprintf (fp, "\n");
3161  }
3162 
3163  return;
3164 }
3165 
3166 /*
3167  * qdump_print_stats_text () -
3168  * return:
3169  * fp(in):
3170  * xasl_p(in):
3171  * indent(in):
3172  */
3173 void
3174 qdump_print_stats_text (FILE * fp, xasl_node * xasl_p, int indent)
3175 {
3176  ORDERBY_STATS *ostats;
3177  GROUPBY_STATS *gstats;
3178 
3179  if (xasl_p == NULL)
3180  {
3181  return;
3182  }
3183 
3184  if (xasl_p->type != CONNECTBY_PROC)
3185  {
3186  indent += 2;
3187  }
3188 
3189  if (xasl_p->type != SCAN_PROC)
3190  {
3191  fprintf (fp, "%*c", indent, ' ');
3192  }
3193 
3194  switch (xasl_p->type)
3195  {
3196  case BUILDLIST_PROC:
3197  case BUILDVALUE_PROC:
3198  case INSERT_PROC:
3199  case UPDATE_PROC:
3200  case DELETE_PROC:
3201  case CONNECTBY_PROC:
3202  case BUILD_SCHEMA_PROC:
3203  fprintf (fp, "%s (time: %d, fetch: %lld, ioread: %lld)\n", qdump_xasl_type_string (xasl_p),
3204  TO_MSEC (xasl_p->xasl_stats.elapsed_time), (long long int) xasl_p->xasl_stats.fetches,
3205  (long long int) xasl_p->xasl_stats.ioreads);
3206  indent += 2;
3207  break;
3208 
3209  case UNION_PROC:
3210  fprintf (fp, "UNION\n");
3211  qdump_print_stats_text (fp, xasl_p->proc.union_.left, indent);
3212  qdump_print_stats_text (fp, xasl_p->proc.union_.right, indent);
3213  break;
3214  case DIFFERENCE_PROC:
3215  fprintf (fp, "DIFFERENCE\n");
3216  qdump_print_stats_text (fp, xasl_p->proc.union_.left, indent);
3217  qdump_print_stats_text (fp, xasl_p->proc.union_.right, indent);
3218  break;
3219  case INTERSECTION_PROC:
3220  fprintf (fp, "INTERSECTION\n");
3221  qdump_print_stats_text (fp, xasl_p->proc.union_.left, indent);
3222  qdump_print_stats_text (fp, xasl_p->proc.union_.right, indent);
3223  break;
3224 
3225  case MERGELIST_PROC:
3226  fprintf (fp, "MERGELIST\n");
3227  qdump_print_stats_text (fp, xasl_p->proc.mergelist.outer_xasl, indent);
3228  qdump_print_stats_text (fp, xasl_p->proc.mergelist.inner_xasl, indent);
3229  break;
3230 
3231  case MERGE_PROC:
3232  fprintf (fp, "MERGE\n");
3233  qdump_print_stats_text (fp, xasl_p->proc.merge.update_xasl, indent);
3234  qdump_print_stats_text (fp, xasl_p->proc.merge.insert_xasl, indent);
3235  break;
3236 
3237  case CTE_PROC:
3238  fprintf (fp, "CTE (non_recursive_part)\n");
3239  qdump_print_stats_text (fp, xasl_p->proc.cte.non_recursive_part, indent);
3240  if (xasl_p->proc.cte.recursive_part != NULL)
3241  {
3242  fprintf (fp, "%*c", indent, ' ');
3243  fprintf (fp, "CTE (recursive_part)\n");
3244  qdump_print_stats_text (fp, xasl_p->proc.cte.recursive_part, indent);
3245  }
3246  break;
3247 
3248  case SCAN_PROC:
3249  case OBJFETCH_PROC:
3250  default:
3251  break;
3252  }
3253 
3254  qdump_print_access_spec_stats_text (fp, xasl_p->spec_list, indent);
3255  qdump_print_access_spec_stats_text (fp, xasl_p->merge_spec, indent);
3256 
3257  qdump_print_stats_text (fp, xasl_p->scan_ptr, indent);
3258  qdump_print_stats_text (fp, xasl_p->connect_by_ptr, indent);
3259 
3260  gstats = &xasl_p->groupby_stats;
3261  if (gstats->run_groupby)
3262  {
3263  fprintf (fp, "%*c", indent, ' ');
3264  fprintf (fp, "GROUPBY (time: %d", TO_MSEC (gstats->groupby_time));
3265 
3266  if (gstats->groupby_hash == HS_ACCEPT_ALL)
3267  {
3268  fprintf (fp, ", hash: true");
3269  }
3270  else if (gstats->groupby_hash == HS_REJECT_ALL)
3271  {
3272  fprintf (fp, ", hash: partial");
3273  }
3274  else
3275  {
3276  fprintf (fp, ", hash: false");
3277  }
3278 
3279  if (gstats->groupby_sort)
3280  {
3281  fprintf (fp, ", sort: true, page: %lld, ioread: %lld", (long long int) gstats->groupby_pages,
3282  (long long int) gstats->groupby_ioreads);
3283  }
3284  else
3285  {
3286  fprintf (fp, ", sort: false");
3287  }
3288 
3289  fprintf (fp, ", rows: %d)\n", gstats->rows);
3290  }
3291 
3292  ostats = &xasl_p->orderby_stats;
3293  if (ostats->orderby_filesort || ostats->orderby_topnsort || XASL_IS_FLAGED (xasl_p, XASL_SKIP_ORDERBY_LIST))
3294  {
3295  fprintf (fp, "%*c", indent, ' ');
3296  fprintf (fp, "ORDERBY (time: %d", TO_MSEC (ostats->orderby_time));
3297 
3298  if (ostats->orderby_filesort)
3299  {
3300  fprintf (fp, ", sort: true");
3301  fprintf (fp, ", page: %lld, ioread: %lld", (long long int) ostats->orderby_pages,
3302  (long long int) ostats->orderby_ioreads);
3303  }
3304  else if (ostats->orderby_topnsort)
3305  {
3306  fprintf (fp, ", topnsort: true");
3307  }
3308  else
3309  {
3310  fprintf (fp, ", skipsort: true");
3311  }
3312  fprintf (fp, ")\n");
3313  }
3314 
3315  if (HAVE_SUBQUERY_PROC (xasl_p) && xasl_p->aptr_list != NULL)
3316  {
3317  if (HAVE_SUBQUERY_PROC (xasl_p->aptr_list))
3318  {
3319  fprintf (fp, "%*cSUBQUERY (uncorrelated)\n", indent, ' ');
3320  }
3321 
3322  qdump_print_stats_text (fp, xasl_p->aptr_list, indent);
3323  }
3324 
3325  if (xasl_p->dptr_list != NULL)
3326  {
3327  fprintf (fp, "%*cSUBQUERY (correlated)\n", indent, ' ');
3328  qdump_print_stats_text (fp, xasl_p->dptr_list, indent);
3329  }
3330 }
3331 #endif /* SERVER_MODE */
QPROC_SINGLE_FETCH single_fetch
Definition: query_list.h:339
pred_expr * lhs
regu_variable_node * key1
Definition: access_spec.hpp:67
static bool qdump_print_attribute(const char *action_p, int attr_count, int *attr_ids_p)
Definition: query_dump.c:300
static bool qdump_print_rlike_eval_term(EVAL_TERM *term_p)
Definition: query_dump.c:1453
static bool qdump_print_oid(OID *oidptr)
Definition: query_dump.c:1376
OUTPTR_LIST * outptr_list
Definition: xasl.h:968
REGU_VARIABLE_LIST prior_regu_list_pred
Definition: xasl.h:427
SORT_LIST * orderby_list
Definition: xasl.h:957
static const char * qdump_range_type_string(RANGE_TYPE range_type)
Definition: query_dump.c:613
cubthread::entry * thread_get_thread_entry_info(void)
#define NO_ERROR
Definition: error_code.h:46
static bool qdump_print_type_list(QFILE_TUPLE_VALUE_TYPE_LIST *typeptr)
Definition: query_dump.c:820
PRED_EXPR * set_pred
Definition: xasl.h:298
VAL_LIST * prior_val_list
Definition: xasl.h:425
static const char * qdump_target_type_string(TARGET_TYPE type)
Definition: query_dump.c:408
XASL_NODE * fptr_list
Definition: xasl.h:984
key_range * key_ranges
Definition: access_spec.hpp:75
DB_VALUE * save_instnum_val
Definition: xasl.h:981
static bool qdump_print_arith(int type, void *ptr)
Definition: query_dump.c:1810
#define XASL_CLEAR_FLAG(x, f)
Definition: xasl.h:497
ACCESS_SPEC_TYPE * merge_spec
Definition: xasl.h:971
regu_variable_node * key_limit_u
Definition: access_spec.hpp:81
QFILE_TUPLE_VALUE_TYPE_LIST type_list
Definition: query_list.h:428
REGU_VARIABLE_LIST cls_regu_list_key
Definition: xasl.h:719
QDUMP_XASL_CHECK_NODE * next
Definition: query_dump.c:57
REGU_VARIABLE * rightptr
Definition: regu_var.hpp:129
RANGE_TYPE
PRED_EXPR * if_pred
Definition: xasl.h:978
static bool qdump_print_connect_by_proc_node(XASL_NODE *xasl_p)
Definition: query_dump.c:2198
BUILDVALUE_PROC_NODE buildvalue
Definition: xasl.h:1020
int val_cnt
Definition: xasl.h:208
#define XASL_G_GRBYNUM_FLAG_SCAN_CONTINUE
Definition: xasl.h:471
int n_oid_list
Definition: xasl.h:1035
DB_TYPE
Definition: dbtype_def.h:670
regu_variable_node * src
INDX_INFO * indexptr
Definition: xasl.h:927
TYPE_EVAL_TERM et_type
REGU_VARIABLE_LIST next
Definition: regu_var.hpp:221
bool ql_flag
Definition: xasl.h:300
const int REGU_VARIABLE_HIDDEN_COLUMN
Definition: regu_var.hpp:156
UPDDEL_CLASS_INFO * classes
Definition: xasl.h:407
#define ACCESS_SPEC_SHOWSTMT_SPEC(ptr)
Definition: xasl.h:812
union xasl_node::@155 proc
REGU_VARIABLE * leftptr
Definition: regu_var.hpp:128
QFILE_LIST_MERGE_INFO ls_merge
Definition: xasl.h:363
SHOWSTMT_TYPE show_type
Definition: xasl.h:758
regu_variable_node * elem
PRED_EXPR * g_grbynum_pred
Definition: xasl.h:316
TARGET_TYPE type
Definition: xasl.h:925
union regu_variable_node::regu_data_value value
XASL_NODE * inner_xasl
Definition: xasl.h:359
REGU_VARIABLE * orderby_limit
Definition: xasl.h:960
static bool qdump_print_predicate(PRED_EXPR *predptr)
Definition: query_dump.c:1578
CL_ATTR_ID id
Definition: regu_var.hpp:76
static bool qdump_print_value_type_addr(REGU_VARIABLE *value)
Definition: query_dump.c:1315
QUERY_OPTIONS option
Definition: xasl.h:967
#define XASL_LINK_TO_REGU_VARIABLE
Definition: xasl.h:477
static bool qdump_print_hfid(HFID id)
Definition: query_dump.c:699
UNION_PROC_NODE union_
Definition: xasl.h:1017
static bool qdump_print_vfid(VFID id)
Definition: query_dump.c:713
static bool qdump_print_merge_list_proc_node(MERGELIST_PROC_NODE *ptr)
Definition: query_dump.c:260
bool REGU_VARIABLE_IS_FLAGED(const regu_variable_node *regu, int flag)
Definition: regu_var.hpp:253
aggregate_accumulator accumulator
#define ACCESS_SPEC_LIST_SPEC(ptr)
Definition: xasl.h:809
static bool qdump_print_regu_type(REGU_VARIABLE *value)
Definition: query_dump.c:1076
XASL_NODE * update_xasl
Definition: xasl.h:438
MERGELIST_PROC_NODE mergelist
Definition: xasl.h:1021
int cat_fetched
Definition: xasl.h:1001
XASL_NODE * aptr_list
Definition: xasl.h:974
PROC_TYPE type
Definition: xasl.h:953
OID class_oid
Definition: xasl.h:386
UPDDEL_CLASS_INFO * classes
Definition: xasl.h:370
DB_VALUE * arg
Definition: xasl.h:297
BUILDLIST_PROC_NODE buildlist
Definition: xasl.h:1019
Definition: xasl.h:189
#define ACCESS_SPEC_SET_PTR(ptr)
Definition: xasl.h:836
int * att_id
Definition: xasl.h:390
UPDATE_PROC_NODE update
Definition: xasl.h:1022
regu_variable_node * lhs
ACCESS_SPEC_TYPE * inner_spec_list
Definition: xasl.h:360
static bool qdump_print_index(INDX_INFO *indexptr)
Definition: query_dump.c:636
DELETE_PROC_NODE delete_
Definition: xasl.h:1024
DB_VALUE * g_grbynum_val
Definition: xasl.h:317
SORT_ORDER s_order
Definition: query_list.h:417
static bool qdump_print_comp_eval_term(EVAL_TERM *term_p)
Definition: query_dump.c:1383
int is_single_tuple
Definition: xasl.h:965
VAL_LIST * val_list
Definition: xasl.h:972
PRED_EXPR * ordbynum_pred
Definition: xasl.h:958
REGU_VARIABLE_LIST list_regu_list_probe
Definition: xasl.h:751
REGU_VARIABLE_LIST list_regu_list_build
Definition: xasl.h:750
void THREAD_ENTRY
DB_VALUE * val
Definition: xasl.h:196
static bool qdump_print_xasl_type(XASL_NODE *xasl)
Definition: query_dump.c:125
RANGE range
Definition: access_spec.hpp:69
OPERATOR_TYPE opcode
Definition: regu_var.hpp:131
KEY_INFO key_info
Definition: access_spec.hpp:91
ACCESS_METHOD access
Definition: xasl.h:926
ACCESS_METHOD
Definition: xasl.h:687
XASL_NODE * next
Definition: xasl.h:952
DB_DATA data
Definition: dbtype_def.h:1083
static bool qdump_print_column(const char *title_p, int col_count, int *column_p)
Definition: query_dump.c:210
DB_VALUE * s_dbval
Definition: xasl.h:934
int flag
Definition: xasl.h:954
XASL_NODE * recursive_part
Definition: xasl.h:447
static bool qdump_print_value(REGU_VARIABLE *value)
Definition: query_dump.c:1195
ACCESS_SPEC_TYPE * next
Definition: xasl.h:935
PRED_EXPR * start_with_pred
Definition: xasl.h:419
XASL_NODE * outer_xasl
Definition: xasl.h:356
#define TO_MSEC(elapsed)
#define assert(x)
ACCESS_SPEC_TYPE * curr_spec
Definition: xasl.h:996
int ordbynum_flag
Definition: xasl.h:961
bool qdump_print_xasl(xasl_node *xasl_p)
Definition: query_dump.c:2294
#define XASL_TOP_MOST_XASL
Definition: xasl.h:480
static bool qdump_print_class(CLS_SPEC_TYPE *ptr)
Definition: query_dump.c:680
CONNECTBY_PROC_NODE connect_by
Definition: xasl.h:1025
int32_t fileid
Definition: dbtype_def.h:886
XASL_NODE * dptr_list
Definition: xasl.h:976
REGU_VARIABLE_LIST after_cb_regu_list_rest
Definition: xasl.h:430
OPERATOR_TYPE
PRED_EXPR * where_range
Definition: xasl.h:931
int num_vals
Definition: xasl.h:388
INSERT_PROC_NODE insert
Definition: xasl.h:1023
struct sort_list * next
Definition: query_list.h:415
comp_eval_term et_comp
REGU_VARIABLE value
Definition: regu_var.hpp:222
const char * qdump_operator_type_string(OPERATOR_TYPE optype)
Definition: query_dump.c:1016
static bool qdump_print_arith_expression(ARITH_TYPE *arith_p)
Definition: query_dump.c:1709
static bool qdump_print_value_list(VAL_LIST *vallist)
Definition: query_dump.c:926
QFILE_LIST_ID * list_id
Definition: xasl.h:955
REGU_VARIABLE_LIST list_regu_list_pred
Definition: xasl.h:748
union cubxasl::pred_expr::@185 pe
static bool qdump_print_function_value(REGU_VARIABLE *regu)
Definition: query_dump.c:1288
#define DB_VALUE_DOMAIN_TYPE(value)
Definition: dbtype.h:70
static bool qdump_print_tuple_value_position(QFILE_TUPLE_VALUE_POSITION pos)
Definition: query_dump.c:911
static const char * qdump_access_method_string(ACCESS_METHOD access)
Definition: query_dump.c:435
#define ACCESS_SPEC_CLS_SPEC(ptr)
Definition: xasl.h:797
#define IS_ANY_INDEX_ACCESS(access_)
Definition: xasl.h:699
int next_scan_on
Definition: xasl.h:998
REGU_VARIABLE * level_regu
Definition: xasl.h:989
static bool qdump_print_build_value_node(XASL_NODE *xasl_p)
Definition: query_dump.c:2156
ARITH_TYPE * outarith_list
Definition: xasl.h:348
static bool qdump_print_db_value(DB_VALUE *value)
Definition: query_dump.c:1009
static bool qdump_print_access_spec(ACCESS_SPEC_TYPE *spec_list)
Definition: query_dump.c:458
static const char * qdump_bool_operator_string(BOOL_OP bool_op)
Definition: query_dump.c:1529
static bool qdump_print_aggregate_expression(AGGREGATE_TYPE *aggptr)
Definition: query_dump.c:1760
#define TP_DOMAIN_TYPE(dom)
REGU_VARIABLE * iscycle_regu
Definition: xasl.h:994
PRED_EXPR * after_connect_by_pred
Definition: xasl.h:420
#define LOCK_TO_LOCKMODE_STRING(lock)
DB_VALUE * isleaf_val
Definition: xasl.h:991
static bool qdump_print_update_proc_node(UPDATE_PROC_NODE *ptr)
Definition: query_dump.c:321
#define NULL
Definition: freelistheap.h:34
int next_scan_block_on
Definition: xasl.h:999
static const char * qdump_key_range_string(RANGE range)
Definition: query_dump.c:538
int * att_id
Definition: xasl.h:235
#define XASL_IS_FLAGED(x, f)
Definition: xasl.h:495
void db_value_print(const DB_VALUE *value)
Definition: db_macro.c:1663
XASL_NODE * connect_by_ptr
Definition: xasl.h:987
REGU_VARIABLE_LIST regu_list_rest
Definition: xasl.h:424
REGU_VARIABLE_LIST regu_list_pred
Definition: xasl.h:423
VAL_LIST * single_tuple
Definition: xasl.h:963
REGU_VARIABLE_LIST after_cb_regu_list_pred
Definition: xasl.h:429
regu_variable_node * rhs
QFILE_TUPLE_VALUE_POSITION pos_descr
Definition: query_list.h:416
REGU_DATATYPE
Definition: regu_var.hpp:42
static bool qdump_print_sort_list(SORT_LIST *sorting_list)
Definition: query_dump.c:860
VAL_LIST * g_val_list
Definition: xasl.h:314
static bool qdump_print_list(LIST_SPEC_TYPE *ptr)
Definition: query_dump.c:725
static bool qdump_print_list_merge_info(QFILE_LIST_MERGE_INFO *ptr)
Definition: query_dump.c:231
aggregate_list_node * next
XASL_NODE * insert_xasl
Definition: xasl.h:439
REGU_VARIABLE_LIST list_regu_list_rest
Definition: xasl.h:749
DB_VALUE * value
Definition: regu_var.hpp:127
AGGREGATE_TYPE * agg_list
Definition: xasl.h:347
regu_variable_node * src
bool fetch_res
Definition: xasl.h:299
static const char * qdump_regu_type_string(REGU_DATATYPE type)
Definition: query_dump.c:1029
int num_orderby_keys
Definition: xasl.h:376
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
static bool qdump_print_attribute_id(ATTR_DESCR attr)
Definition: query_dump.c:897
static bool qdump_print_lhs_predicate(PRED_EXPR *pred_p)
Definition: query_dump.c:1558
DB_TYPE type
Definition: regu_var.hpp:77
OID * class_oid
Definition: xasl.h:232
FETCH_PROC_NODE fetch
Definition: xasl.h:1018
AGGREGATE_TYPE * g_agg_list
Definition: xasl.h:318
static const char * qdump_data_type_string(DB_TYPE type)
Definition: query_dump.c:1100
#define HAVE_SUBQUERY_PROC(xasl_p)
Definition: query_dump.c:50
PRED_EXPR * where_pred
Definition: xasl.h:930
PRED_EXPR * after_join_pred
Definition: xasl.h:977
CTE_PROC_NODE cte
Definition: xasl.h:1027
XASL_NODE * eptr_list
Definition: xasl.h:308
OID creator_oid
Definition: xasl.h:1033
static const char * qdump_arith_operator_string(OPERATOR_TYPE opcode)
Definition: query_dump.c:1673
static void error(const char *msg)
Definition: gencat.c:331
#define XASL_SKIP_ORDERBY_LIST
Definition: xasl.h:478
int g_grbynum_flag
Definition: xasl.h:328
#define ACCESS_SPEC_XASL_NODE(ptr)
Definition: xasl.h:821
#define XASL_INSTNUM_FLAG_SCAN_CONTINUE
Definition: xasl.h:460
XASL_NODE * left
Definition: xasl.h:289
const char * query_alias
Definition: xasl.h:1039
VAL_LIST * outer_val_list
Definition: xasl.h:358
XASL_NODE * right
Definition: xasl.h:290
OUTPTR_LIST * prior_outptr_list
Definition: xasl.h:426
regu_variable_node * key2
Definition: access_spec.hpp:68
int instnum_flag
Definition: xasl.h:997
bool key_limit_reset
Definition: access_spec.hpp:78
DB_VALUE * level_val
Definition: xasl.h:988
static bool qdump_print_domain_list(int cnt, TP_DOMAIN **ptr)
Definition: query_dump.c:837
OID * class_oid_list
Definition: xasl.h:1036
static bool qdump_print_delete_proc_node(DELETE_PROC_NODE *ptr)
Definition: query_dump.c:356
OUTPTR_LIST * g_outptr_list
Definition: xasl.h:312
XASL_NODE * xasl_node
Definition: xasl.h:753
PRED_EXPR * having_pred
Definition: xasl.h:345
regu_variable_node * elemset
DB_VALUE * ordbynum_val
Definition: xasl.h:959
RANGE_TYPE range_type
Definition: access_spec.hpp:90
static bool qdump_print_eval_term(PRED_EXPR *pred_p)
Definition: query_dump.c:1471
XASL_NODE * scan_ptr
Definition: xasl.h:985
static bool qdump_print_insert_proc_node(INSERT_PROC_NODE *ptr)
Definition: query_dump.c:392
#define free_and_init(ptr)
Definition: memory_alloc.h:147
static bool qdump_print_btid(BTID id)
Definition: query_dump.c:668
ACCESS_SPEC_TYPE * spec_list
Definition: xasl.h:970
bool is_user_given_keylimit
Definition: access_spec.hpp:79
static bool qdump_print_fetch_node(XASL_NODE *xasl_p)
Definition: query_dump.c:2044
static bool qdump_print_regu_variable_list(REGU_VARIABLE_LIST varlist)
Definition: query_dump.c:963
int num_subclasses
Definition: xasl.h:231
static bool qdump_print_build_list_node(XASL_NODE *xasl_p)
Definition: query_dump.c:2068
int num_classes
Definition: xasl.h:408
static bool qdump_print_showstmt(SHOWSTMT_SPEC_TYPE *ptr)
Definition: query_dump.c:746
QPROC_DB_VALUE_LIST valp
Definition: xasl.h:207
QFILE_LIST_ID * input_list_id
Definition: xasl.h:421
static bool qdump_print_list_id(QFILE_LIST_ID *idptr)
Definition: query_dump.c:795
bool prm_get_bool_value(PARAM_ID prm_id)
class regu_variable_node REGU_VARIABLE
Definition: regu_var.hpp:64
PRED_EXPR * where_key
Definition: xasl.h:929
void er_clear(void)
REGU_VARIABLE_LIST cls_regu_list_pred
Definition: xasl.h:720
DB_VALUE * grbynum_val
Definition: xasl.h:346
int i
Definition: dynamic_load.c:954
PROC_TYPE
Definition: xasl.h:172
OID cls_oid
Definition: xasl.h:727
HFID * class_hfid
Definition: xasl.h:233
static bool qdump_print_alsm_eval_term(EVAL_TERM *term_p)
Definition: query_dump.c:1401
REGU_VARIABLE_LIST cls_regu_list_rest
Definition: xasl.h:721
PRED_EXPR * instnum_pred
Definition: xasl.h:979
int dbval_cnt
Definition: xasl.h:1040
QPROC_DB_VALUE_LIST next
Definition: xasl.h:195
REGU_VARIABLE_LIST prior_regu_list_rest
Definition: xasl.h:428
static bool qdump_print_like_eval_term(EVAL_TERM *term_p)
Definition: query_dump.c:1428
#define HASH_NUMBER
Definition: query_dump.c:48
TYPE_PRED_EXPR type
SORT_LIST * groupby_list
Definition: xasl.h:309
HFID hfid
Definition: xasl.h:726
int * class_locks
Definition: xasl.h:1037
REGU_VARIABLE_LIST arg_list
Definition: xasl.h:759
#define XASL_ORDBYNUM_FLAG_SCAN_CONTINUE
Definition: xasl.h:456
#define foutput
Definition: query_dump.c:40
alsm_eval_term et_alsm
static bool qdump_print_outlist(const char *title, OUTPTR_LIST *outlist)
Definition: query_dump.c:761
regu_variable_node * pattern
union cubxasl::eval_term::@184 et
QFILE_LIST_ID * start_with_list_id
Definition: xasl.h:422
static const char * qdump_relation_operator_string(int op)
Definition: query_dump.c:1645
like_eval_term et_like
#define XASL_ZERO_CORR_LEVEL
Definition: xasl.h:479
int heap_get_indexinfo_of_btid(THREAD_ENTRY *thread_p, const OID *class_oid, const BTID *btid, BTREE_TYPE *type, int *num_attrs, ATTR_ID **attr_ids, int **attrs_prefix_length, char **btnamepp, int *func_index_col_id)
Definition: heap_file.c:13134
regu_variable_node * pattern
REGU_VARIABLE_LIST g_regu_list
Definition: xasl.h:313
QPROC_SINGLE_FETCH single_fetch
Definition: xasl.h:933
pred_expr * rhs
PRED_EXPR * g_having_pred
Definition: xasl.h:315
XASL_NODE * bptr_list
Definition: xasl.h:975
ACCESS_SPEC_TYPE * outer_spec_list
Definition: xasl.h:357
RANGE
Definition: access_spec.hpp:32
int heap_get_class_name(THREAD_ENTRY *thread_p, const OID *class_oid, char **class_name)
Definition: heap_file.c:9328
static bool qdump_print_term(PRED_EXPR *pred_ptr)
Definition: query_dump.c:1500
regu_variable_node * esc_char
Definition: xasl.h:186
TARGET_TYPE
Definition: xasl.h:675
VAL_LIST * inner_val_list
Definition: xasl.h:361
DB_VALUE * iscycle_val
Definition: xasl.h:993
MERGE_PROC_NODE merge
Definition: xasl.h:1026
REGU_VARIABLE_LIST valptrp
Definition: regu_var.hpp:116
DB_VALUE ** output_columns
Definition: xasl.h:306
DB_VALUE * instnum_val
Definition: xasl.h:980
rlike_eval_term et_rlike
int num_classes
Definition: xasl.h:369
HFID class_hfid
Definition: xasl.h:387
REGU_VARIABLE * isleaf_regu
Definition: xasl.h:992
static bool qdump_print_db_value_array(DB_VALUE **array, int cnt)
Definition: query_dump.c:188
const char * fcode_get_uppercase_name(FUNC_TYPE ftype)
XASL_NODE * non_recursive_part
Definition: xasl.h:446
static bool qdump_print_key_info(KEY_INFO *key_info)
Definition: query_dump.c:575
regu_variable_list_node * operands
static const char * qdump_option_string(int option)
Definition: query_dump.c:990
bool g_with_rollup
Definition: xasl.h:329
int * tcard_list
Definition: xasl.h:1038
regu_variable_node * case_sensitive
bool is_constant
Definition: access_spec.hpp:77
BOOL_OP
regu_variable_node * key_limit_l
Definition: access_spec.hpp:80