CUBRID Engine  latest
xasl_to_stream.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  * xasl_to_stream.c - XASL tree storer
21  */
22 
23 #ident "$Id$"
24 
25 #include "config.h"
26 
27 #include <stdio.h>
28 #include <stdarg.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <assert.h>
32 
33 #include "xasl_to_stream.h"
34 
35 #include "error_manager.h"
36 #include "server_interface.h"
37 #include "class_object.h"
38 #include "object_primitive.h"
39 #include "work_space.h"
40 #include "memory_alloc.h"
41 #include "xasl.h"
42 #include "xasl_aggregate.hpp"
43 #include "xasl_analytic.hpp"
44 #include "xasl_predicate.hpp"
45 #include "xasl_stream.hpp"
46 #include "xasl_unpack_info.hpp"
47 
48 #define BYTE_SIZE OR_INT_SIZE
49 #define LONG_SIZE OR_INT_SIZE
50 #define PTR_SIZE OR_INT_SIZE
51 #define pack_char or_pack_int
52 #define pack_long or_pack_int
53 
54 /* structure of a visited pointer constant */
57 {
58  const void *ptr; /* a pointer constant */
59  int offset; /* offset where the node pointed by 'ptr' is stored */
60 };
61 
62 /* linear byte stream to store the given XASL tree */
63 static char *xts_Stream_buffer = NULL; /* pointer to the stream */
64 static int xts_Stream_size = 0; /* # of bytes allocated */
66 
67 /* blocks of visited pointer constants */
69 
70 /* low-water-mark of visited pointers */
71 static int xts_Ptr_lwm[MAX_PTR_BLOCKS] = { 0 };
72 static int xts_Ptr_max[MAX_PTR_BLOCKS] = { 0 };
73 
74 /* error code specific to this file */
76 
77 static int xts_save_aggregate_type (const AGGREGATE_TYPE * aggregate);
78 static int xts_save_function_type (const FUNCTION_TYPE * function);
79 static int xts_save_analytic_type (const ANALYTIC_TYPE * analytic);
80 static int xts_save_analytic_eval_type (const ANALYTIC_EVAL_TYPE * analytic);
81 static int xts_save_srlist_id (const QFILE_SORTED_LIST_ID * sort_list_id);
82 static int xts_save_list_id (const QFILE_LIST_ID * list_id);
83 static int xts_save_arith_type (const ARITH_TYPE * arithmetic);
84 static int xts_save_indx_info (const INDX_INFO * indx_info);
85 static int xts_save_outptr_list (const OUTPTR_LIST * outptr_list);
86 static int xts_save_selupd_list (const SELUPD_LIST * selupd_list);
87 static int xts_save_pred_expr (const PRED_EXPR * ptr);
88 static int xts_save_regu_variable (const REGU_VARIABLE * ptr);
91 static int xts_save_sort_list (const SORT_LIST * ptr);
92 static int xts_save_string (const char *str);
93 static int xts_save_val_list (const VAL_LIST * ptr);
94 static int xts_save_db_value (const DB_VALUE * ptr);
95 static int xts_save_xasl_node (const XASL_NODE * ptr);
96 static int xts_save_filter_pred_node (const PRED_EXPR_WITH_CONTEXT * pred);
97 static int xts_save_func_pred (const FUNC_PRED * ptr);
99 #if 0
100 /* there are currently no pointers to these type of structures in xasl
101  * so there is no need to have a separate restore function.
102  */
103 static int xts_save_merge_list_info (const MERGELIST_PROC_NODE * ptr);
104 static int xts_save_ls_merge_info (const QFILE_LIST_MERGE_INFO * ptr);
105 static int xts_save_update_info (const UPDATE_PROC_NODE * ptr);
106 static int xts_save_delete_info (const DELETE_PROC_NODE * ptr);
107 static int xts_save_insert_info (const INSERT_PROC_NODE * ptr);
108 #endif
109 
110 // *INDENT-OFF*
111 template <typename T>
112 static int xts_save (const T &t);
113 
114 template <typename T>
115 static void xts_debug_check (const T &t, char *pack_start, const char *pack_end);
116 template <typename T>
117 static void xts_debug_clear (T &t);
118 // *INDENT-ON*
119 
120 static int xts_save_db_value_array (DB_VALUE ** ptr, int size);
121 static int xts_save_int_array (int *ptr, int size);
122 static int xts_save_hfid_array (HFID * ptr, int size);
123 static int xts_save_oid_array (OID * ptr, int size);
124 static int xts_save_method_sig_list (const METHOD_SIG_LIST * ptr);
125 static int xts_save_method_sig (const METHOD_SIG * ptr, int size);
126 static int xts_save_key_range_array (const KEY_RANGE * ptr, int size);
127 static int xts_save_upddel_class_info_array (const UPDDEL_CLASS_INFO * classes, int nelements);
128 static int xts_save_update_assignment_array (const UPDATE_ASSIGNMENT * assigns, int nelements);
129 static int xts_save_odku_info (const ODKU_INFO * odku_info);
130 
131 static char *xts_process (char *ptr, const json_table_column & json_table_col);
132 static char *xts_process (char *ptr, const json_table_node & json_table_node);
133 static char *xts_process (char *ptr, const json_table_spec_node & set_spec);
134 static char *xts_process_xasl_node (char *ptr, const XASL_NODE * xasl);
135 static char *xts_process_xasl_header (char *ptr, const XASL_NODE_HEADER header);
136 static char *xts_process_filter_pred_node (char *ptr, const PRED_EXPR_WITH_CONTEXT * pred);
137 static char *xts_process_func_pred (char *ptr, const FUNC_PRED * xasl);
138 static char *xts_process_cache_attrinfo (char *ptr);
139 static char *xts_process_union_proc (char *ptr, const UNION_PROC_NODE * union_proc);
140 static char *xts_process_fetch_proc (char *ptr, const FETCH_PROC_NODE * obj_set_fetch_proc);
141 static char *xts_process_buildlist_proc (char *ptr, const BUILDLIST_PROC_NODE * build_list_proc);
142 static char *xts_process_buildvalue_proc (char *ptr, const BUILDVALUE_PROC_NODE * build_value_proc);
143 static char *xts_process_mergelist_proc (char *ptr, const MERGELIST_PROC_NODE * merge_list_info);
145 static char *xts_save_upddel_class_info (char *ptr, const UPDDEL_CLASS_INFO * upd_cls);
146 static char *xts_save_update_assignment (char *ptr, const UPDATE_ASSIGNMENT * assign);
147 static char *xts_process_update_proc (char *ptr, const UPDATE_PROC_NODE * update_info);
148 static char *xts_process_delete_proc (char *ptr, const DELETE_PROC_NODE * delete_proc);
149 static char *xts_process_insert_proc (char *ptr, const INSERT_PROC_NODE * insert_proc);
150 static char *xts_process_merge_proc (char *ptr, const MERGE_PROC_NODE * merge_info);
151 static char *xts_process_cte_proc (char *ptr, const CTE_PROC_NODE * cte_proc);
152 
153 static char *xts_process_outptr_list (char *ptr, const OUTPTR_LIST * outptr_list);
154 static char *xts_process_selupd_list (char *ptr, const SELUPD_LIST * selupd_list);
155 static char *xts_process_pred_expr (char *ptr, const PRED_EXPR * pred_expr);
156 static char *xts_process_pred (char *ptr, const PRED * pred);
157 static char *xts_process_eval_term (char *ptr, const EVAL_TERM * eval_term);
158 static char *xts_process_comp_eval_term (char *ptr, const COMP_EVAL_TERM * comp_eval_term);
159 static char *xts_process_alsm_eval_term (char *ptr, const ALSM_EVAL_TERM * alsm_eval_term);
160 static char *xts_process_like_eval_term (char *ptr, const LIKE_EVAL_TERM * like_eval_term);
161 static char *xts_process_rlike_eval_term (char *ptr, const RLIKE_EVAL_TERM * rlike_eval_term);
162 static char *xts_process_access_spec_type (char *ptr, const ACCESS_SPEC_TYPE * access_spec);
163 static char *xts_process_indx_info (char *ptr, const INDX_INFO * indx_info);
164 static char *xts_process_key_info (char *ptr, const KEY_INFO * key_info);
165 static char *xts_process_cls_spec_type (char *ptr, const CLS_SPEC_TYPE * cls_spec);
166 static char *xts_process_list_spec_type (char *ptr, const LIST_SPEC_TYPE * list_spec);
167 static char *xts_process_showstmt_spec_type (char *ptr, const SHOWSTMT_SPEC_TYPE * list_spec);
168 static char *xts_process_set_spec_type (char *ptr, const SET_SPEC_TYPE * set_spec);
169 static char *xts_process_json_table_column_behavior (char *ptr, const json_table_column_behavior * behavior);
170 static char *xts_process_method_spec_type (char *ptr, const METHOD_SPEC_TYPE * method_spec);
171 static char *xts_process_rlist_spec_type (char *ptr, const LIST_SPEC_TYPE * list_spec);
172 static char *xts_process_list_id (char *ptr, const QFILE_LIST_ID * list_id);
173 static char *xts_process_val_list (char *ptr, const VAL_LIST * val_list);
174 static char *xts_process_regu_variable (char *ptr, const REGU_VARIABLE * regu_var);
175 static char *xts_pack_regu_variable_value (char *ptr, const REGU_VARIABLE * regu_var);
176 static char *xts_process_attr_descr (char *ptr, const ATTR_DESCR * attr_descr);
177 static char *xts_process_pos_descr (char *ptr, const QFILE_TUPLE_VALUE_POSITION * position_descr);
178 static char *xts_process_db_value (char *ptr, const DB_VALUE * value);
179 static char *xts_process_arith_type (char *ptr, const ARITH_TYPE * arith);
180 static char *xts_process_aggregate_type (char *ptr, const AGGREGATE_TYPE * aggregate);
181 static char *xts_process_analytic_type (char *ptr, const ANALYTIC_TYPE * analytic);
182 static char *xts_process_analytic_eval_type (char *ptr, const ANALYTIC_EVAL_TYPE * analytic);
183 static char *xts_process_function_type (char *ptr, const FUNCTION_TYPE * function);
184 static char *xts_process_srlist_id (char *ptr, const QFILE_SORTED_LIST_ID * sort_list_id);
185 static char *xts_process_sort_list (char *ptr, const SORT_LIST * sort_list);
186 static char *xts_process_method_sig_list (char *ptr, const METHOD_SIG_LIST * method_sig_list);
187 static char *xts_process_method_sig (char *ptr, const METHOD_SIG * method_sig, int size);
188 static char *xts_process_connectby_proc (char *ptr, const CONNECTBY_PROC_NODE * connectby_proc);
189 static char *xts_process_regu_value_list (char *ptr, const REGU_VALUE_LIST * regu_value_list);
190 
191 static int xts_sizeof (const json_table_column & ptr);
192 static int xts_sizeof (const json_table_node & ptr);
193 static int xts_sizeof (const json_table_spec_node & ptr);
194 static int xts_sizeof_xasl_node (const XASL_NODE * ptr);
196 static int xts_sizeof_func_pred (const FUNC_PRED * ptr);
198 static int xts_sizeof_union_proc (const UNION_PROC_NODE * ptr);
199 static int xts_sizeof_fetch_proc (const FETCH_PROC_NODE * ptr);
204 static int xts_sizeof_upddel_class_info (const UPDDEL_CLASS_INFO * upd_cls);
205 static int xts_sizeof_update_assignment (const UPDATE_ASSIGNMENT * assign);
206 static int xts_sizeof_odku_info (const ODKU_INFO * odku_info);
207 static int xts_sizeof_update_proc (const UPDATE_PROC_NODE * ptr);
208 static int xts_sizeof_delete_proc (const DELETE_PROC_NODE * ptr);
209 static int xts_sizeof_insert_proc (const INSERT_PROC_NODE * ptr);
210 static int xts_sizeof_merge_proc (const MERGE_PROC_NODE * ptr);
211 static int xts_sizeof_outptr_list (const OUTPTR_LIST * ptr);
212 static int xts_sizeof_selupd_list (const SELUPD_LIST * ptr);
213 static int xts_sizeof_pred_expr (const PRED_EXPR * ptr);
214 static int xts_sizeof_pred (const PRED * ptr);
215 static int xts_sizeof_eval_term (const EVAL_TERM * ptr);
216 static int xts_sizeof_comp_eval_term (const COMP_EVAL_TERM * ptr);
217 static int xts_sizeof_alsm_eval_term (const ALSM_EVAL_TERM * ptr);
218 static int xts_sizeof_like_eval_term (const LIKE_EVAL_TERM * ptr);
219 static int xts_sizeof_rlike_eval_term (const RLIKE_EVAL_TERM * ptr);
221 static int xts_sizeof_indx_info (const INDX_INFO * ptr);
222 static int xts_sizeof_key_info (const KEY_INFO * ptr);
223 static int xts_sizeof_cls_spec_type (const CLS_SPEC_TYPE * ptr);
224 static int xts_sizeof_list_spec_type (const LIST_SPEC_TYPE * ptr);
226 static int xts_sizeof_set_spec_type (const SET_SPEC_TYPE * ptr);
229 static int xts_sizeof_list_id (const QFILE_LIST_ID * ptr);
230 static int xts_sizeof_val_list (const VAL_LIST * ptr);
231 static int xts_sizeof_regu_variable (const REGU_VARIABLE * ptr);
233 static int xts_sizeof_attr_descr (const ATTR_DESCR * ptr);
235 static int xts_sizeof_db_value (const DB_VALUE * ptr);
236 static int xts_sizeof_arith_type (const ARITH_TYPE * ptr);
237 static int xts_sizeof_aggregate_type (const AGGREGATE_TYPE * ptr);
238 static int xts_sizeof_function_type (const FUNCTION_TYPE * ptr);
239 static int xts_sizeof_analytic_type (const ANALYTIC_TYPE * ptr);
241 static int xts_sizeof_srlist_id (const QFILE_SORTED_LIST_ID * ptr);
242 static int xts_sizeof_sort_list (const SORT_LIST * ptr);
243 static int xts_sizeof_method_sig_list (const METHOD_SIG_LIST * ptr);
244 static int xts_sizeof_method_sig (const METHOD_SIG * ptr);
247 static int xts_sizeof_cte_proc (const CTE_PROC_NODE * ptr);
248 
249 static int xts_mark_ptr_visited (const void *ptr, int offset);
250 static int xts_get_offset_visited_ptr (const void *ptr);
251 static void xts_free_visited_ptrs (void);
252 static int xts_reserve_location_in_stream (int size);
253 static int xts_sizeof_regu_variable_list (const REGU_VARIABLE_LIST regu_var_list);
254 static char *xts_process_regu_variable_list (char *ptr, const REGU_VARIABLE_LIST regu_var_list);
255 
256 /*
257  * xts_map_xasl_to_stream () -
258  * return: if successful, return 0, otherwise non-zero error code
259  * xasl_tree(in) : pointer to root of XASL tree
260  * stream (out) : xasl stream & size
261  *
262  * Note: map the XASL tree into linear byte stream of disk
263  * representation. On successful return, `*xasl_stream'
264  * will have the address of memory containing the linearly
265  * mapped xasl stream, `*buffer_size' will have the
266  * # of bytes allocated for the stream
267  *
268  * Note: the caller should be responsible for free the memory of
269  * xasl_stream. the free function should be free_and_init().
270  */
271 int
272 xts_map_xasl_to_stream (const XASL_NODE * xasl_tree, XASL_STREAM * stream)
273 {
274  int offset, org_offset;
275  int header_size, body_size;
276  char *p;
277  int i;
278 
279  if (!xasl_tree || !stream)
280  {
282  }
283 
285 
286  /* reserve space for new XASL format */
287  header_size = sizeof (int) /* xasl->dbval_cnt */
288  + sizeof (OID) /* xasl->creator_oid */
289  + sizeof (int) /* xasl->n_oid_list */
290  + sizeof (OID) * xasl_tree->n_oid_list /* xasl->class_oid_list */
291  + sizeof (int) * xasl_tree->n_oid_list /* xasl->class_locks */
292  + sizeof (int) * xasl_tree->n_oid_list; /* xasl->tcard_list */
293 
294  offset = sizeof (int) /* [size of header data] */
295  + header_size /* [header data] */
296  + sizeof (int); /* [size of body data] */
297 
298  org_offset = offset;
299  offset = xasl_stream_make_align (offset);
300 
302 
303 #if !defined(NDEBUG)
304  /* suppress valgrind UMW error */
305  if (offset > org_offset)
306  {
307  memset (xts_Stream_buffer + org_offset, 0, offset - org_offset);
308  }
309 #endif
310 
311  /* save XASL tree into body data of the stream buffer */
312  if (xts_save_xasl_node (xasl_tree) == ER_FAILED)
313  {
314  if (xts_Stream_buffer)
315  {
317  }
318  goto end;
319  }
320 
321  /* make header size and data of new XASL format */
322  p = or_pack_int (xts_Stream_buffer, header_size);
323  p = or_pack_int (p, xasl_tree->dbval_cnt);
324  p = or_pack_oid (p, (OID *) (&xasl_tree->creator_oid));
325  p = or_pack_int (p, xasl_tree->n_oid_list);
326  for (i = 0; i < xasl_tree->n_oid_list; i++)
327  {
328  p = or_pack_oid (p, &xasl_tree->class_oid_list[i]);
329  }
330  for (i = 0; i < xasl_tree->n_oid_list; i++)
331  {
332  p = or_pack_int (p, xasl_tree->class_locks[i]);
333  }
334  for (i = 0; i < xasl_tree->n_oid_list; i++)
335  {
336  p = or_pack_int (p, xasl_tree->tcard_list[i]);
337  }
338 
339  /* set body size of new XASL format */
340  body_size = xts_Free_offset_in_stream - offset;
341  p = or_pack_int (p, body_size);
342 
343  /* set result */
344  stream->buffer = xts_Stream_buffer;
346 
347  if (stream->buffer_size <= 0)
348  {
349  assert (false);
351  }
352 
353 end:
354  /* free all memories */
356 
358  xts_Stream_size = 0;
360 
361  return xts_Xasl_errcode;
362 }
363 
364 /*
365  * xts_map_filter_pred_to_stream () -
366  * return: if successful, return 0, otherwise non-zero error code
367  * pred(in) : pointer to root of predicate tree
368  * pred_stream(out) : pointer to predicate stream
369  * pred_stream_size(out): # of bytes in predicate stream
370  */
371 int
372 xts_map_filter_pred_to_stream (const PRED_EXPR_WITH_CONTEXT * pred, char **pred_stream, int *pred_stream_size)
373 {
374  int offset;
375  int header_size, body_size;
376  char *p = NULL;
377 
378  if (!pred || !pred_stream || !pred_stream_size)
379  {
381  }
382 
384  header_size = 0; /* could be changed */
385 
386  offset = sizeof (int) /* [size of header data] */
387  + header_size /* [header data] */
388  + sizeof (int); /* [size of body data] */
389  offset = xasl_stream_make_align (offset);
390 
392 
393  if (xts_save_filter_pred_node (pred) == ER_FAILED)
394  {
395  if (xts_Stream_buffer)
396  {
398  }
399  goto end;
400  }
401 
402  /* make header size and data */
403  p = or_pack_int (xts_Stream_buffer, header_size);
404 
405  /* set body size of new XASL format */
406  body_size = xts_Free_offset_in_stream - offset;
407  p = or_pack_int (p, body_size);
408 
409  /* set result */
410  *pred_stream = xts_Stream_buffer;
411  *pred_stream_size = xts_Free_offset_in_stream;
412 
413 end:
414  /* free all memories */
416 
418  xts_Stream_size = 0;
420 
421  return xts_Xasl_errcode;
422 }
423 
424 /*
425  * xts_map_func_pred_to_stream () -
426  * return: if successful, return 0, otherwise non-zero error code
427  * xasl_tree(in) : pointer to root of XASL tree
428  * xasl_stream(out) : pointer to xasl stream
429  * xasl_stream_size(out): # of bytes in xasl_stream
430  *
431  * Note: the caller should be responsible for free the memory of
432  * xasl_stream. the free function should be free_and_init().
433  */
434 int
435 xts_map_func_pred_to_stream (const FUNC_PRED * xasl_tree, char **xasl_stream, int *xasl_stream_size)
436 {
437  int offset;
438  int header_size, body_size;
439  char *p;
440  int test;
441 
442  if (!xasl_tree || !xasl_stream || !xasl_stream_size)
443  {
445  }
446 
448 
449  /* reserve space for new XASL format */
450  header_size = 0;
451 
452  offset = sizeof (int) /* [size of header data] */
453  + header_size /* [header data] */
454  + sizeof (int); /* [size of body data] */
455  offset = xasl_stream_make_align (offset);
456 
458 
459  /* save XASL tree into body data of the stream buffer */
460  if (xts_save_func_pred (xasl_tree) == ER_FAILED)
461  {
462  if (xts_Stream_buffer)
463  {
465  }
466  goto end;
467  }
468 
469  /* make header size and data of new XASL format */
470  p = or_pack_int (xts_Stream_buffer, header_size);
471 
472  /* set body size of new XASL format */
473  body_size = xts_Free_offset_in_stream - offset;
474  p = or_pack_int (p, body_size);
475 
476  /* set result */
477  *xasl_stream = xts_Stream_buffer;
478  *xasl_stream_size = xts_Free_offset_in_stream;
479 
480 end:
481  /* free all memories */
483 
485  xts_Stream_size = 0;
487  or_unpack_int (*xasl_stream, &test);
488  return xts_Xasl_errcode;
489 }
490 
491 static int
493 {
494  int offset;
495  int size;
496  OR_ALIGNED_BUF (sizeof (*aggregate) * 2) a_buf;
497  char *buf = OR_ALIGNED_BUF_START (a_buf);
498  char *buf_p = NULL;
499  bool is_buf_alloced = false;
500 
501  if (aggregate == NULL)
502  {
503  return NO_ERROR;
504  }
505 
506  offset = xts_get_offset_visited_ptr (aggregate);
507  if (offset != ER_FAILED)
508  {
509  return offset;
510  }
511 
512  size = xts_sizeof_aggregate_type (aggregate);
513  if (size == ER_FAILED)
514  {
515  return ER_FAILED;
516  }
517 
518  offset = xts_reserve_location_in_stream (size);
519  if (offset == ER_FAILED || xts_mark_ptr_visited (aggregate, offset) == ER_FAILED)
520  {
521  return ER_FAILED;
522  }
523 
524  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
525  {
526  buf_p = buf;
527  }
528  else
529  {
530  buf_p = (char *) malloc (size);
531  if (buf_p == NULL)
532  {
534  return ER_FAILED;
535  }
536 
537  is_buf_alloced = true;
538  }
539 
540  buf = xts_process_aggregate_type (buf_p, aggregate);
541  if (buf == NULL)
542  {
543  offset = ER_FAILED;
544  goto end;
545  }
546  assert (buf <= buf_p + size);
547 
548  memcpy (&xts_Stream_buffer[offset], buf_p, size);
549 
550 end:
551  if (is_buf_alloced)
552  {
553  free_and_init (buf_p);
554  }
555 
556  return offset;
557 }
558 
559 static int
561 {
562  int offset;
563  int size;
564  OR_ALIGNED_BUF (sizeof (*function) * 2) a_buf;
565  char *buf = OR_ALIGNED_BUF_START (a_buf);
566  char *buf_p = NULL;
567  bool is_buf_alloced = false;
568 
569  if (function == NULL)
570  {
571  return NO_ERROR;
572  }
573 
574  offset = xts_get_offset_visited_ptr (function);
575  if (offset != ER_FAILED)
576  {
577  return offset;
578  }
579 
580  size = xts_sizeof_function_type (function);
581  if (size == ER_FAILED)
582  {
583  return ER_FAILED;
584  }
585 
586  offset = xts_reserve_location_in_stream (size);
587  if (offset == ER_FAILED || xts_mark_ptr_visited (function, offset) == ER_FAILED)
588  {
589  return ER_FAILED;
590  }
591 
592  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
593  {
594  buf_p = buf;
595  }
596  else
597  {
598  buf_p = (char *) malloc (size);
599  if (buf_p == NULL)
600  {
602  return ER_FAILED;
603  }
604 
605  is_buf_alloced = true;
606  }
607 
608  buf = xts_process_function_type (buf_p, function);
609  if (buf == NULL)
610  {
611  offset = ER_FAILED;
612  goto end;
613  }
614  assert (buf <= buf_p + size);
615 
616  memcpy (&xts_Stream_buffer[offset], buf_p, size);
617 
618 end:
619  if (is_buf_alloced)
620  {
621  free_and_init (buf_p);
622  }
623 
624  return offset;
625 }
626 
627 static int
629 {
630  int offset;
631  int size;
632  OR_ALIGNED_BUF (sizeof (*analytic) * 2) a_buf;
633  char *buf = OR_ALIGNED_BUF_START (a_buf);
634  char *buf_p = NULL;
635  bool is_buf_alloced = false;
636 
637  if (analytic == NULL)
638  {
639  return NO_ERROR;
640  }
641 
642  offset = xts_get_offset_visited_ptr (analytic);
643  if (offset != ER_FAILED)
644  {
645  return offset;
646  }
647 
648  size = xts_sizeof_analytic_type (analytic);
649  if (size == ER_FAILED)
650  {
651  return ER_FAILED;
652  }
653 
654  offset = xts_reserve_location_in_stream (size);
655  if (offset == ER_FAILED || xts_mark_ptr_visited (analytic, offset) == ER_FAILED)
656  {
657  return ER_FAILED;
658  }
659 
660  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
661  {
662  buf_p = buf;
663  }
664  else
665  {
666  buf_p = (char *) malloc (size);
667  if (buf_p == NULL)
668  {
670  return ER_FAILED;
671  }
672 
673  is_buf_alloced = true;
674  }
675 
676  if (xts_process_analytic_type (buf_p, analytic) == NULL)
677  {
678  offset = ER_FAILED;
679  goto end;
680  }
681 
682  memcpy (&xts_Stream_buffer[offset], buf_p, size);
683 
684 end:
685  if (is_buf_alloced)
686  {
687  free_and_init (buf_p);
688  }
689 
690  return offset;
691 }
692 
693 static int
695 {
696  int offset;
697  int size;
698  OR_ALIGNED_BUF (sizeof (*analytic_eval) * 2) a_buf;
699  char *buf = OR_ALIGNED_BUF_START (a_buf);
700  char *buf_p = NULL;
701  bool is_buf_alloced = false;
702 
703  if (analytic_eval == NULL)
704  {
705  return NO_ERROR;
706  }
707 
708  offset = xts_get_offset_visited_ptr (analytic_eval);
709  if (offset != ER_FAILED)
710  {
711  return offset;
712  }
713 
714  size = xts_sizeof_analytic_eval_type (analytic_eval);
715  if (size == ER_FAILED)
716  {
717  return ER_FAILED;
718  }
719 
720  offset = xts_reserve_location_in_stream (size);
721  if (offset == ER_FAILED || xts_mark_ptr_visited (analytic_eval, offset) == ER_FAILED)
722  {
723  return ER_FAILED;
724  }
725 
726  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
727  {
728  buf_p = buf;
729  }
730  else
731  {
732  buf_p = (char *) malloc (size);
733  if (buf_p == NULL)
734  {
736  return ER_FAILED;
737  }
738 
739  is_buf_alloced = true;
740  }
741 
742  if (xts_process_analytic_eval_type (buf_p, analytic_eval) == NULL)
743  {
744  offset = ER_FAILED;
745  goto end;
746  }
747 
748  memcpy (&xts_Stream_buffer[offset], buf_p, size);
749 
750 end:
751  if (is_buf_alloced)
752  {
753  free_and_init (buf_p);
754  }
755 
756  return offset;
757 }
758 
759 static int
761 {
762  int offset;
763  int size;
764  OR_ALIGNED_BUF (sizeof (*sort_list_id) * 2) a_buf;
765  char *buf = OR_ALIGNED_BUF_START (a_buf);
766  char *buf_p = NULL;
767  bool is_buf_alloced = false;
768 
769  if (sort_list_id == NULL)
770  {
771  return NO_ERROR;
772  }
773 
774  offset = xts_get_offset_visited_ptr (sort_list_id);
775  if (offset != ER_FAILED)
776  {
777  return offset;
778  }
779 
780  size = xts_sizeof_srlist_id (sort_list_id);
781  if (size == ER_FAILED)
782  {
783  return ER_FAILED;
784  }
785 
786  offset = xts_reserve_location_in_stream (size);
787  if (offset == ER_FAILED || xts_mark_ptr_visited (sort_list_id, offset) == ER_FAILED)
788  {
789  return ER_FAILED;
790  }
791 
792  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
793  {
794  buf_p = buf;
795  }
796  else
797  {
798  buf_p = (char *) malloc (size);
799  if (buf_p == NULL)
800  {
802  return ER_FAILED;
803  }
804 
805  is_buf_alloced = true;
806  }
807 
808  buf = xts_process_srlist_id (buf_p, sort_list_id);
809  if (buf == NULL)
810  {
811  offset = ER_FAILED;
812  goto end;
813  }
814  assert (buf <= buf_p + size);
815 
816  memcpy (&xts_Stream_buffer[offset], buf_p, size);
817 
818 end:
819  if (is_buf_alloced)
820  {
821  free_and_init (buf_p);
822  }
823 
824  return offset;
825 }
826 
827 static int
829 {
830  int offset;
831  int size;
832  OR_ALIGNED_BUF (sizeof (*list_id) * 2) a_buf;
833  char *buf = OR_ALIGNED_BUF_START (a_buf);
834  char *buf_p = NULL;
835  bool is_buf_alloced = false;
836 
837  if (list_id == NULL)
838  {
839  return NO_ERROR;
840  }
841 
842  offset = xts_get_offset_visited_ptr (list_id);
843  if (offset != ER_FAILED)
844  {
845  return offset;
846  }
847 
848  size = xts_sizeof_list_id (list_id);
849  if (size == ER_FAILED)
850  {
851  return ER_FAILED;
852  }
853 
854  offset = xts_reserve_location_in_stream (size);
855  if (offset == ER_FAILED || xts_mark_ptr_visited (list_id, offset) == ER_FAILED)
856  {
857  return ER_FAILED;
858  }
859 
860  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
861  {
862  buf_p = buf;
863  }
864  else
865  {
866  buf_p = (char *) malloc (size);
867  if (buf_p == NULL)
868  {
870  return ER_FAILED;
871  }
872 
873  is_buf_alloced = true;
874  }
875 
876  buf = xts_process_list_id (buf_p, list_id);
877  if (buf == NULL)
878  {
879  offset = ER_FAILED;
880  goto end;
881  }
882  assert (buf <= buf_p + size);
883 
884  memcpy (&xts_Stream_buffer[offset], buf_p, size);
885 
886 end:
887  if (is_buf_alloced)
888  {
889  free_and_init (buf_p);
890  }
891 
892  return offset;
893 }
894 
895 static int
896 xts_save_arith_type (const ARITH_TYPE * arithmetic)
897 {
898  int offset;
899  int size;
900  OR_ALIGNED_BUF (sizeof (*arithmetic) * 2) a_buf;
901  char *buf = OR_ALIGNED_BUF_START (a_buf);
902  char *buf_p = NULL;
903  bool is_buf_alloced = false;
904 
905  if (arithmetic == NULL)
906  {
907  return NO_ERROR;
908  }
909 
910  offset = xts_get_offset_visited_ptr (arithmetic);
911  if (offset != ER_FAILED)
912  {
913  return offset;
914  }
915 
916  size = xts_sizeof_arith_type (arithmetic);
917  if (size == ER_FAILED)
918  {
919  return ER_FAILED;
920  }
921 
922  offset = xts_reserve_location_in_stream (size);
923  if (offset == ER_FAILED || xts_mark_ptr_visited (arithmetic, offset) == ER_FAILED)
924  {
925  return ER_FAILED;
926  }
927 
928  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
929  {
930  buf_p = buf;
931  }
932  else
933  {
934  buf_p = (char *) malloc (size);
935  if (buf_p == NULL)
936  {
938  return ER_FAILED;
939  }
940 
941  is_buf_alloced = true;
942  }
943 
944  buf = xts_process_arith_type (buf_p, arithmetic);
945  if (buf == NULL)
946  {
947  offset = ER_FAILED;
948  goto end;
949  }
950  assert (buf <= buf_p + size);
951 
952  memcpy (&xts_Stream_buffer[offset], buf_p, size);
953 
954 end:
955  if (is_buf_alloced)
956  {
957  free_and_init (buf_p);
958  }
959 
960  return offset;
961 }
962 
963 static int
965 {
966  int offset;
967  int size;
968  OR_ALIGNED_BUF (sizeof (*indx_info) * 2) a_buf;
969  char *buf = OR_ALIGNED_BUF_START (a_buf);
970  char *buf_p = NULL;
971  bool is_buf_alloced = false;
972 
973  if (indx_info == NULL)
974  {
975  return NO_ERROR;
976  }
977 
978  offset = xts_get_offset_visited_ptr (indx_info);
979  if (offset != ER_FAILED)
980  {
981  return offset;
982  }
983 
984  size = xts_sizeof_indx_info (indx_info);
985  if (size == ER_FAILED)
986  {
987  return ER_FAILED;
988  }
989 
990  offset = xts_reserve_location_in_stream (size);
991  if (offset == ER_FAILED || xts_mark_ptr_visited (indx_info, offset) == ER_FAILED)
992  {
993  return ER_FAILED;
994  }
995 
996  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
997  {
998  buf_p = buf;
999  }
1000  else
1001  {
1002  buf_p = (char *) malloc (size);
1003  if (buf_p == NULL)
1004  {
1006  return ER_FAILED;
1007  }
1008 
1009  is_buf_alloced = true;
1010  }
1011 
1012  buf = xts_process_indx_info (buf_p, indx_info);
1013  if (buf == NULL)
1014  {
1015  offset = ER_FAILED;
1016  goto end;
1017  }
1018  assert (buf <= buf_p + size);
1019 
1020  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1021 
1022 end:
1023  if (is_buf_alloced)
1024  {
1025  free_and_init (buf_p);
1026  }
1027 
1028  return offset;
1029 }
1030 
1031 static int
1032 xts_save_outptr_list (const OUTPTR_LIST * outptr_list)
1033 {
1034  int offset;
1035  int size;
1036  OR_ALIGNED_BUF (sizeof (*outptr_list) * 2) a_buf;
1037  char *buf = OR_ALIGNED_BUF_START (a_buf);
1038  char *buf_p = NULL;
1039  bool is_buf_alloced = false;
1040 
1041  if (outptr_list == NULL)
1042  {
1043  return NO_ERROR;
1044  }
1045 
1046  offset = xts_get_offset_visited_ptr (outptr_list);
1047  if (offset != ER_FAILED)
1048  {
1049  return offset;
1050  }
1051 
1052  size = xts_sizeof_outptr_list (outptr_list);
1053  if (size == ER_FAILED)
1054  {
1055  return ER_FAILED;
1056  }
1057 
1058  offset = xts_reserve_location_in_stream (size);
1059  if (offset == ER_FAILED || xts_mark_ptr_visited (outptr_list, offset) == ER_FAILED)
1060  {
1061  return ER_FAILED;
1062  }
1063 
1064  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1065  {
1066  buf_p = buf;
1067  }
1068  else
1069  {
1070  buf_p = (char *) malloc (size);
1071  if (buf_p == NULL)
1072  {
1074  return ER_FAILED;
1075  }
1076 
1077  is_buf_alloced = true;
1078  }
1079 
1080  buf = xts_process_outptr_list (buf_p, outptr_list);
1081  if (buf == NULL)
1082  {
1083  offset = ER_FAILED;
1084  goto end;
1085  }
1086  assert (buf <= buf_p + size);
1087 
1088  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1089 
1090 end:
1091  if (is_buf_alloced)
1092  {
1093  free_and_init (buf_p);
1094  }
1095 
1096  return offset;
1097 }
1098 
1099 static int
1101 {
1102  int offset;
1103  int size;
1104  OR_ALIGNED_BUF (sizeof (*selupd_list) * 2) a_buf;
1105  char *buf = OR_ALIGNED_BUF_START (a_buf);
1106  char *buf_p = NULL;
1107  bool is_buf_alloced = false;
1108 
1109  if (selupd_list == NULL)
1110  {
1111  return NO_ERROR;
1112  }
1113 
1114  offset = xts_get_offset_visited_ptr (selupd_list);
1115  if (offset != ER_FAILED)
1116  {
1117  return offset;
1118  }
1119 
1120  size = xts_sizeof_selupd_list (selupd_list);
1121  if (size == ER_FAILED)
1122  {
1123  return ER_FAILED;
1124  }
1125 
1126  offset = xts_reserve_location_in_stream (size);
1127  if (offset == ER_FAILED || xts_mark_ptr_visited (selupd_list, offset) == ER_FAILED)
1128  {
1129  return ER_FAILED;
1130  }
1131 
1132  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1133  {
1134  buf_p = buf;
1135  }
1136  else
1137  {
1138  buf_p = (char *) malloc (size);
1139  if (buf_p == NULL)
1140  {
1142  return ER_FAILED;
1143  }
1144 
1145  is_buf_alloced = true;
1146  }
1147 
1148  buf = xts_process_selupd_list (buf_p, selupd_list);
1149  if (buf == NULL)
1150  {
1151  offset = ER_FAILED;
1152  goto end;
1153  }
1154  assert (buf <= buf_p + size);
1155 
1156  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1157 
1158 end:
1159  if (is_buf_alloced)
1160  {
1161  free_and_init (buf_p);
1162  }
1163 
1164  return offset;
1165 }
1166 
1167 static int
1168 xts_save_pred_expr (const PRED_EXPR * pred_expr)
1169 {
1170  int offset;
1171  int size;
1172  OR_ALIGNED_BUF (sizeof (*pred_expr) * 2) a_buf;
1173  char *buf = OR_ALIGNED_BUF_START (a_buf);
1174  char *buf_p = NULL;
1175  bool is_buf_alloced = false;
1176 
1177  if (pred_expr == NULL)
1178  {
1179  return NO_ERROR;
1180  }
1181 
1182  offset = xts_get_offset_visited_ptr (pred_expr);
1183  if (offset != ER_FAILED)
1184  {
1185  return offset;
1186  }
1187 
1188  size = xts_sizeof_pred_expr (pred_expr);
1189  if (size == ER_FAILED)
1190  {
1191  return ER_FAILED;
1192  }
1193 
1194  offset = xts_reserve_location_in_stream (size);
1195  if (offset == ER_FAILED || xts_mark_ptr_visited (pred_expr, offset) == ER_FAILED)
1196  {
1197  return ER_FAILED;
1198  }
1199 
1200  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1201  {
1202  buf_p = buf;
1203  }
1204  else
1205  {
1206  buf_p = (char *) malloc (size);
1207  if (buf_p == NULL)
1208  {
1210  return ER_FAILED;
1211  }
1212 
1213  is_buf_alloced = true;
1214  }
1215 
1216  buf = xts_process_pred_expr (buf_p, pred_expr);
1217  if (buf == NULL)
1218  {
1219  offset = ER_FAILED;
1220  goto end;
1221  }
1222  assert (buf <= buf_p + size);
1223 
1224  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1225 
1226 end:
1227  if (is_buf_alloced)
1228  {
1229  free_and_init (buf_p);
1230  }
1231 
1232  return offset;
1233 }
1234 
1235 static int
1237 {
1238  int offset;
1239  int size;
1240  OR_ALIGNED_BUF (sizeof (*regu_var) * 2) a_buf;
1241  char *buf = OR_ALIGNED_BUF_START (a_buf);
1242  char *buf_p = NULL;
1243  bool is_buf_alloced = false;
1244 
1245  if (regu_var == NULL)
1246  {
1247  return NO_ERROR;
1248  }
1249 
1250  offset = xts_get_offset_visited_ptr (regu_var);
1251  if (offset != ER_FAILED)
1252  {
1253  return offset;
1254  }
1255 
1256  size = xts_sizeof_regu_variable (regu_var);
1257  if (size == ER_FAILED)
1258  {
1259  return ER_FAILED;
1260  }
1261 
1262  offset = xts_reserve_location_in_stream (size);
1263  if (offset == ER_FAILED || xts_mark_ptr_visited (regu_var, offset) == ER_FAILED)
1264  {
1265  return ER_FAILED;
1266  }
1267 
1268  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1269  {
1270  buf_p = buf;
1271  }
1272  else
1273  {
1274  buf_p = (char *) malloc (size);
1275  if (buf_p == NULL)
1276  {
1278  return ER_FAILED;
1279  }
1280 
1281  is_buf_alloced = true;
1282  }
1283 
1284  buf = xts_process_regu_variable (buf_p, regu_var);
1285  if (buf == NULL)
1286  {
1287  offset = ER_FAILED;
1288  goto end;
1289  }
1290  assert (buf <= buf_p + size);
1291 
1292  /*
1293  * OR_VALUE_ALIGNED_SIZE may reserve more bytes
1294  * suppress valgrind UMW (uninitialized memory write)
1295  */
1296 #if !defined(NDEBUG)
1297  do
1298  {
1299  int margin = size - CAST_BUFLEN (buf - buf_p);
1300  if (margin > 0)
1301  {
1302  memset (buf, 0, margin);
1303  }
1304  }
1305  while (0);
1306 #endif
1307 
1308  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1309 
1310 end:
1311  if (is_buf_alloced)
1312  {
1313  free_and_init (buf_p);
1314  }
1315 
1316  return offset;
1317 }
1318 
1319 static int
1321 {
1322  int offset;
1323  int size;
1324  OR_ALIGNED_BUF (sizeof (*sort_list) * 2) a_buf;
1325  char *buf = OR_ALIGNED_BUF_START (a_buf);
1326  char *buf_p = NULL;
1327  bool is_buf_alloced = false;
1328 
1329  if (sort_list == NULL)
1330  {
1331  return NO_ERROR;
1332  }
1333 
1334  offset = xts_get_offset_visited_ptr (sort_list);
1335  if (offset != ER_FAILED)
1336  {
1337  return offset;
1338  }
1339 
1340  size = xts_sizeof_sort_list (sort_list);
1341  if (size == ER_FAILED)
1342  {
1343  return ER_FAILED;
1344  }
1345 
1346  offset = xts_reserve_location_in_stream (size);
1347  if (offset == ER_FAILED || xts_mark_ptr_visited (sort_list, offset) == ER_FAILED)
1348  {
1349  return ER_FAILED;
1350  }
1351 
1352  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1353  {
1354  buf_p = buf;
1355  }
1356  else
1357  {
1358  buf_p = (char *) malloc (size);
1359  if (buf_p == NULL)
1360  {
1362  return ER_FAILED;
1363  }
1364 
1365  is_buf_alloced = true;
1366  }
1367 
1368  buf = xts_process_sort_list (buf_p, sort_list);
1369  if (buf == NULL)
1370  {
1371  offset = ER_FAILED;
1372  goto end;
1373  }
1374  assert (buf <= buf_p + size);
1375 
1376  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1377 
1378 end:
1379  if (is_buf_alloced)
1380  {
1381  free_and_init (buf_p);
1382  }
1383 
1384  return offset;
1385 }
1386 
1387 static int
1388 xts_save_val_list (const VAL_LIST * val_list)
1389 {
1390  int offset;
1391  int size;
1392  OR_ALIGNED_BUF (sizeof (*val_list) * 2) a_buf;
1393  char *buf = OR_ALIGNED_BUF_START (a_buf);
1394  char *buf_p = NULL;
1395  bool is_buf_alloced = false;
1396 
1397  if (val_list == NULL)
1398  {
1399  return NO_ERROR;
1400  }
1401 
1402  offset = xts_get_offset_visited_ptr (val_list);
1403  if (offset != ER_FAILED)
1404  {
1405  return offset;
1406  }
1407 
1408  size = xts_sizeof_val_list (val_list);
1409  if (size == ER_FAILED)
1410  {
1411  return ER_FAILED;
1412  }
1413 
1414  offset = xts_reserve_location_in_stream (size);
1415  if (offset == ER_FAILED || xts_mark_ptr_visited (val_list, offset) == ER_FAILED)
1416  {
1417  return ER_FAILED;
1418  }
1419 
1420  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1421  {
1422  buf_p = buf;
1423  }
1424  else
1425  {
1426  buf_p = (char *) malloc (size);
1427  if (buf_p == NULL)
1428  {
1430  return ER_FAILED;
1431  }
1432 
1433  is_buf_alloced = true;
1434  }
1435 
1436  buf = xts_process_val_list (buf_p, val_list);
1437  if (buf == NULL)
1438  {
1439  offset = ER_FAILED;
1440  goto end;
1441  }
1442  assert (buf <= buf_p + size);
1443 
1444  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1445 
1446 end:
1447  if (is_buf_alloced)
1448  {
1449  free_and_init (buf_p);
1450  }
1451 
1452  return offset;
1453 }
1454 
1455 static int
1457 {
1458  int offset;
1459  int size;
1460  OR_ALIGNED_BUF (sizeof (*value) * 2) a_buf;
1461  char *buf = OR_ALIGNED_BUF_START (a_buf);
1462  char *buf_p = NULL;
1463  bool is_buf_alloced = false;
1464 
1465  if (value == NULL)
1466  {
1467  return NO_ERROR;
1468  }
1469 
1470  offset = xts_get_offset_visited_ptr (value);
1471  if (offset != ER_FAILED)
1472  {
1473  return offset;
1474  }
1475 
1476  size = xts_sizeof_db_value (value);
1477  if (size == ER_FAILED)
1478  {
1479  return ER_FAILED;
1480  }
1481 
1482  offset = xts_reserve_location_in_stream (size);
1483  if (offset == ER_FAILED || xts_mark_ptr_visited (value, offset) == ER_FAILED)
1484  {
1485  return ER_FAILED;
1486  }
1487 
1488  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1489  {
1490  buf_p = buf;
1491  }
1492  else
1493  {
1494  buf_p = (char *) malloc (size);
1495  if (buf_p == NULL)
1496  {
1498  return ER_FAILED;
1499  }
1500 
1501  is_buf_alloced = true;
1502  }
1503 
1504  buf = xts_process_db_value (buf_p, value);
1505  if (buf == NULL)
1506  {
1507  offset = ER_FAILED;
1508  goto end;
1509  }
1510  assert (buf <= buf_p + size);
1511 
1512  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1513 
1514 end:
1515  if (is_buf_alloced)
1516  {
1517  free_and_init (buf_p);
1518  }
1519 
1520  return offset;
1521 }
1522 
1523 static int
1525 {
1526  int offset;
1527  int size;
1528  OR_ALIGNED_BUF (sizeof (*xasl) * 2) a_buf;
1529  char *buf = OR_ALIGNED_BUF_START (a_buf);
1530  char *buf_p = NULL;
1531  bool is_buf_alloced = false;
1532 
1533  if (xasl == NULL)
1534  {
1535  return NO_ERROR;
1536  }
1537 
1538  offset = xts_get_offset_visited_ptr (xasl);
1539  if (offset != ER_FAILED)
1540  {
1541  return offset;
1542  }
1543 
1544  size = xts_sizeof_xasl_node (xasl);
1545  if (size == ER_FAILED)
1546  {
1547  return ER_FAILED;
1548  }
1549 
1550  offset = xts_reserve_location_in_stream (size);
1551  if (offset == ER_FAILED || xts_mark_ptr_visited (xasl, offset) == ER_FAILED)
1552  {
1553  return ER_FAILED;
1554  }
1555 
1556  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1557  {
1558  buf_p = buf;
1559  }
1560  else
1561  {
1562  buf_p = (char *) malloc (size);
1563  if (buf_p == NULL)
1564  {
1566  return ER_FAILED;
1567  }
1568 
1569  is_buf_alloced = true;
1570  }
1571 
1572  buf = xts_process_xasl_node (buf_p, xasl);
1573  if (buf == NULL)
1574  {
1575  offset = ER_FAILED;
1576  goto end;
1577  }
1578 
1579  assert (buf <= buf_p + size);
1580 
1581  /*
1582  * OR_DOUBLE_ALIGNED_SIZE may reserve more bytes
1583  * suppress valgrind UMW (uninitialized memory write)
1584  */
1585 #if !defined(NDEBUG)
1586  do
1587  {
1588  int margin = size - CAST_BUFLEN (buf - buf_p);
1589  if (margin > 0)
1590  {
1591  memset (buf, 0, margin);
1592  }
1593  }
1594  while (0);
1595 #endif
1596 
1597  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1598 
1599 end:
1600  if (is_buf_alloced)
1601  {
1602  free_and_init (buf_p);
1603  }
1604 
1605  return offset;
1606 }
1607 
1608 static int
1610 {
1611  int offset;
1612  int size;
1613  OR_ALIGNED_BUF (sizeof (*pred) * 2) a_buf;
1614  char *buf = OR_ALIGNED_BUF_START (a_buf);
1615  char *buf_p = NULL;
1616  bool is_buf_alloced = false;
1617 
1618  if (pred == NULL)
1619  {
1620  return NO_ERROR;
1621  }
1622 
1623  offset = xts_get_offset_visited_ptr (pred);
1624  if (offset != ER_FAILED)
1625  {
1626  return offset;
1627  }
1628 
1629  size = xts_sizeof_filter_pred_node (pred);
1630  if (size == ER_FAILED)
1631  {
1632  return ER_FAILED;
1633  }
1634 
1635  offset = xts_reserve_location_in_stream (size);
1636  if (offset == ER_FAILED || xts_mark_ptr_visited (pred, offset) == ER_FAILED)
1637  {
1638  return ER_FAILED;
1639  }
1640 
1641  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1642  {
1643  buf_p = buf;
1644  }
1645  else
1646  {
1647  buf_p = (char *) malloc (size);
1648  if (buf_p == NULL)
1649  {
1651  return ER_FAILED;
1652  }
1653 
1654  is_buf_alloced = true;
1655  }
1656 
1657  buf = xts_process_filter_pred_node (buf_p, pred);
1658  if (buf == NULL)
1659  {
1660  offset = ER_FAILED;
1661  goto end;
1662  }
1663  assert (buf <= buf_p + size);
1664 
1665  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1666 
1667 end:
1668  if (is_buf_alloced)
1669  {
1670  free_and_init (buf_p);
1671  }
1672 
1673  return offset;
1674 }
1675 
1676 static int
1678 {
1679  int offset;
1680  int size;
1681  OR_ALIGNED_BUF (sizeof (*func_pred) * 2) a_buf;
1682  char *buf = OR_ALIGNED_BUF_START (a_buf);
1683  char *buf_p = NULL;
1684  bool is_buf_alloced = false;
1685 
1686  if (func_pred == NULL)
1687  {
1688  return NO_ERROR;
1689  }
1690 
1691  offset = xts_get_offset_visited_ptr (func_pred);
1692  if (offset != ER_FAILED)
1693  {
1694  return offset;
1695  }
1696 
1697  size = xts_sizeof_func_pred (func_pred);
1698  if (size == ER_FAILED)
1699  {
1700  return ER_FAILED;
1701  }
1702 
1703  offset = xts_reserve_location_in_stream (size);
1704  if (offset == ER_FAILED || xts_mark_ptr_visited (func_pred, offset) == ER_FAILED)
1705  {
1706  return ER_FAILED;
1707  }
1708 
1709  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1710  {
1711  buf_p = buf;
1712  }
1713  else
1714  {
1715  buf_p = (char *) malloc (size);
1716  if (buf_p == NULL)
1717  {
1719  return ER_FAILED;
1720  }
1721 
1722  is_buf_alloced = true;
1723  }
1724 
1725  buf = xts_process_func_pred (buf_p, func_pred);
1726  if (buf == NULL)
1727  {
1728  offset = ER_FAILED;
1729  goto end;
1730  }
1731  assert (buf <= buf_p + size);
1732 
1733  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1734 
1735 end:
1736  if (is_buf_alloced)
1737  {
1738  free_and_init (buf_p);
1739  }
1740 
1741  return offset;
1742 }
1743 
1744 static int
1746 {
1747  int offset;
1748  int size;
1749  OR_ALIGNED_BUF (sizeof (*attrinfo) * 2) a_buf;
1750  char *buf = OR_ALIGNED_BUF_START (a_buf);
1751  char *buf_p = NULL;
1752  bool is_buf_alloced = false;
1753 
1754  if (attrinfo == NULL)
1755  {
1756  return NO_ERROR;
1757  }
1758 
1759  offset = xts_get_offset_visited_ptr (attrinfo);
1760  if (offset != ER_FAILED)
1761  {
1762  return offset;
1763  }
1764 
1765  size = xts_sizeof_cache_attrinfo (attrinfo);
1766  if (size == ER_FAILED)
1767  {
1768  return ER_FAILED;
1769  }
1770 
1771  offset = xts_reserve_location_in_stream (size);
1772  if (offset == ER_FAILED || xts_mark_ptr_visited (attrinfo, offset) == ER_FAILED)
1773  {
1774  return ER_FAILED;
1775  }
1776 
1777  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1778  {
1779  buf_p = buf;
1780  }
1781  else
1782  {
1783  buf_p = (char *) malloc (size);
1784  if (buf_p == NULL)
1785  {
1787  return ER_FAILED;
1788  }
1789 
1790  is_buf_alloced = true;
1791  }
1792 
1793  buf = xts_process_cache_attrinfo (buf_p);
1794  if (buf == NULL)
1795  {
1796  offset = ER_FAILED;
1797  goto end;
1798  }
1799  assert (buf <= buf_p + size);
1800 
1801  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1802 
1803 end:
1804  if (is_buf_alloced)
1805  {
1806  free_and_init (buf_p);
1807  }
1808 
1809  return offset;
1810 }
1811 
1812 #if 0
1813 /*
1814  * there are currently no pointers to these type of structures in xasl
1815  * so there is no need to have a separate restore function.
1816  */
1817 
1818 static int
1819 xts_save_merge_list_info (const MERGELIST_PROC_NODE * mergelist_proc)
1820 {
1821  int offset;
1822  int size;
1823  OR_ALIGNED_BUF (sizeof (*mergelist_proc) * 2) a_buf;
1824  char *buf = OR_ALIGNED_BUF_START (a_buf);
1825  char *buf_p = NULL;
1826  bool is_buf_alloced = false;
1827 
1828  if (mergelist_proc == NULL)
1829  {
1830  return NO_ERROR;
1831  }
1832 
1833  offset = xts_get_offset_visited_ptr (mergelist_proc);
1834  if (offset != ER_FAILED)
1835  {
1836  return offset;
1837  }
1838 
1839  size = xts_sizeof_merge_list_info (mergelist_proc);
1840  if (size == ER_FAILED)
1841  {
1842  return ER_FAILED;
1843  }
1844 
1845  offset = xts_reserve_location_in_stream (size);
1846  if (offset == ER_FAILED || xts_mark_ptr_visited (mergelist_proc, offset) == ER_FAILED)
1847  {
1848  return ER_FAILED;
1849  }
1850 
1851  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1852  {
1853  buf_p = buf;
1854  }
1855  else
1856  {
1857  buf_p = (char *) malloc (size);
1858  if (buf_p == NULL)
1859  {
1861  return ER_FAILED;
1862  }
1863 
1864  is_buf_alloced = true;
1865  }
1866 
1867  if (xts_process_merge_list_info (buf_p, mergelist_proc) == NULL)
1868  {
1869  offset = ER_FAILED;
1870  goto end;
1871  }
1872 
1873  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1874 
1875 end:
1876  if (is_buf_alloced)
1877  {
1878  free_and_init (buf_p);
1879  }
1880 
1881  return offset;
1882 }
1883 
1884 static int
1885 xts_save_ls_merge_info (const QFILE_LIST_MERGE_INFO * list_merge_info)
1886 {
1887  int offset;
1888  int size;
1889  OR_ALIGNED_BUF (sizeof (*list_merge_info) * 2) a_buf;
1890  char *buf = OR_ALIGNED_BUF_START (a_buf);
1891  char *buf_p = NULL;
1892  bool is_buf_alloced = false;
1893 
1894  if (list_merge_info == NULL)
1895  {
1896  return NO_ERROR;
1897  }
1898 
1899  offset = xts_get_offset_visited_ptr (list_merge_info);
1900  if (offset != ER_FAILED)
1901  {
1902  return offset;
1903  }
1904 
1905  size = xts_sizeof_ls_merge_info (list_merge_info);
1906  if (size == ER_FAILED)
1907  {
1908  return ER_FAILED;
1909  }
1910 
1911  offset = xts_reserve_location_in_stream (size);
1912  if (offset == ER_FAILED || xts_mark_ptr_visited (list_merge_info, offset) == ER_FAILED)
1913  {
1914  return ER_FAILED;
1915  }
1916 
1917  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1918  {
1919  buf_p = buf;
1920  }
1921  else
1922  {
1923  buf_p = (char *) malloc (size);
1924  if (buf_p == NULL)
1925  {
1927  return ER_FAILED;
1928  }
1929 
1930  is_buf_alloced = true;
1931  }
1932 
1933  if (xts_process_ls_merge_info (buf_p, list_merge_info) == NULL)
1934  {
1935  offset = ER_FAILED;
1936  goto end;
1937  }
1938 
1939  memcpy (&xts_Stream_buffer[offset], buf_p, size);
1940 
1941 end:
1942  if (is_buf_alloced)
1943  {
1944  free_and_init (buf_p);
1945  }
1946 
1947  return offset;
1948 }
1949 
1950 static int
1951 xts_save_update_info (const UPDATE_PROC_NODE * update_proc)
1952 {
1953  int offset;
1954  int size;
1955  OR_ALIGNED_BUF (sizeof (*update_proc) * 2) a_buf;
1956  char *buf = OR_ALIGNED_BUF_START (a_buf);
1957  char *buf_p = NULL;
1958  bool is_buf_alloced = false;
1959 
1960  if (update_proc == NULL)
1961  {
1962  return NO_ERROR;
1963  }
1964 
1965  offset = xts_get_offset_visited_ptr (update_proc);
1966  if (offset != ER_FAILED)
1967  {
1968  return offset;
1969  }
1970 
1971  size = xts_sizeof_update_info (update_proc);
1972  if (size == ER_FAILED)
1973  {
1974  return ER_FAILED;
1975  }
1976 
1977  offset = xts_reserve_location_in_stream (size);
1978  if (offset == ER_FAILED || xts_mark_ptr_visited (update_proc, offset) == ER_FAILED)
1979  {
1980  return ER_FAILED;
1981  }
1982 
1983  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
1984  {
1985  buf_p = buf;
1986  }
1987  else
1988  {
1989  buf_p = (char *) malloc (size);
1990  if (buf_p == NULL)
1991  {
1993  return ER_FAILED;
1994  }
1995 
1996  is_buf_alloced = true;
1997  }
1998 
1999  if (xts_process_update_info (buf_p, update_proc) == NULL)
2000  {
2001  offset = ER_FAILED;
2002  goto end;
2003  }
2004 
2005  memcpy (&xts_Stream_buffer[offset], buf_p, size);
2006 
2007 end:
2008  if (is_buf_alloced)
2009  {
2010  free_and_init (buf_p);
2011  }
2012 
2013  return offset;
2014 }
2015 
2016 static int
2017 xts_save_delete_info (const DELETE_PROC_NODE * delete_proc)
2018 {
2019  int offset;
2020  int size;
2021  OR_ALIGNED_BUF (sizeof (*delete_proc) * 2) a_buf;
2022  char *buf = OR_ALIGNED_BUF_START (a_buf);
2023  char *buf_p = NULL;
2024  bool is_buf_alloced = false;
2025 
2026  if (delete_proc == NULL)
2027  {
2028  return NO_ERROR;
2029  }
2030 
2031  offset = xts_get_offset_visited_ptr (delete_proc);
2032  if (offset != ER_FAILED)
2033  {
2034  return offset;
2035  }
2036 
2037  size = xts_sizeof_delete_info (delete_proc);
2038  if (size == ER_FAILED)
2039  {
2040  return ER_FAILED;
2041  }
2042 
2043  offset = xts_reserve_location_in_stream (size);
2044  if (offset == ER_FAILED || xts_mark_ptr_visited (delete_proc, offset) == ER_FAILED)
2045  {
2046  return ER_FAILED;
2047  }
2048 
2049  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
2050  {
2051  buf_p = buf;
2052  }
2053  else
2054  {
2055  buf_p = (char *) malloc (size);
2056  if (buf_p == NULL)
2057  {
2059  return ER_FAILED;
2060  }
2061 
2062  is_buf_alloced = true;
2063  }
2064 
2065  if (xts_process_delete_info (buf_p, delete_proc) == NULL)
2066  {
2067  offset = ER_FAILED;
2068  goto end;
2069  }
2070 
2071  memcpy (&xts_Stream_buffer[offset], buf_p, size);
2072 
2073 end:
2074  if (is_buf_alloced)
2075  {
2076  free_and_init (buf_p);
2077  }
2078 
2079  return offset;
2080 }
2081 
2082 static int
2083 xts_save_insert_info (const INSERT_PROC_NODE * insert_proc)
2084 {
2085  int offset;
2086  int size;
2087  OR_ALIGNED_BUF (sizeof (*insert_proc) * 2) a_buf;
2088  char *buf = OR_ALIGNED_BUF_START (a_buf);
2089  char *buf_p = NULL;
2090  bool is_buf_alloced = false;
2091 
2092  if (insert_proc == NULL)
2093  {
2094  return NO_ERROR;
2095  }
2096 
2097  offset = xts_get_offset_visited_ptr (insert_proc);
2098  if (offset != ER_FAILED)
2099  {
2100  return offset;
2101  }
2102 
2103  size = xts_sizeof_insert_proc (insert_proc);
2104  if (size == ER_FAILED)
2105  {
2106  return ER_FAILED;
2107  }
2108 
2109  offset = xts_reserve_location_in_stream (size);
2110  if (offset == ER_FAILED || xts_mark_ptr_visited (insert_proc, offset) == ER_FAILED)
2111  {
2112  return ER_FAILED;
2113  }
2114 
2115  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
2116  {
2117  buf_p = buf;
2118  }
2119  else
2120  {
2121  buf_p = (char *) malloc (size);
2122  if (buf_p == NULL)
2123  {
2125  return ER_FAILED;
2126  }
2127 
2128  is_buf_alloced = true;
2129  }
2130 
2131  if (xts_process_insert_info (buf_p, insert_proc) == NULL)
2132  {
2133  offset = ER_FAILED;
2134  goto end;
2135  }
2136 
2137  memcpy (&xts_Stream_buffer[offset], buf_p, size);
2138 
2139 end:
2140  if (is_buf_alloced)
2141  {
2142  free_and_init (buf_p);
2143  }
2144 
2145  return offset;
2146 }
2147 #endif
2148 
2149 static int
2151 {
2152  int offset;
2153  int size;
2154  OR_ALIGNED_BUF (sizeof (*method_sig_list) * 2) a_buf;
2155  char *buf = OR_ALIGNED_BUF_START (a_buf);
2156  char *buf_p = NULL;
2157  bool is_buf_alloced = false;
2158 
2159  if (method_sig_list == NULL)
2160  {
2161  return NO_ERROR;
2162  }
2163 
2164  offset = xts_get_offset_visited_ptr (method_sig_list);
2165  if (offset != ER_FAILED)
2166  {
2167  return offset;
2168  }
2169 
2170  size = xts_sizeof_method_sig_list (method_sig_list);
2171  if (size == ER_FAILED)
2172  {
2173  return ER_FAILED;
2174  }
2175 
2176  offset = xts_reserve_location_in_stream (size);
2177  if (offset == ER_FAILED || xts_mark_ptr_visited (method_sig_list, offset) == ER_FAILED)
2178  {
2179  return ER_FAILED;
2180  }
2181 
2182  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
2183  {
2184  buf_p = buf;
2185  }
2186  else
2187  {
2188  buf_p = (char *) malloc (size);
2189  if (buf_p == NULL)
2190  {
2192  return ER_FAILED;
2193  }
2194 
2195  is_buf_alloced = true;
2196  }
2197 
2198  buf = xts_process_method_sig_list (buf_p, method_sig_list);
2199  if (buf == NULL)
2200  {
2201  offset = ER_FAILED;
2202  goto end;
2203  }
2204  assert (buf <= buf_p + size);
2205 
2206  memcpy (&xts_Stream_buffer[offset], buf_p, size);
2207 
2208 end:
2209  if (is_buf_alloced)
2210  {
2211  free_and_init (buf_p);
2212  }
2213 
2214  return offset;
2215 }
2216 
2217 static int
2218 xts_save_method_sig (const METHOD_SIG * method_sig, int count)
2219 {
2220  int offset;
2221  int size;
2222  OR_ALIGNED_BUF (sizeof (*method_sig) * 2) a_buf;
2223  char *buf = OR_ALIGNED_BUF_START (a_buf);
2224  char *buf_p = NULL;
2225  bool is_buf_alloced = false;
2226 
2227  if (method_sig == NULL)
2228  {
2229  assert (count == 0);
2230  return NO_ERROR;
2231  }
2232 
2233  assert (count > 0);
2234 
2235  offset = xts_get_offset_visited_ptr (method_sig);
2236  if (offset != ER_FAILED)
2237  {
2238  return offset;
2239  }
2240 
2241  size = xts_sizeof_method_sig (method_sig);
2242  if (size == ER_FAILED)
2243  {
2244  return ER_FAILED;
2245  }
2246 
2247  offset = xts_reserve_location_in_stream (size);
2248  if (offset == ER_FAILED || xts_mark_ptr_visited (method_sig, offset) == ER_FAILED)
2249  {
2250  return ER_FAILED;
2251  }
2252 
2253  if (size <= (int) OR_ALIGNED_BUF_SIZE (a_buf))
2254  {
2255  buf_p = buf;
2256  }
2257  else
2258  {
2259  buf_p = (char *) malloc (size);
2260  if (buf_p == NULL)
2261  {
2263  return ER_FAILED;
2264  }
2265 
2266  is_buf_alloced = true;
2267  }
2268 
2269  buf = xts_process_method_sig (buf_p, method_sig, count);
2270  if (buf == NULL)
2271  {
2272  offset = ER_FAILED;
2273  goto end;
2274  }
2275  assert (buf <= buf_p + size);
2276 
2277  memcpy (&xts_Stream_buffer[offset], buf_p, size);
2278 
2279 end:
2280  if (is_buf_alloced)
2281  {
2282  free_and_init (buf_p);
2283  }
2284 
2285  return offset;
2286 }
2287 
2288 static int
2289 xts_save_string (const char *string)
2290 {
2291  int offset;
2292  int packed_length, length;
2293 
2294  offset = xts_get_offset_visited_ptr (string);
2295  if (offset != ER_FAILED)
2296  {
2297  return offset;
2298  }
2299 
2300  packed_length = or_packed_string_length (string, &length);
2301 
2302  assert (string != NULL || length == 0);
2303 
2304  offset = xts_reserve_location_in_stream (packed_length);
2305  if (offset == ER_FAILED || xts_mark_ptr_visited (string, offset) == ER_FAILED)
2306  {
2307  return ER_FAILED;
2308  }
2309 
2310  or_pack_string_with_length (&xts_Stream_buffer[offset], string, length);
2311 
2312  return offset;
2313 }
2314 
2315 #if defined(ENABLE_UNUSED_FUNCTION)
2316 static int
2317 xts_save_string_with_length (const char *string, int length)
2318 {
2319  int offset;
2320 
2321  offset = xts_get_offset_visited_ptr (string);
2322  if (offset != ER_FAILED)
2323  {
2324  return offset;
2325  }
2326 
2327  offset = xts_reserve_location_in_stream (or_align_length (length));
2328  if (offset == ER_FAILED || xts_mark_ptr_visited (string, offset) == ER_FAILED)
2329  {
2330  return ER_FAILED;
2331  }
2332 
2333  or_pack_string_with_length (&xts_Stream_buffer[offset], (char *) string, length);
2334 
2335  return offset;
2336 }
2337 
2338 static int
2339 xts_save_input_vals (const char *input_vals_p, int length)
2340 {
2341  int offset;
2342 
2343  offset = xts_get_offset_visited_ptr (input_vals_p);
2344  if (offset != ER_FAILED)
2345  {
2346  return offset;
2347  }
2348 
2349  offset = xts_reserve_location_in_stream (length);
2350  if (offset == ER_FAILED || xts_mark_ptr_visited (input_vals_p, offset) == ER_FAILED)
2351  {
2352  return ER_FAILED;
2353  }
2354 
2355  memmove (&xts_Stream_buffer[offset], (char *) input_vals_p, length);
2356 
2357  return offset;
2358 }
2359 #endif
2360 
2361 static int
2362 xts_save_db_value_array (DB_VALUE ** db_value_array_p, int nelements)
2363 {
2364  int offset;
2365  int *offset_array;
2366  int i;
2367 
2368  if (db_value_array_p == NULL)
2369  {
2370  return NO_ERROR;
2371  }
2372 
2373  offset_array = (int *) malloc (sizeof (int) * nelements);
2374  if (offset_array == NULL)
2375  {
2376  return ER_FAILED;
2377  }
2378 
2379  for (i = 0; i < nelements; i++)
2380  {
2381  offset_array[i] = xts_save_db_value (db_value_array_p[i]);
2382  if (offset_array[i] == ER_FAILED)
2383  {
2384  offset = ER_FAILED;
2385  goto end;
2386  }
2387  }
2388 
2389  offset = xts_save_int_array (offset_array, nelements);
2390 
2391 end:
2392  free_and_init (offset_array);
2393 
2394  return offset;
2395 }
2396 
2397 #if defined (ENABLE_UNUSED_FUNCTION)
2398 static int
2399 xts_save_domain_array (TP_DOMAIN ** domain_array_p, int nelements)
2400 {
2401  int offset, i, len;
2402  char *ptr;
2403 
2404  if (domain_array_p == NULL)
2405  {
2406  return 0;
2407  }
2408 
2409  for (len = 0, i = 0; i < nelements; i++)
2410  {
2411  len += or_packed_domain_size (domain_array_p[i], 0);
2412  }
2413 
2414  offset = xts_reserve_location_in_stream (len);
2415  if (offset == ER_FAILED)
2416  {
2417  return ER_FAILED;
2418  }
2419 
2420  ptr = &xts_Stream_buffer[offset];
2421  for (i = 0; i < nelements; i++)
2422  {
2423  ptr = or_pack_domain (ptr, domain_array_p[i], 0, 0);
2424  }
2425 
2426  return offset;
2427 }
2428 #endif
2429 
2430 static int
2431 xts_save_int_array (int *int_array, int nelements)
2432 {
2433  int offset, i;
2434  char *ptr;
2435 
2436  if (int_array == NULL)
2437  {
2438  return 0;
2439  }
2440 
2441  offset = xts_reserve_location_in_stream (OR_INT_SIZE * nelements);
2442  if (offset == ER_FAILED)
2443  {
2444  return ER_FAILED;
2445  }
2446 
2447  ptr = &xts_Stream_buffer[offset];
2448  for (i = 0; i < nelements; ++i)
2449  {
2450  ptr = or_pack_int (ptr, int_array[i]);
2451  }
2452 
2453  return offset;
2454 }
2455 
2456 static int
2457 xts_save_hfid_array (HFID * hfid_array, int nelements)
2458 {
2459  int offset, i;
2460  char *ptr;
2461 
2462  if (hfid_array == NULL)
2463  {
2464  return 0;
2465  }
2466 
2467  offset = xts_reserve_location_in_stream (OR_HFID_SIZE * nelements);
2468  if (offset == ER_FAILED)
2469  {
2470  return ER_FAILED;
2471  }
2472 
2473  ptr = &xts_Stream_buffer[offset];
2474  for (i = 0; i < nelements; ++i)
2475  {
2476  ptr = or_pack_hfid (ptr, &hfid_array[i]);
2477  }
2478 
2479  return offset;
2480 }
2481 
2482 static int
2483 xts_save_oid_array (OID * oid_array, int nelements)
2484 {
2485  int offset, i;
2486  char *ptr;
2487 
2488  if (oid_array == NULL)
2489  {
2490  return 0;
2491  }
2492 
2493  offset = xts_reserve_location_in_stream (OR_OID_SIZE * nelements);
2494  if (offset == ER_FAILED)
2495  {
2496  return ER_FAILED;
2497  }
2498 
2499  ptr = &xts_Stream_buffer[offset];
2500  for (i = 0; i < nelements; ++i)
2501  {
2502  ptr = or_pack_oid (ptr, &oid_array[i]);
2503  }
2504 
2505  return offset;
2506 }
2507 
2508 /*
2509  * Save the regu_variable_list as an array to avoid recursion in the server.
2510  * Pack the array size first, then the array.
2511  */
2512 #define OFFSET_BUFFER_SIZE 32
2513 
2514 static int
2516 {
2517  int offset;
2518  int *regu_var_offset_table;
2519  int offset_local_buffer[OFFSET_BUFFER_SIZE];
2520  REGU_VARIABLE_LIST regu_var_p;
2521  int nelements, i;
2522 
2523  if (regu_var_list == NULL)
2524  {
2525  return 0;
2526  }
2527 
2528  offset = xts_get_offset_visited_ptr (regu_var_list);
2529  if (offset != ER_FAILED)
2530  {
2531  return offset;
2532  }
2533 
2534  nelements = 0;
2535  for (regu_var_p = regu_var_list; regu_var_p; regu_var_p = regu_var_p->next)
2536  {
2537  ++nelements;
2538  }
2539 
2540  if (OFFSET_BUFFER_SIZE <= nelements)
2541  {
2542  regu_var_offset_table = (int *) malloc (sizeof (int) * (nelements + 1));
2543  if (regu_var_offset_table == NULL)
2544  {
2545  return ER_FAILED;
2546  }
2547  }
2548  else
2549  {
2550  regu_var_offset_table = offset_local_buffer;
2551  }
2552 
2553  i = 0;
2554  regu_var_offset_table[i++] = nelements;
2555  for (regu_var_p = regu_var_list; regu_var_p; ++i, regu_var_p = regu_var_p->next)
2556  {
2557  regu_var_offset_table[i] = xts_save_regu_variable (&regu_var_p->value);
2558  if (regu_var_offset_table[i] == ER_FAILED)
2559  {
2560  if (regu_var_offset_table != offset_local_buffer)
2561  {
2562  free_and_init (regu_var_offset_table);
2563  }
2564  return ER_FAILED;
2565  }
2566  }
2567 
2568  offset = xts_save_int_array (regu_var_offset_table, nelements + 1);
2569 
2570  if (regu_var_offset_table != offset_local_buffer)
2571  {
2572  free_and_init (regu_var_offset_table);
2573  }
2574 
2575  if (offset == ER_FAILED || xts_mark_ptr_visited (regu_var_list, offset) == ER_FAILED)
2576  {
2577  return ER_FAILED;
2578  }
2579 
2580  return offset;
2581 }
2582 
2583 static int
2585 {
2586  int offset;
2587  int *regu_var_list_offset_table;
2588  int offset_local_buffer[OFFSET_BUFFER_SIZE];
2589  REGU_VARLIST_LIST regu_var_list_p;
2590  int nelements, i;
2591 
2592  if (regu_var_list_list == NULL)
2593  {
2594  return 0;
2595  }
2596 
2597  offset = xts_get_offset_visited_ptr (regu_var_list_list);
2598  if (offset != ER_FAILED)
2599  {
2600  return offset;
2601  }
2602 
2603  nelements = 0;
2604  for (regu_var_list_p = regu_var_list_list; regu_var_list_p; regu_var_list_p = regu_var_list_p->next)
2605  {
2606  ++nelements;
2607  }
2608 
2609  if (OFFSET_BUFFER_SIZE <= nelements)
2610  {
2611  regu_var_list_offset_table = (int *) malloc (sizeof (int) * (nelements + 1));
2612  if (regu_var_list_offset_table == NULL)
2613  {
2614  return ER_FAILED;
2615  }
2616  }
2617  else
2618  {
2619  regu_var_list_offset_table = offset_local_buffer;
2620  }
2621 
2622  i = 0;
2623  regu_var_list_offset_table[i++] = nelements;
2624  for (regu_var_list_p = regu_var_list_list; regu_var_list_p; ++i, regu_var_list_p = regu_var_list_p->next)
2625  {
2626  regu_var_list_offset_table[i] = xts_save_regu_variable_list (regu_var_list_p->list);
2627  if (regu_var_list_offset_table[i] == ER_FAILED)
2628  {
2629  if (regu_var_list_offset_table != offset_local_buffer)
2630  {
2631  free_and_init (regu_var_list_offset_table);
2632  }
2633  return ER_FAILED;
2634  }
2635  }
2636 
2637  offset = xts_save_int_array (regu_var_list_offset_table, nelements + 1);
2638 
2639  if (regu_var_list_offset_table != offset_local_buffer)
2640  {
2641  free_and_init (regu_var_list_offset_table);
2642  }
2643 
2644  if (offset == ER_FAILED || xts_mark_ptr_visited (regu_var_list_list, offset) == ER_FAILED)
2645  {
2646  return ER_FAILED;
2647  }
2648 
2649  return offset;
2650 }
2651 
2652 static int
2653 xts_save_key_range_array (const KEY_RANGE * key_range_array, int nelements)
2654 {
2655  int offset, i, j;
2656  int *key_range_offset_table;
2657 
2658  if (key_range_array == NULL)
2659  {
2660  return 0;
2661  }
2662 
2663  offset = xts_get_offset_visited_ptr (key_range_array);
2664  if (offset != ER_FAILED)
2665  {
2666  return offset;
2667  }
2668 
2669  key_range_offset_table = (int *) malloc (sizeof (int) * 3 * nelements);
2670  if (key_range_offset_table == NULL)
2671  {
2672  return ER_FAILED;
2673  }
2674 
2675  for (i = 0, j = 0; i < nelements; i++, j++)
2676  {
2677  key_range_offset_table[j] = key_range_array[i].range;
2678 
2679  if (key_range_array[i].key1)
2680  {
2681  key_range_offset_table[++j] = xts_save_regu_variable (key_range_array[i].key1);
2682  if (key_range_offset_table[j] == ER_FAILED)
2683  {
2684  free_and_init (key_range_offset_table);
2685  return ER_FAILED;
2686  }
2687  }
2688  else
2689  {
2690  key_range_offset_table[++j] = 0;
2691  }
2692 
2693  if (key_range_array[i].key2)
2694  {
2695  key_range_offset_table[++j] = xts_save_regu_variable (key_range_array[i].key2);
2696  if (key_range_offset_table[j] == ER_FAILED)
2697  {
2698  free_and_init (key_range_offset_table);
2699  return ER_FAILED;
2700  }
2701  }
2702  else
2703  {
2704  key_range_offset_table[++j] = 0;
2705  }
2706  }
2707 
2708  offset = xts_save_int_array (key_range_offset_table, 3 * nelements);
2709 
2710  free_and_init (key_range_offset_table);
2711 
2712  return offset;
2713 }
2714 
2715 /*
2716  * xts_process_xasl_header () - Pack XASL node header in buffer.
2717  *
2718  * return : buffer pointer after the packed XASL node header.
2719  * ptr (in) : buffer pointer where XASL node header should be packed.
2720  * header (in) : XASL node header.
2721  */
2722 static char *
2724 {
2725  if (ptr == NULL)
2726  {
2727  return NULL;
2728  }
2729  ASSERT_ALIGN (ptr, INT_ALIGNMENT);
2730 
2731  OR_PACK_XASL_NODE_HEADER (ptr, &header);
2732  return ptr;
2733 };
2734 
2735 static char *
2736 xts_process_xasl_node (char *ptr, const XASL_NODE * xasl)
2737 {
2738  int offset;
2739  int cnt;
2740  ACCESS_SPEC_TYPE *access_spec = NULL;
2741 
2742  assert (PTR_ALIGN (ptr, MAX_ALIGNMENT) == ptr);
2743 
2744  /* pack header first */
2745  ptr = xts_process_xasl_header (ptr, xasl->header);
2746 
2747  ptr = or_pack_int (ptr, xasl->type);
2748 
2749  ptr = or_pack_int (ptr, xasl->flag);
2750 
2751  if (xasl->list_id == NULL)
2752  {
2753  ptr = or_pack_int (ptr, 0);
2754  }
2755  else
2756  {
2757  offset = xts_save_list_id (xasl->list_id);
2758  if (offset == ER_FAILED)
2759  {
2760  return NULL;
2761  }
2762  ptr = or_pack_int (ptr, offset);
2763  }
2764 
2765  offset = xts_save_sort_list (xasl->after_iscan_list);
2766  if (offset == ER_FAILED)
2767  {
2768  return NULL;
2769  }
2770  ptr = or_pack_int (ptr, offset);
2771 
2772  offset = xts_save_sort_list (xasl->orderby_list);
2773  if (offset == ER_FAILED)
2774  {
2775  return NULL;
2776  }
2777  ptr = or_pack_int (ptr, offset);
2778 
2779  offset = xts_save_pred_expr (xasl->ordbynum_pred);
2780  if (offset == ER_FAILED)
2781  {
2782  return NULL;
2783  }
2784  ptr = or_pack_int (ptr, offset);
2785 
2786  offset = xts_save_db_value (xasl->ordbynum_val);
2787  if (offset == ER_FAILED)
2788  {
2789  return NULL;
2790  }
2791  ptr = or_pack_int (ptr, offset);
2792 
2793  offset = xts_save_regu_variable (xasl->orderby_limit);
2794  if (offset == ER_FAILED)
2795  {
2796  return NULL;
2797  }
2798  ptr = or_pack_int (ptr, offset);
2799 
2800  ptr = or_pack_int (ptr, xasl->ordbynum_flag);
2801 
2802  offset = xts_save_regu_variable (xasl->limit_offset);
2803  if (offset == ER_FAILED)
2804  {
2805  return NULL;
2806  }
2807  ptr = or_pack_int (ptr, offset);
2808 
2809  offset = xts_save_regu_variable (xasl->limit_row_count);
2810  if (offset == ER_FAILED)
2811  {
2812  return NULL;
2813  }
2814  ptr = or_pack_int (ptr, offset);
2815 
2816  offset = xts_save_val_list (xasl->single_tuple);
2817  if (offset == ER_FAILED)
2818  {
2819  return NULL;
2820  }
2821  ptr = or_pack_int (ptr, offset);
2822 
2823  ptr = or_pack_int (ptr, xasl->is_single_tuple);
2824 
2825  ptr = or_pack_int (ptr, xasl->option);
2826 
2827  offset = xts_save_outptr_list (xasl->outptr_list);
2828  if (offset == ER_FAILED)
2829  {
2830  return NULL;
2831  }
2832  ptr = or_pack_int (ptr, offset);
2833 
2834  offset = xts_save_selupd_list (xasl->selected_upd_list);
2835  if (offset == ER_FAILED)
2836  {
2837  return NULL;
2838  }
2839  ptr = or_pack_int (ptr, offset);
2840 
2841  for (cnt = 0, access_spec = xasl->spec_list; access_spec; access_spec = access_spec->next, cnt++)
2842  ; /* empty */
2843  ptr = or_pack_int (ptr, cnt);
2844 
2845  for (access_spec = xasl->spec_list; access_spec; access_spec = access_spec->next)
2846  {
2847  ptr = xts_process_access_spec_type (ptr, access_spec);
2848  }
2849 
2850  for (cnt = 0, access_spec = xasl->merge_spec; access_spec; access_spec = access_spec->next, cnt++)
2851  ; /* empty */
2852  ptr = or_pack_int (ptr, cnt);
2853 
2854  for (access_spec = xasl->merge_spec; access_spec; access_spec = access_spec->next)
2855  {
2856  ptr = xts_process_access_spec_type (ptr, access_spec);
2857  }
2858 
2859  offset = xts_save_val_list (xasl->val_list);
2860  if (offset == ER_FAILED)
2861  {
2862  return NULL;
2863  }
2864  ptr = or_pack_int (ptr, offset);
2865 
2866  offset = xts_save_val_list (xasl->merge_val_list);
2867  if (offset == ER_FAILED)
2868  {
2869  return NULL;
2870  }
2871  ptr = or_pack_int (ptr, offset);
2872 
2873  offset = xts_save_xasl_node (xasl->aptr_list);
2874  if (offset == ER_FAILED)
2875  {
2876  return NULL;
2877  }
2878  ptr = or_pack_int (ptr, offset);
2879 
2880  offset = xts_save_xasl_node (xasl->bptr_list);
2881  if (offset == ER_FAILED)
2882  {
2883  return NULL;
2884  }
2885  ptr = or_pack_int (ptr, offset);
2886 
2887  offset = xts_save_xasl_node (xasl->dptr_list);
2888  if (offset == ER_FAILED)
2889  {
2890  return NULL;
2891  }
2892  ptr = or_pack_int (ptr, offset);
2893 
2894  offset = xts_save_pred_expr (xasl->after_join_pred);
2895  if (offset == ER_FAILED)
2896  {
2897  return NULL;
2898  }
2899  ptr = or_pack_int (ptr, offset);
2900 
2901  offset = xts_save_pred_expr (xasl->if_pred);
2902  if (offset == ER_FAILED)
2903  {
2904  return NULL;
2905  }
2906  ptr = or_pack_int (ptr, offset);
2907 
2908  offset = xts_save_pred_expr (xasl->instnum_pred);
2909  if (offset == ER_FAILED)
2910  {
2911  return NULL;
2912  }
2913  ptr = or_pack_int (ptr, offset);
2914 
2915  offset = xts_save_db_value (xasl->instnum_val);
2916  if (offset == ER_FAILED)
2917  {
2918  return NULL;
2919  }
2920  ptr = or_pack_int (ptr, offset);
2921 
2922  offset = xts_save_db_value (xasl->save_instnum_val);
2923  if (offset == ER_FAILED)
2924  {
2925  return NULL;
2926  }
2927  ptr = or_pack_int (ptr, offset);
2928 
2929  ptr = or_pack_int (ptr, xasl->instnum_flag);
2930 
2931  offset = xts_save_xasl_node (xasl->fptr_list);
2932  if (offset == ER_FAILED)
2933  {
2934  return NULL;
2935  }
2936  ptr = or_pack_int (ptr, offset);
2937 
2938  offset = xts_save_xasl_node (xasl->scan_ptr);
2939  if (offset == ER_FAILED)
2940  {
2941  return NULL;
2942  }
2943  ptr = or_pack_int (ptr, offset);
2944 
2945  offset = xts_save_xasl_node (xasl->connect_by_ptr);
2946  if (offset == ER_FAILED)
2947  {
2948  return NULL;
2949  }
2950  ptr = or_pack_int (ptr, offset);
2951 
2952  offset = xts_save_db_value (xasl->level_val);
2953  if (offset == ER_FAILED)
2954  {
2955  return NULL;
2956  }
2957  ptr = or_pack_int (ptr, offset);
2958 
2959  offset = xts_save_regu_variable (xasl->level_regu);
2960  if (offset == ER_FAILED)
2961  {
2962  return NULL;
2963  }
2964  ptr = or_pack_int (ptr, offset);
2965 
2966  offset = xts_save_db_value (xasl->isleaf_val);
2967  if (offset == ER_FAILED)
2968  {
2969  return NULL;
2970  }
2971  ptr = or_pack_int (ptr, offset);
2972 
2973  offset = xts_save_regu_variable (xasl->isleaf_regu);
2974  if (offset == ER_FAILED)
2975  {
2976  return NULL;
2977  }
2978  ptr = or_pack_int (ptr, offset);
2979 
2980  offset = xts_save_db_value (xasl->iscycle_val);
2981  if (offset == ER_FAILED)
2982  {
2983  return NULL;
2984  }
2985  ptr = or_pack_int (ptr, offset);
2986 
2987  offset = xts_save_regu_variable (xasl->iscycle_regu);
2988  if (offset == ER_FAILED)
2989  {
2990  return NULL;
2991  }
2992  ptr = or_pack_int (ptr, offset);
2993 
2994  for (cnt = 0, access_spec = xasl->curr_spec; access_spec; access_spec = access_spec->next, cnt++)
2995  ; /* empty */
2996  ptr = or_pack_int (ptr, cnt);
2997 
2998  for (access_spec = xasl->curr_spec; access_spec; access_spec = access_spec->next)
2999  {
3000  ptr = xts_process_access_spec_type (ptr, access_spec);
3001  }
3002 
3003  ptr = or_pack_int (ptr, xasl->next_scan_on);
3004 
3005  ptr = or_pack_int (ptr, xasl->next_scan_block_on);
3006 
3007  ptr = or_pack_int (ptr, xasl->cat_fetched);
3008 
3009  ptr = or_pack_int (ptr, (int) xasl->scan_op_type);
3010 
3011  ptr = or_pack_int (ptr, xasl->upd_del_class_cnt);
3012 
3013  ptr = or_pack_int (ptr, xasl->mvcc_reev_extra_cls_cnt);
3014 
3015  /*
3016  * NOTE that the composite lock block is strictly a server side block
3017  * and is not packed.
3018  */
3019 
3020  switch (xasl->type)
3021  {
3022  case BUILDLIST_PROC:
3023  ptr = xts_process_buildlist_proc (ptr, &xasl->proc.buildlist);
3024  break;
3025 
3026  case BUILDVALUE_PROC:
3027  ptr = xts_process_buildvalue_proc (ptr, &xasl->proc.buildvalue);
3028  break;
3029 
3030  case MERGELIST_PROC:
3031  ptr = xts_process_mergelist_proc (ptr, &xasl->proc.mergelist);
3032  break;
3033 
3034  case CONNECTBY_PROC:
3035  ptr = xts_process_connectby_proc (ptr, &xasl->proc.connect_by);
3036  break;
3037 
3038  case UPDATE_PROC:
3039  ptr = xts_process_update_proc (ptr, &xasl->proc.update);
3040  break;
3041 
3042  case DELETE_PROC:
3043  ptr = xts_process_delete_proc (ptr, &xasl->proc.delete_);
3044  break;
3045 
3046  case INSERT_PROC:
3047  ptr = xts_process_insert_proc (ptr, &xasl->proc.insert);
3048  break;
3049 
3050  case UNION_PROC:
3051  case DIFFERENCE_PROC:
3052  case INTERSECTION_PROC:
3053  ptr = xts_process_union_proc (ptr, &xasl->proc.union_);
3054  break;
3055 
3056  case OBJFETCH_PROC:
3057  ptr = xts_process_fetch_proc (ptr, &xasl->proc.fetch);
3058  break;
3059 
3060  case SCAN_PROC:
3061  break;
3062 
3063  case DO_PROC:
3064  break;
3065 
3066  case MERGE_PROC:
3067  ptr = xts_process_merge_proc (ptr, &xasl->proc.merge);
3068  break;
3069 
3070  case BUILD_SCHEMA_PROC:
3071  break;
3072 
3073  case CTE_PROC:
3074  ptr = xts_process_cte_proc (ptr, &xasl->proc.cte);
3075  break;
3076 
3077  default:
3079  return NULL;
3080  }
3081 
3082  if (ptr == NULL)
3083  {
3084  return NULL;
3085  }
3086 
3087  ptr = or_pack_int (ptr, xasl->projected_size);
3088  ptr = or_pack_double (ptr, xasl->cardinality);
3089 
3090  ptr = or_pack_int (ptr, (int) xasl->iscan_oid_order);
3091 
3092  if (xasl->query_alias)
3093  {
3094  offset = xts_save_string (xasl->query_alias);
3095  }
3096  else
3097  {
3098  offset = xts_save_string ("*** EMPTY QUERY ***");
3099  }
3100  if (offset == ER_FAILED)
3101  {
3102  return NULL;
3103  }
3104  ptr = or_pack_int (ptr, offset);
3105 
3106  offset = xts_save_xasl_node (xasl->next);
3107  if (offset == ER_FAILED)
3108  {
3109  return NULL;
3110  }
3111  ptr = or_pack_int (ptr, offset);
3112 
3113  return ptr;
3114 }
3115 
3116 static char *
3118 {
3119  int offset;
3120 
3121  offset = xts_save_pred_expr (pred->pred);
3122  if (offset == ER_FAILED)
3123  {
3124  return NULL;
3125  }
3126  ptr = or_pack_int (ptr, offset);
3127 
3128  ptr = or_pack_int (ptr, pred->num_attrs_pred);
3129  offset = xts_save_int_array (pred->attrids_pred, pred->num_attrs_pred);
3130  if (offset == ER_FAILED)
3131  {
3132  return NULL;
3133  }
3134  ptr = or_pack_int (ptr, offset);
3135 
3136  offset = xts_save_cache_attrinfo (pred->cache_pred);
3137  if (offset == ER_FAILED)
3138  {
3139  return NULL;
3140  }
3141  ptr = or_pack_int (ptr, offset);
3142 
3143  return ptr;
3144 }
3145 
3146 static char *
3148 {
3149  int offset;
3150 
3151  offset = xts_save_regu_variable (func_pred->func_regu);
3152  if (offset == ER_FAILED)
3153  {
3154  return NULL;
3155  }
3156  ptr = or_pack_int (ptr, offset);
3157 
3158  offset = xts_save_cache_attrinfo (func_pred->cache_attrinfo);
3159  if (offset == ER_FAILED)
3160  {
3161  return NULL;
3162  }
3163  ptr = or_pack_int (ptr, offset);
3164 
3165  return ptr;
3166 }
3167 
3168 static char *
3170 {
3171  /*
3172  * We don't need to pack anything here, it is strictly a server side
3173  * structure. Unfortunately, we must send something or else the ptrs
3174  * to this structure might conflict with a structure that might be
3175  * packed after it. To avoid this we'll pack a single zero.
3176  */
3177  ptr = or_pack_int (ptr, 0);
3178 
3179  return ptr;
3180 }
3181 
3182 static char *
3183 xts_process_union_proc (char *ptr, const UNION_PROC_NODE * union_proc)
3184 {
3185  int offset;
3186 
3187  offset = xts_save_xasl_node (union_proc->left);
3188  if (offset == ER_FAILED)
3189  {
3190  return NULL;
3191  }
3192  ptr = or_pack_int (ptr, offset);
3193 
3194  offset = xts_save_xasl_node (union_proc->right);
3195  if (offset == ER_FAILED)
3196  {
3197  return NULL;
3198  }
3199  ptr = or_pack_int (ptr, offset);
3200 
3201  return ptr;
3202 }
3203 
3204 static char *
3205 xts_process_fetch_proc (char *ptr, const FETCH_PROC_NODE * obj_set_fetch_proc)
3206 {
3207  int offset;
3208 
3209  offset = xts_save_db_value (obj_set_fetch_proc->arg);
3210  if (offset == ER_FAILED)
3211  {
3212  return NULL;
3213  }
3214  ptr = or_pack_int (ptr, offset);
3215 
3216  ptr = or_pack_int (ptr, (int) obj_set_fetch_proc->fetch_res);
3217 
3218  offset = xts_save_pred_expr (obj_set_fetch_proc->set_pred);
3219  if (offset == ER_FAILED)
3220  {
3221  return NULL;
3222  }
3223  ptr = or_pack_int (ptr, offset);
3224 
3225  ptr = or_pack_int (ptr, (int) obj_set_fetch_proc->ql_flag);
3226 
3227  return ptr;
3228 }
3229 
3230 static char *
3231 xts_process_buildlist_proc (char *ptr, const BUILDLIST_PROC_NODE * build_list_proc)
3232 {
3233  int offset;
3234 
3235  /* ptr->output_columns not sent to server */
3236 
3237  offset = xts_save_xasl_node (build_list_proc->eptr_list);
3238  if (offset == ER_FAILED)
3239  {
3240  return NULL;
3241  }
3242  ptr = or_pack_int (ptr, offset);
3243 
3244  offset = xts_save_sort_list (build_list_proc->groupby_list);
3245  if (offset == ER_FAILED)
3246  {
3247  return NULL;
3248  }
3249  ptr = or_pack_int (ptr, offset);
3250 
3251  offset = xts_save_sort_list (build_list_proc->after_groupby_list);
3252  if (offset == ER_FAILED)
3253  {
3254  return NULL;
3255  }
3256  ptr = or_pack_int (ptr, offset);
3257 
3258  if (build_list_proc->push_list_id == NULL)
3259  {
3260  ptr = or_pack_int (ptr, 0);
3261  }
3262  else
3263  {
3264  offset = xts_save_list_id (build_list_proc->push_list_id);
3265  if (offset == ER_FAILED)
3266  {
3267  return NULL;
3268  }
3269  ptr = or_pack_int (ptr, offset);
3270  }
3271 
3272  offset = xts_save_outptr_list (build_list_proc->g_outptr_list);
3273  if (offset == ER_FAILED)
3274  {
3275  return NULL;
3276  }
3277  ptr = or_pack_int (ptr, offset);
3278 
3279  offset = xts_save_regu_variable_list (build_list_proc->g_regu_list);
3280  if (offset == ER_FAILED)
3281  {
3282  return NULL;
3283  }
3284  ptr = or_pack_int (ptr, offset);
3285 
3286  offset = xts_save_val_list (build_list_proc->g_val_list);
3287  if (offset == ER_FAILED)
3288  {
3289  return NULL;
3290  }
3291  ptr = or_pack_int (ptr, offset);
3292 
3293  offset = xts_save_pred_expr (build_list_proc->g_having_pred);
3294  if (offset == ER_FAILED)
3295  {
3296  return NULL;
3297  }
3298  ptr = or_pack_int (ptr, offset);
3299 
3300  offset = xts_save_pred_expr (build_list_proc->g_grbynum_pred);
3301  if (offset == ER_FAILED)
3302  {
3303  return NULL;
3304  }
3305  ptr = or_pack_int (ptr, offset);
3306 
3307  offset = xts_save_db_value (build_list_proc->g_grbynum_val);
3308  if (offset == ER_FAILED)
3309  {
3310  return NULL;
3311  }
3312  ptr = or_pack_int (ptr, offset);
3313 
3314  ptr = or_pack_int (ptr, build_list_proc->g_hash_eligible);
3315 
3316  ptr = or_pack_int (ptr, build_list_proc->g_output_first_tuple);
3317  ptr = or_pack_int (ptr, build_list_proc->g_hkey_size);
3318 
3319  offset = xts_save_regu_variable_list (build_list_proc->g_hk_scan_regu_list);
3320  if (offset == ER_FAILED)
3321  {
3322  return NULL;
3323  }
3324  ptr = or_pack_int (ptr, offset);
3325 
3326  offset = xts_save_regu_variable_list (build_list_proc->g_hk_sort_regu_list);
3327  if (offset == ER_FAILED)
3328  {
3329  return NULL;
3330  }
3331  ptr = or_pack_int (ptr, offset);
3332 
3333  offset = xts_save_regu_variable_list (build_list_proc->g_scan_regu_list);
3334  if (offset == ER_FAILED)
3335  {
3336  return NULL;
3337  }
3338  ptr = or_pack_int (ptr, offset);
3339 
3340  ptr = or_pack_int (ptr, build_list_proc->g_func_count);
3341  ptr = or_pack_int (ptr, build_list_proc->g_grbynum_flag);
3342  ptr = or_pack_int (ptr, build_list_proc->g_with_rollup);
3343 
3344  offset = xts_save_aggregate_type (build_list_proc->g_agg_list);
3345  if (offset == ER_FAILED)
3346  {
3347  return NULL;
3348  }
3349  ptr = or_pack_int (ptr, offset);
3350 
3351  offset = xts_save_analytic_eval_type (build_list_proc->a_eval_list);
3352  if (offset == ER_FAILED)
3353  {
3354  return NULL;
3355  }
3356  ptr = or_pack_int (ptr, offset);
3357 
3358  offset = xts_save_regu_variable_list (build_list_proc->a_regu_list);
3359  if (offset == ER_FAILED)
3360  {
3361  return NULL;
3362  }
3363  ptr = or_pack_int (ptr, offset);
3364 
3365  offset = xts_save_outptr_list (build_list_proc->a_outptr_list);
3366  if (offset == ER_FAILED)
3367  {
3368  return NULL;
3369  }
3370  ptr = or_pack_int (ptr, offset);
3371 
3372  offset = xts_save_outptr_list (build_list_proc->a_outptr_list_ex);
3373  if (offset == ER_FAILED)
3374  {
3375  return NULL;
3376  }
3377  ptr = or_pack_int (ptr, offset);
3378 
3379  offset = xts_save_outptr_list (build_list_proc->a_outptr_list_interm);
3380  if (offset == ER_FAILED)
3381  {
3382  return NULL;
3383  }
3384  ptr = or_pack_int (ptr, offset);
3385 
3386  offset = xts_save_val_list (build_list_proc->a_val_list);
3387  if (offset == ER_FAILED)
3388  {
3389  return NULL;
3390  }
3391  ptr = or_pack_int (ptr, offset);
3392 
3393  return ptr;
3394 }
3395 
3396 static char *
3397 xts_process_buildvalue_proc (char *ptr, const BUILDVALUE_PROC_NODE * build_value_proc)
3398 {
3399  int offset;
3400 
3401  offset = xts_save_pred_expr (build_value_proc->having_pred);
3402  if (offset == ER_FAILED)
3403  {
3404  return NULL;
3405  }
3406  ptr = or_pack_int (ptr, offset);
3407 
3408  offset = xts_save_db_value (build_value_proc->grbynum_val);
3409  if (offset == ER_FAILED)
3410  {
3411  return NULL;
3412  }
3413  ptr = or_pack_int (ptr, offset);
3414 
3415  offset = xts_save_aggregate_type (build_value_proc->agg_list);
3416  if (offset == ER_FAILED)
3417  {
3418  return NULL;
3419  }
3420  ptr = or_pack_int (ptr, offset);
3421 
3422  offset = xts_save_arith_type (build_value_proc->outarith_list);
3423  if (offset == ER_FAILED)
3424  {
3425  return NULL;
3426  }
3427  ptr = or_pack_int (ptr, offset);
3428 
3429  ptr = or_pack_int (ptr, build_value_proc->is_always_false);
3430 
3431  return ptr;
3432 }
3433 
3434 static char *
3435 xts_process_mergelist_proc (char *ptr, const MERGELIST_PROC_NODE * merge_list_info)
3436 {
3437  int offset;
3438  int cnt;
3439  ACCESS_SPEC_TYPE *access_spec = NULL;
3440 
3441  offset = xts_save_xasl_node (merge_list_info->outer_xasl);
3442  if (offset == ER_FAILED)
3443  {
3444  return NULL;
3445  }
3446  ptr = or_pack_int (ptr, offset);
3447 
3448  for (cnt = 0, access_spec = merge_list_info->outer_spec_list; access_spec; access_spec = access_spec->next, cnt++)
3449  ; /* empty */
3450  ptr = or_pack_int (ptr, cnt);
3451 
3452  for (access_spec = merge_list_info->outer_spec_list; access_spec; access_spec = access_spec->next)
3453  {
3454  ptr = xts_process_access_spec_type (ptr, access_spec);
3455  }
3456 
3457  offset = xts_save_val_list (merge_list_info->outer_val_list);
3458  if (offset == ER_FAILED)
3459  {
3460  return NULL;
3461  }
3462  ptr = or_pack_int (ptr, offset);
3463 
3464  offset = xts_save_xasl_node (merge_list_info->inner_xasl);
3465  if (offset == ER_FAILED)
3466  {
3467  return NULL;
3468  }
3469  ptr = or_pack_int (ptr, offset);
3470 
3471  for (cnt = 0, access_spec = merge_list_info->inner_spec_list; access_spec; access_spec = access_spec->next, cnt++)
3472  ; /* empty */
3473  ptr = or_pack_int (ptr, cnt);
3474 
3475  for (access_spec = merge_list_info->inner_spec_list; access_spec; access_spec = access_spec->next)
3476  {
3477  ptr = xts_process_access_spec_type (ptr, access_spec);
3478  }
3479 
3480  offset = xts_save_val_list (merge_list_info->inner_val_list);
3481  if (offset == ER_FAILED)
3482  {
3483  return NULL;
3484  }
3485  ptr = or_pack_int (ptr, offset);
3486 
3487  return xts_process_ls_merge_info (ptr, &merge_list_info->ls_merge);
3488 }
3489 
3490 static char *
3491 xts_process_cte_proc (char *ptr, const CTE_PROC_NODE * cte_proc)
3492 {
3493  int offset;
3494 
3495  offset = xts_save_xasl_node (cte_proc->non_recursive_part);
3496  if (offset == ER_FAILED)
3497  {
3498  return NULL;
3499  }
3500  ptr = or_pack_int (ptr, offset);
3501 
3502  offset = xts_save_xasl_node (cte_proc->recursive_part);
3503  if (offset == ER_FAILED)
3504  {
3505  return NULL;
3506  }
3507  ptr = or_pack_int (ptr, offset);
3508 
3509  return ptr;
3510 }
3511 
3512 static char *
3514 {
3515  int offset;
3516 
3517  ptr = or_pack_int (ptr, qfile_list_merge_info->join_type);
3518 
3519  ptr = or_pack_int (ptr, qfile_list_merge_info->single_fetch);
3520 
3521  ptr = or_pack_int (ptr, qfile_list_merge_info->ls_column_cnt);
3522 
3523  offset = xts_save_int_array (qfile_list_merge_info->ls_outer_column, qfile_list_merge_info->ls_column_cnt);
3524  if (offset == ER_FAILED)
3525  {
3526  return NULL;
3527  }
3528  ptr = or_pack_int (ptr, offset);
3529 
3530  offset = xts_save_int_array (qfile_list_merge_info->ls_outer_unique, qfile_list_merge_info->ls_column_cnt);
3531  if (offset == ER_FAILED)
3532  {
3533  return NULL;
3534  }
3535  ptr = or_pack_int (ptr, offset);
3536 
3537  offset = xts_save_int_array (qfile_list_merge_info->ls_inner_column, qfile_list_merge_info->ls_column_cnt);
3538  if (offset == ER_FAILED)
3539  {
3540  return NULL;
3541  }
3542  ptr = or_pack_int (ptr, offset);
3543 
3544  offset = xts_save_int_array (qfile_list_merge_info->ls_inner_unique, qfile_list_merge_info->ls_column_cnt);
3545  if (offset == ER_FAILED)
3546  {
3547  return NULL;
3548  }
3549  ptr = or_pack_int (ptr, offset);
3550 
3551  ptr = or_pack_int (ptr, qfile_list_merge_info->ls_pos_cnt);
3552 
3553  offset = xts_save_int_array (qfile_list_merge_info->ls_pos_list, qfile_list_merge_info->ls_pos_cnt);
3554  if (offset == ER_FAILED)
3555  {
3556  return NULL;
3557  }
3558  ptr = or_pack_int (ptr, offset);
3559 
3560  offset = xts_save_int_array (qfile_list_merge_info->ls_outer_inner_list, qfile_list_merge_info->ls_pos_cnt);
3561  if (offset == ER_FAILED)
3562  {
3563  return NULL;
3564  }
3565  ptr = or_pack_int (ptr, offset);
3566 
3567  return ptr;
3568 }
3569 
3570 static char *
3572 {
3573  int offset = 0;
3574  int i;
3575  char *p;
3576 
3577  /* num_subclasses */
3578  ptr = or_pack_int (ptr, upd_cls->num_subclasses);
3579 
3580  /* class_oid */
3581  offset = xts_save_oid_array (upd_cls->class_oid, upd_cls->num_subclasses);
3582  if (offset == ER_FAILED)
3583  {
3584  return NULL;
3585  }
3586  ptr = or_pack_int (ptr, offset);
3587 
3588  /* class_hfid */
3589  offset = xts_save_hfid_array (upd_cls->class_hfid, upd_cls->num_subclasses);
3590  if (offset == ER_FAILED)
3591  {
3592  return NULL;
3593  }
3594  ptr = or_pack_int (ptr, offset);
3595 
3596  /* num_attrs */
3597  ptr = or_pack_int (ptr, upd_cls->num_attrs);
3598 
3599  /* att_id */
3600  offset = xts_save_int_array (upd_cls->att_id, upd_cls->num_attrs * upd_cls->num_subclasses);
3601  if (offset == ER_FAILED)
3602  {
3603  return NULL;
3604  }
3605  ptr = or_pack_int (ptr, offset);
3606  /* pruning info */
3607  ptr = or_pack_int (ptr, upd_cls->needs_pruning);
3608  /* has_uniques */
3609  ptr = or_pack_int (ptr, upd_cls->has_uniques);
3610 
3611  /* make sure num_lob_attrs and lob_attr_ids are both NULL or are both not NULL */
3612  assert ((upd_cls->num_lob_attrs && upd_cls->lob_attr_ids) || (!upd_cls->num_lob_attrs && !upd_cls->lob_attr_ids));
3613  /* num_lob_attrs */
3614  offset = xts_save_int_array (upd_cls->num_lob_attrs, upd_cls->num_subclasses);
3615  if (offset == ER_FAILED)
3616  {
3617  return NULL;
3618  }
3619  ptr = or_pack_int (ptr, offset);
3620  /* lob_attr_ids */
3621  if (upd_cls->lob_attr_ids)
3622  {
3623  offset = xts_reserve_location_in_stream (upd_cls->num_subclasses * sizeof (int));
3624  if (offset == ER_FAILED)
3625  {
3626  return NULL;
3627  }
3628  ptr = or_pack_int (ptr, offset);
3629  p = &xts_Stream_buffer[offset];
3630  for (i = 0; i < upd_cls->num_subclasses; i++)
3631  {
3632  offset = xts_save_int_array (upd_cls->lob_attr_ids[i], upd_cls->num_lob_attrs[i]);
3633  if (offset == ER_FAILED)
3634  {
3635  return NULL;
3636  }
3637  p = or_pack_int (p, offset);
3638  }
3639  }
3640  else
3641  {
3642  ptr = or_pack_int (ptr, 0);
3643  }
3644 
3645  /* no of indexes in mvcc assignments extra classes */
3646  ptr = or_pack_int (ptr, upd_cls->num_extra_assign_reev);
3647 
3648  /* mvcc assignments extra classes */
3649  offset = xts_save_int_array (upd_cls->mvcc_extra_assign_reev, upd_cls->num_extra_assign_reev);
3650  if (offset == ER_FAILED)
3651  {
3652  return NULL;
3653  }
3654  ptr = or_pack_int (ptr, offset);
3655 
3656  return ptr;
3657 }
3658 
3659 static int
3660 xts_save_upddel_class_info_array (const UPDDEL_CLASS_INFO * classes, int nelements)
3661 {
3662  char *ptr = NULL, *buf = NULL;
3663  int idx, offset = ER_FAILED;
3664  int size = xts_sizeof_upddel_class_info (classes) * nelements;
3665 
3666  assert (nelements > 0);
3667  assert (size > 0);
3668 
3669  offset = xts_reserve_location_in_stream (size);
3670  if (offset == ER_FAILED)
3671  {
3672  offset = ER_FAILED;
3673  goto end;
3674  }
3675 
3676  ptr = buf = (char *) malloc (size);
3677  if (buf == NULL)
3678  {
3679  offset = ER_OUT_OF_VIRTUAL_MEMORY;
3680  goto end;
3681  }
3682 
3683  for (idx = 0; idx < nelements; idx++)
3684  {
3685  ptr = xts_save_upddel_class_info (ptr, &classes[idx]);
3686  if (ptr == NULL)
3687  {
3688  offset = ER_FAILED;
3689  goto end;
3690  }
3691  }
3692  memcpy (&xts_Stream_buffer[offset], buf, size);
3693 
3694 end:
3695  if (buf != NULL)
3696  {
3697  free_and_init (buf);
3698  }
3699 
3700  return offset;
3701 }
3702 
3703 static char *
3705 {
3706  int offset = 0;
3707 
3708  /* cls_idx */
3709  ptr = or_pack_int (ptr, assign->cls_idx);
3710 
3711  /* att_idx */
3712  ptr = or_pack_int (ptr, assign->att_idx);
3713 
3714  /* constant */
3715  if (assign->constant)
3716  {
3717  offset = xts_save_db_value (assign->constant);
3718  if (offset == ER_FAILED)
3719  {
3720  return NULL;
3721  }
3722  }
3723  else
3724  {
3725  offset = 0;
3726  }
3727  ptr = or_pack_int (ptr, offset);
3728 
3729  /* regu_var */
3730  if (assign->regu_var)
3731  {
3732  offset = xts_save_regu_variable (assign->regu_var);
3733  if (offset == ER_FAILED)
3734  {
3735  return NULL;
3736  }
3737  }
3738  else
3739  {
3740  offset = 0;
3741  }
3742  ptr = or_pack_int (ptr, offset);
3743 
3744  return ptr;
3745 }
3746 
3747 static int
3748 xts_save_update_assignment_array (const UPDATE_ASSIGNMENT * assigns, int nelements)
3749 {
3750  char *ptr = NULL, *buf = NULL;
3751  int offset = ER_FAILED, idx;
3752  int size = xts_sizeof_update_assignment (assigns) * nelements;
3753 
3754  assert (nelements > 0);
3755  assert (size > 0);
3756 
3757  offset = xts_reserve_location_in_stream (size);
3758  if (offset == ER_FAILED)
3759  {
3760  offset = ER_FAILED;
3761  goto end;
3762  }
3763 
3764  ptr = buf = (char *) malloc (size);
3765  if (buf == NULL)
3766  {
3767  offset = ER_OUT_OF_VIRTUAL_MEMORY;
3768  goto end;
3769  }
3770 
3771  for (idx = 0; idx < nelements; idx++)
3772  {
3773  ptr = xts_save_update_assignment (ptr, &assigns[idx]);
3774  if (ptr == NULL)
3775  {
3776  offset = ER_FAILED;
3777  goto end;
3778  }
3779  }
3780  memcpy (&xts_Stream_buffer[offset], buf, size);
3781 
3782 end:
3783  if (buf != NULL)
3784  {
3785  free_and_init (buf);
3786  }
3787 
3788  return offset;
3789 }
3790 
3791 static int
3793 {
3794  int offset, return_offset;
3795  int size;
3796  char *ptr = NULL, *buf = NULL;
3797 
3798  if (odku_info == NULL)
3799  {
3800  return 0;
3801  }
3802 
3803  size = xts_sizeof_odku_info (odku_info);
3804 
3805  return_offset = xts_reserve_location_in_stream (size);
3806  if (return_offset == ER_FAILED)
3807  {
3808  return ER_FAILED;
3809  }
3810 
3811  ptr = buf = (char *) malloc (size);
3812  if (!buf)
3813  {
3815  return ER_FAILED;
3816  }
3817 
3818  /* num_assigns */
3819  ptr = or_pack_int (ptr, odku_info->num_assigns);
3820 
3821  /* attr_ids */
3822  offset = xts_save_int_array (odku_info->attr_ids, odku_info->num_assigns);
3823  if (offset == ER_FAILED)
3824  {
3825  goto end;
3826  }
3827  ptr = or_pack_int (ptr, offset);
3828 
3829  /* assignments */
3830  offset = xts_save_update_assignment_array (odku_info->assignments, odku_info->num_assigns);
3831  if (offset == ER_FAILED)
3832  {
3833  goto end;
3834  }
3835  ptr = or_pack_int (ptr, offset);
3836 
3837  /* constraint predicate */
3838  if (odku_info->cons_pred)
3839  {
3840  offset = xts_save_pred_expr (odku_info->cons_pred);
3841  if (offset == ER_FAILED)
3842  {
3843  goto end;
3844  }
3845  }
3846  else
3847  {
3848  offset = 0;
3849  }
3850  ptr = or_pack_int (ptr, offset);
3851 
3852  /* heap cache attr info */
3853  if (odku_info->attr_info)
3854  {
3855  offset = xts_save_cache_attrinfo (odku_info->attr_info);
3856  if (offset == ER_FAILED)
3857  {
3858  goto end;
3859  }
3860  }
3861  else
3862  {
3863  offset = 0;
3864  }
3865  ptr = or_pack_int (ptr, offset);
3866 
3867  memcpy (&xts_Stream_buffer[return_offset], buf, size);
3868  offset = return_offset;
3869 
3870 end:
3871  if (buf)
3872  {
3873  free_and_init (buf);
3874  }
3875  return offset;
3876 }
3877 
3878 static char *
3879 xts_process_update_proc (char *ptr, const UPDATE_PROC_NODE * update_info)
3880 {
3881  int offset;
3882 
3883  /* classes */
3884  ptr = or_pack_int (ptr, update_info->num_classes);
3885  offset = xts_save_upddel_class_info_array (update_info->classes, update_info->num_classes);
3886  if (offset == ER_FAILED)
3887  {
3888  return NULL;
3889  }
3890  ptr = or_pack_int (ptr, offset);
3891 
3892  /* assigns */
3893  ptr = or_pack_int (ptr, update_info->num_assigns);
3894  offset = xts_save_update_assignment_array (update_info->assigns, update_info->num_assigns);
3895  if (offset == ER_FAILED)
3896  {
3897  return NULL;
3898  }
3899  ptr = or_pack_int (ptr, offset);
3900 
3901  /* cons_pred */
3902  offset = xts_save_pred_expr (update_info->cons_pred);
3903  if (offset == ER_FAILED)
3904  {
3905  return NULL;
3906  }
3907  ptr = or_pack_int (ptr, offset);
3908 
3909  /* wait_msecs */
3910  ptr = or_pack_int (ptr, update_info->wait_msecs);
3911 
3912  /* no_logging */
3913  ptr = or_pack_int (ptr, update_info->no_logging);
3914 
3915  /* num_orderby_keys */
3916  ptr = or_pack_int (ptr, update_info->num_orderby_keys);
3917 
3918  /* num_assign_reev_classes */
3919  ptr = or_pack_int (ptr, update_info->num_assign_reev_classes);
3920 
3921  /* mvcc condition reevaluation data */
3922  ptr = or_pack_int (ptr, update_info->num_reev_classes);
3923  if (update_info->num_reev_classes)
3924  {
3925  offset = xts_save_int_array (update_info->mvcc_reev_classes, update_info->num_reev_classes);
3926  if (offset == ER_FAILED)
3927  {
3928  return NULL;
3929  }
3930  }
3931  else
3932  {
3933  offset = 0;
3934  }
3935  ptr = or_pack_int (ptr, offset);
3936 
3937  return ptr;
3938 }
3939 
3940 static char *
3941 xts_process_delete_proc (char *ptr, const DELETE_PROC_NODE * delete_info)
3942 {
3943  int offset;
3944 
3945  ptr = or_pack_int (ptr, delete_info->num_classes);
3946 
3947  offset = xts_save_upddel_class_info_array (delete_info->classes, delete_info->num_classes);
3948  if (offset == ER_FAILED)
3949  {
3950  return NULL;
3951  }
3952  ptr = or_pack_int (ptr, offset);
3953 
3954  ptr = or_pack_int (ptr, delete_info->wait_msecs);
3955 
3956  ptr = or_pack_int (ptr, delete_info->no_logging);
3957 
3958  /* mvcc condition reevaluation data */
3959  ptr = or_pack_int (ptr, delete_info->num_reev_classes);
3960  if (delete_info->num_reev_classes)
3961  {
3962  offset = xts_save_int_array (delete_info->mvcc_reev_classes, delete_info->num_reev_classes);
3963  if (offset == ER_FAILED)
3964  {
3965  return NULL;
3966  }
3967  }
3968  else
3969  {
3970  offset = 0;
3971  }
3972  ptr = or_pack_int (ptr, offset);
3973 
3974  return ptr;
3975 }
3976 
3977 static char *
3978 xts_process_insert_proc (char *ptr, const INSERT_PROC_NODE * insert_info)
3979 {
3980  int offset, i;
3981 
3982  ptr = or_pack_oid (ptr, (OID *) (&insert_info->class_oid));
3983 
3984  ptr = or_pack_hfid (ptr, &insert_info->class_hfid);
3985 
3986  ptr = or_pack_int (ptr, insert_info->num_vals);
3987 
3988  ptr = or_pack_int (ptr, insert_info->num_default_expr);
3989 
3990  offset = xts_save_int_array (insert_info->att_id, insert_info->num_vals);
3991  if (offset == ER_FAILED)
3992  {
3993  return NULL;
3994  }
3995  ptr = or_pack_int (ptr, offset);
3996 
3997  offset = xts_save_pred_expr (insert_info->cons_pred);
3998  if (offset == ER_FAILED)
3999  {
4000  return NULL;
4001  }
4002  ptr = or_pack_int (ptr, offset);
4003 
4004  ptr = or_pack_int (ptr, insert_info->has_uniques);
4005 
4006  ptr = or_pack_int (ptr, insert_info->wait_msecs);
4007 
4008  ptr = or_pack_int (ptr, insert_info->no_logging);
4009 
4010  ptr = or_pack_int (ptr, insert_info->do_replace);
4011 
4012  ptr = or_pack_int (ptr, insert_info->pruning_type);
4013 
4014  offset = xts_save_odku_info (insert_info->odku);
4015  if (offset == ER_FAILED)
4016  {
4017  return NULL;
4018  }
4019  ptr = or_pack_int (ptr, offset);
4020 
4021  ptr = or_pack_int (ptr, insert_info->num_val_lists);
4022 
4023  for (i = 0; i < insert_info->num_val_lists; i++)
4024  {
4025  offset = xts_save_outptr_list (insert_info->valptr_lists[i]);
4026  if (offset == ER_FAILED)
4027  {
4028  return NULL;
4029  }
4030  ptr = or_pack_int (ptr, offset);
4031  }
4032 
4033  offset = xts_save_db_value (insert_info->obj_oid);
4034  if (offset == ER_FAILED)
4035  {
4036  return NULL;
4037  }
4038  ptr = or_pack_int (ptr, offset);
4039 
4040  return ptr;
4041 }
4042 
4043 static char *
4044 xts_process_merge_proc (char *ptr, const MERGE_PROC_NODE * merge_info)
4045 {
4046  int offset;
4047 
4048  offset = xts_save_xasl_node (merge_info->update_xasl);
4049  if (offset == ER_FAILED)
4050  {
4051  return NULL;
4052  }
4053  ptr = or_pack_int (ptr, offset);
4054 
4055  offset = xts_save_xasl_node (merge_info->insert_xasl);
4056  if (offset == ER_FAILED)
4057  {
4058  return NULL;
4059  }
4060  ptr = or_pack_int (ptr, offset);
4061 
4062  ptr = or_pack_int (ptr, merge_info->has_delete);
4063 
4064  return ptr;
4065 }
4066 
4067 static char *
4068 xts_process_outptr_list (char *ptr, const OUTPTR_LIST * outptr_list)
4069 {
4070  int offset;
4071 
4072  ptr = or_pack_int (ptr, outptr_list->valptr_cnt);
4073 
4074  offset = xts_save_regu_variable_list (outptr_list->valptrp);
4075  if (offset == ER_FAILED)
4076  {
4077  return NULL;
4078  }
4079  ptr = or_pack_int (ptr, offset);
4080 
4081  return ptr;
4082 }
4083 
4084 static char *
4086 {
4087  int offset;
4088 
4089  ptr = or_pack_oid (ptr, (OID *) (&selupd_list->class_oid));
4090  ptr = or_pack_hfid (ptr, &selupd_list->class_hfid);
4091 
4092  ptr = or_pack_int (ptr, selupd_list->select_list_size);
4093 
4094  ptr = or_pack_int (ptr, selupd_list->wait_msecs);
4095 
4096  offset = xts_save_regu_varlist_list (selupd_list->select_list);
4097  if (offset == ER_FAILED)
4098  {
4099  return NULL;
4100  }
4101  ptr = or_pack_int (ptr, offset);
4102 
4103  offset = xts_save_selupd_list (selupd_list->next);
4104  if (offset == ER_FAILED)
4105  {
4106  return NULL;
4107  }
4108  ptr = or_pack_int (ptr, offset);
4109 
4110  return ptr;
4111 }
4112 
4113 static char *
4114 xts_process_pred_expr (char *ptr, const PRED_EXPR * pred_expr)
4115 {
4116  int offset;
4117 
4118  ptr = or_pack_int (ptr, pred_expr->type);
4119 
4120  switch (pred_expr->type)
4121  {
4122  case T_PRED:
4123  ptr = xts_process_pred (ptr, &pred_expr->pe.m_pred);
4124  break;
4125 
4126  case T_EVAL_TERM:
4127  ptr = xts_process_eval_term (ptr, &pred_expr->pe.m_eval_term);
4128  break;
4129 
4130  case T_NOT_TERM:
4131  offset = xts_save_pred_expr (pred_expr->pe.m_not_term);
4132  if (offset == ER_FAILED)
4133  {
4134  return NULL;
4135  }
4136  ptr = or_pack_int (ptr, offset);
4137  break;
4138 
4139  default:
4141  return NULL;
4142  }
4143 
4144  return ptr;
4145 }
4146 
4147 static char *
4148 xts_process_pred (char *ptr, const PRED * pred)
4149 {
4150  int offset;
4151  PRED_EXPR *rhs;
4152 
4153  offset = xts_save_pred_expr (pred->lhs); /* lhs */
4154  if (offset == ER_FAILED)
4155  {
4156  return NULL;
4157  }
4158  ptr = or_pack_int (ptr, offset);
4159 
4160  ptr = or_pack_int (ptr, pred->bool_op); /* bool_op */
4161 
4162  rhs = pred->rhs;
4163  ptr = or_pack_int (ptr, rhs->type); /* rhs-type */
4164 
4165  /* Traverse right-linear chains of AND/OR terms */
4166  while (rhs->type == T_PRED)
4167  {
4168  pred = &rhs->pe.m_pred;
4169 
4170  offset = xts_save_pred_expr (pred->lhs); /* lhs */
4171  if (offset == ER_FAILED)
4172  {
4173  return NULL;
4174  }
4175  ptr = or_pack_int (ptr, offset);
4176 
4177  ptr = or_pack_int (ptr, pred->bool_op); /* bool_op */
4178 
4179  rhs = pred->rhs;
4180  ptr = or_pack_int (ptr, rhs->type); /* rhs-type */
4181  }
4182 
4183  offset = xts_save_pred_expr (pred->rhs); /* rhs */
4184  if (offset == ER_FAILED)
4185  {
4186  return NULL;
4187  }
4188  ptr = or_pack_int (ptr, offset);
4189 
4190  return ptr;
4191 }
4192 
4193 static char *
4194 xts_process_eval_term (char *ptr, const EVAL_TERM * eval_term)
4195 {
4196  ptr = or_pack_int (ptr, eval_term->et_type);
4197 
4198  switch (eval_term->et_type)
4199  {
4200  case T_COMP_EVAL_TERM:
4201  ptr = xts_process_comp_eval_term (ptr, &eval_term->et.et_comp);
4202  break;
4203 
4204  case T_ALSM_EVAL_TERM:
4205  ptr = xts_process_alsm_eval_term (ptr, &eval_term->et.et_alsm);
4206  break;
4207 
4208  case T_LIKE_EVAL_TERM:
4209  ptr = xts_process_like_eval_term (ptr, &eval_term->et.et_like);
4210  break;
4211 
4212  case T_RLIKE_EVAL_TERM:
4213  ptr = xts_process_rlike_eval_term (ptr, &eval_term->et.et_rlike);
4214  break;
4215 
4216  default:
4218  return NULL;
4219  }
4220 
4221  return ptr;
4222 }
4223 
4224 static char *
4225 xts_process_comp_eval_term (char *ptr, const COMP_EVAL_TERM * comp_eval_term)
4226 {
4227  int offset;
4228 
4229  offset = xts_save_regu_variable (comp_eval_term->lhs);
4230  if (offset == ER_FAILED)
4231  {
4232  return NULL;
4233  }
4234  ptr = or_pack_int (ptr, offset);
4235 
4236  offset = xts_save_regu_variable (comp_eval_term->rhs);
4237  if (offset == ER_FAILED)
4238  {
4239  return NULL;
4240  }
4241  ptr = or_pack_int (ptr, offset);
4242 
4243  ptr = or_pack_int (ptr, comp_eval_term->rel_op);
4244 
4245  ptr = or_pack_int (ptr, comp_eval_term->type);
4246 
4247  return ptr;
4248 }
4249 
4250 static char *
4251 xts_process_alsm_eval_term (char *ptr, const ALSM_EVAL_TERM * alsm_eval_term)
4252 {
4253  int offset;
4254 
4255  offset = xts_save_regu_variable (alsm_eval_term->elem);
4256  if (offset == ER_FAILED)
4257  {
4258  return NULL;
4259  }
4260  ptr = or_pack_int (ptr, offset);
4261 
4262  offset = xts_save_regu_variable (alsm_eval_term->elemset);
4263  if (offset == ER_FAILED)
4264  {
4265  return NULL;
4266  }
4267  ptr = or_pack_int (ptr, offset);
4268 
4269  ptr = or_pack_int (ptr, alsm_eval_term->eq_flag);
4270 
4271  ptr = or_pack_int (ptr, alsm_eval_term->rel_op);
4272 
4273  ptr = or_pack_int (ptr, alsm_eval_term->item_type);
4274 
4275  return ptr;
4276 }
4277 
4278 static char *
4279 xts_process_like_eval_term (char *ptr, const LIKE_EVAL_TERM * like_eval_term)
4280 {
4281  int offset;
4282 
4283  offset = xts_save_regu_variable (like_eval_term->src);
4284  if (offset == ER_FAILED)
4285  {
4286  return NULL;
4287  }
4288  ptr = or_pack_int (ptr, offset);
4289 
4290  offset = xts_save_regu_variable (like_eval_term->pattern);
4291  if (offset == ER_FAILED)
4292  {
4293  return NULL;
4294  }
4295  ptr = or_pack_int (ptr, offset);
4296 
4297  offset = xts_save_regu_variable (like_eval_term->esc_char);
4298  if (offset == ER_FAILED)
4299  {
4300  return NULL;
4301  }
4302  ptr = or_pack_int (ptr, offset);
4303 
4304  return ptr;
4305 }
4306 
4307 static char *
4308 xts_process_rlike_eval_term (char *ptr, const RLIKE_EVAL_TERM * rlike_eval_term)
4309 {
4310  int offset;
4311 
4312  offset = xts_save_regu_variable (rlike_eval_term->src);
4313  if (offset == ER_FAILED)
4314  {
4315  return NULL;
4316  }
4317  ptr = or_pack_int (ptr, offset);
4318 
4319  offset = xts_save_regu_variable (rlike_eval_term->pattern);
4320  if (offset == ER_FAILED)
4321  {
4322  return NULL;
4323  }
4324  ptr = or_pack_int (ptr, offset);
4325 
4326  offset = xts_save_regu_variable (rlike_eval_term->case_sensitive);
4327  if (offset == ER_FAILED)
4328  {
4329  return NULL;
4330  }
4331  ptr = or_pack_int (ptr, offset);
4332 
4333  return ptr;
4334 }
4335 
4336 static char *
4338 {
4339  int offset;
4340 
4341  if (ptr == NULL)
4342  {
4343  return NULL;
4344  }
4345 
4346  ptr = or_pack_int (ptr, access_spec->type);
4347 
4348  ptr = or_pack_int (ptr, access_spec->access);
4349 
4350  if (access_spec->access == ACCESS_METHOD_SEQUENTIAL || access_spec->access == ACCESS_METHOD_SEQUENTIAL_RECORD_INFO
4351  || access_spec->access == ACCESS_METHOD_SEQUENTIAL_PAGE_SCAN || access_spec->access == ACCESS_METHOD_JSON_TABLE)
4352  {
4353  ptr = or_pack_int (ptr, 0);
4354  }
4355  else
4356  {
4357  offset = xts_save_indx_info (access_spec->indexptr);
4358  if (offset == ER_FAILED)
4359  {
4360  return NULL;
4361  }
4362 
4363  ptr = or_pack_int (ptr, offset);
4364  }
4365 
4366  offset = xts_save_pred_expr (access_spec->where_key);
4367  if (offset == ER_FAILED)
4368  {
4369  return NULL;
4370  }
4371  ptr = or_pack_int (ptr, offset);
4372 
4373  offset = xts_save_pred_expr (access_spec->where_pred);
4374  if (offset == ER_FAILED)
4375  {
4376  return NULL;
4377  }
4378  ptr = or_pack_int (ptr, offset);
4379 
4380  offset = xts_save_pred_expr (access_spec->where_range);
4381  if (offset == ER_FAILED)
4382  {
4383  return NULL;
4384  }
4385  ptr = or_pack_int (ptr, offset);
4386 
4387  switch (access_spec->type)
4388  {
4389  case TARGET_CLASS:
4390  case TARGET_CLASS_ATTR:
4391  ptr = xts_process_cls_spec_type (ptr, &ACCESS_SPEC_CLS_SPEC (access_spec));
4392  break;
4393 
4394  case TARGET_LIST:
4395  ptr = xts_process_list_spec_type (ptr, &ACCESS_SPEC_LIST_SPEC (access_spec));
4396  break;
4397 
4398  case TARGET_SHOWSTMT:
4399  ptr = xts_process_showstmt_spec_type (ptr, &ACCESS_SPEC_SHOWSTMT_SPEC (access_spec));
4400  break;
4401 
4402  case TARGET_REGUVAL_LIST:
4403  ptr = xts_process_rlist_spec_type (ptr, &ACCESS_SPEC_LIST_SPEC (access_spec));
4404  break;
4405 
4406  case TARGET_SET:
4407  ptr = xts_process_set_spec_type (ptr, &ACCESS_SPEC_SET_SPEC (access_spec));
4408  break;
4409 
4410  case TARGET_METHOD:
4411  ptr = xts_process_method_spec_type (ptr, &ACCESS_SPEC_METHOD_SPEC (access_spec));
4412  break;
4413 
4414  case TARGET_JSON_TABLE:
4415  ptr = xts_process (ptr, ACCESS_SPEC_JSON_TABLE_SPEC (access_spec));
4416  break;
4417 
4418  default:
4420  return NULL;
4421  }
4422 
4423  if (ptr == NULL)
4424  {
4425  return NULL;
4426  }
4427 
4428  /* ptr->s_id not sent to server */
4429 
4430  ptr = or_pack_int (ptr, access_spec->single_fetch);
4431 
4432  ptr = or_pack_int (ptr, access_spec->pruning_type);
4433 
4434  offset = xts_save_db_value (access_spec->s_dbval);
4435  if (offset == ER_FAILED)
4436  {
4437  return NULL;
4438  }
4439  ptr = or_pack_int (ptr, offset);
4440 
4441  ptr = or_pack_int (ptr, access_spec->flags);
4442 
4443  return ptr;
4444 }
4445 
4446 static char *
4448 {
4449  ptr = or_pack_btid (ptr, &indx_info->btid);
4450 
4451  ptr = or_pack_int (ptr, indx_info->coverage);
4452 
4453  ptr = or_pack_int (ptr, indx_info->range_type);
4454 
4455  ptr = xts_process_key_info (ptr, &indx_info->key_info);
4456 
4457  ptr = or_pack_int (ptr, indx_info->orderby_desc);
4458 
4459  ptr = or_pack_int (ptr, indx_info->groupby_desc);
4460 
4461  ptr = or_pack_int (ptr, indx_info->use_desc_index);
4462 
4463  ptr = or_pack_int (ptr, indx_info->orderby_skip);
4464 
4465  ptr = or_pack_int (ptr, indx_info->groupby_skip);
4466 
4467  ptr = or_pack_int (ptr, indx_info->use_iss);
4468 
4469  ptr = or_pack_int (ptr, indx_info->ils_prefix_len);
4470 
4471  ptr = or_pack_int (ptr, indx_info->func_idx_col_id);
4472 
4473  if (indx_info->use_iss)
4474  {
4475  int offset;
4476 
4477  ptr = or_pack_int (ptr, (int) indx_info->iss_range.range);
4478 
4479  offset = xts_save_regu_variable (indx_info->iss_range.key1);
4480  if (offset == ER_FAILED)
4481  {
4482  return NULL;
4483  }
4484  ptr = or_pack_int (ptr, offset);
4485 
4486  /* Key 2 is ALWAYS NULL (see pt_create_iss_range(), so we do not stream it */
4487  }
4488  else
4489  {
4490 #if !defined(NDEBUG)
4491  /* suppress valgrind UMW error */
4492  ptr = or_pack_int (ptr, 0); /* dummy indx_info->iss_range.range */
4493  ptr = or_pack_int (ptr, 0); /* dummp offset of iss_range.key1 */
4494 #endif
4495  }
4496 
4497  return ptr;
4498 }
4499 
4500 static char *
4502 {
4503  int offset;
4504 
4505  ptr = or_pack_int (ptr, key_info->key_cnt);
4506 
4507  if (key_info->key_cnt > 0)
4508  {
4509  offset = xts_save_key_range_array (key_info->key_ranges, key_info->key_cnt);
4510  if (offset == ER_FAILED)
4511  {
4512  return NULL;
4513  }
4514  ptr = or_pack_int (ptr, offset);
4515  }
4516  else
4517  {
4518  ptr = or_pack_int (ptr, 0);
4519  }
4520 
4521  ptr = or_pack_int (ptr, key_info->is_constant);
4522  ptr = or_pack_int (ptr, key_info->key_limit_reset);
4523  ptr = or_pack_int (ptr, key_info->is_user_given_keylimit);
4524 
4525  offset = xts_save_regu_variable (key_info->key_limit_l);
4526  if (offset == ER_FAILED)
4527  {
4528  return NULL;
4529  }
4530  ptr = or_pack_int (ptr, offset);
4531 
4532  offset = xts_save_regu_variable (key_info->key_limit_u);
4533  if (offset == ER_FAILED)
4534  {
4535  return NULL;
4536  }
4537  ptr = or_pack_int (ptr, offset);
4538 
4539  return ptr;
4540 }
4541 
4542 static char *
4544 {
4545  int offset;
4546 
4547  ptr = or_pack_hfid (ptr, &cls_spec->hfid);
4548 
4549  ptr = or_pack_oid (ptr, (OID *) (&cls_spec->cls_oid));
4550 
4551  offset = xts_save_regu_variable_list (cls_spec->cls_regu_list_key);
4552  if (offset == ER_FAILED)
4553  {
4554  return NULL;
4555  }
4556  ptr = or_pack_int (ptr, offset);
4557 
4558  offset = xts_save_regu_variable_list (cls_spec->cls_regu_list_pred);
4559  if (offset == ER_FAILED)
4560  {
4561  return NULL;
4562  }
4563  ptr = or_pack_int (ptr, offset);
4564 
4565  offset = xts_save_regu_variable_list (cls_spec->cls_regu_list_rest);
4566  if (offset == ER_FAILED)
4567  {
4568  return NULL;
4569  }
4570  ptr = or_pack_int (ptr, offset);
4571 
4572  offset = xts_save_regu_variable_list (cls_spec->cls_regu_list_range);
4573  if (offset == ER_FAILED)
4574  {
4575  return NULL;
4576  }
4577  ptr = or_pack_int (ptr, offset);
4578 
4579  offset = xts_save_outptr_list (cls_spec->cls_output_val_list);
4580  if (offset == ER_FAILED)
4581  {
4582  return NULL;
4583  }
4584  ptr = or_pack_int (ptr, offset);
4585 
4586  offset = xts_save_regu_variable_list (cls_spec->cls_regu_val_list);
4587  if (offset == ER_FAILED)
4588  {
4589  return NULL;
4590  }
4591  ptr = or_pack_int (ptr, offset);
4592 
4593  ptr = or_pack_int (ptr, cls_spec->num_attrs_key);
4594 
4595  offset = xts_save_int_array (cls_spec->attrids_key, cls_spec->num_attrs_key);
4596  if (offset == ER_FAILED)
4597  {
4598  return NULL;
4599  }
4600  ptr = or_pack_int (ptr, offset);
4601 
4602  offset = xts_save_cache_attrinfo (cls_spec->cache_key);
4603  if (offset == ER_FAILED)
4604  {
4605  return NULL;
4606  }
4607  ptr = or_pack_int (ptr, offset);
4608 
4609  ptr = or_pack_int (ptr, cls_spec->num_attrs_pred);
4610 
4611  offset = xts_save_int_array (cls_spec->attrids_pred, cls_spec->num_attrs_pred);
4612  if (offset == ER_FAILED)
4613  {
4614  return NULL;
4615  }
4616  ptr = or_pack_int (ptr, offset);
4617 
4618  offset = xts_save_cache_attrinfo (cls_spec->cache_pred);
4619  if (offset == ER_FAILED)
4620  {
4621  return NULL;
4622  }
4623  ptr = or_pack_int (ptr, offset);
4624 
4625  ptr = or_pack_int (ptr, cls_spec->num_attrs_rest);
4626 
4627  offset = xts_save_int_array (cls_spec->attrids_rest, cls_spec->num_attrs_rest);
4628  if (offset == ER_FAILED)
4629  {
4630  return NULL;
4631  }
4632  ptr = or_pack_int (ptr, offset);
4633 
4634  offset = xts_save_cache_attrinfo (cls_spec->cache_rest);
4635  if (offset == ER_FAILED)
4636  {
4637  return NULL;
4638  }
4639  ptr = or_pack_int (ptr, offset);
4640 
4641  ptr = or_pack_int (ptr, cls_spec->schema_type);
4642 
4643  ptr = or_pack_int (ptr, cls_spec->num_attrs_reserved);
4644 
4645  offset = xts_save_db_value_array (cls_spec->cache_reserved, cls_spec->num_attrs_reserved);
4646  if (offset == ER_FAILED)
4647  {
4648  return NULL;
4649  }
4650  ptr = or_pack_int (ptr, offset);
4651 
4653  if (offset == ER_FAILED)
4654  {
4655  return NULL;
4656  }
4657  ptr = or_pack_int (ptr, offset);
4658 
4659  ptr = or_pack_int (ptr, cls_spec->num_attrs_range);
4660 
4661  offset = xts_save_int_array (cls_spec->attrids_range, cls_spec->num_attrs_range);
4662  if (offset == ER_FAILED)
4663  {
4664  return NULL;
4665  }
4666  ptr = or_pack_int (ptr, offset);
4667 
4668  offset = xts_save_cache_attrinfo (cls_spec->cache_range);
4669  if (offset == ER_FAILED)
4670  {
4671  return NULL;
4672  }
4673  ptr = or_pack_int (ptr, offset);
4674 
4675  return ptr;
4676 }
4677 
4678 static char *
4680 {
4681  int offset;
4682 
4683  offset = xts_save_xasl_node (list_spec->xasl_node);
4684  if (offset == ER_FAILED)
4685  {
4686  return NULL;
4687  }
4688  ptr = or_pack_int (ptr, offset);
4689 
4690  offset = xts_save_regu_variable_list (list_spec->list_regu_list_pred);
4691  if (offset == ER_FAILED)
4692  {
4693  return NULL;
4694  }
4695  ptr = or_pack_int (ptr, offset);
4696 
4697  offset = xts_save_regu_variable_list (list_spec->list_regu_list_rest);
4698  if (offset == ER_FAILED)
4699  {
4700  return NULL;
4701  }
4702  ptr = or_pack_int (ptr, offset);
4703 
4704  offset = xts_save_regu_variable_list (list_spec->list_regu_list_build);
4705  if (offset == ER_FAILED)
4706  {
4707  return NULL;
4708  }
4709  ptr = or_pack_int (ptr, offset);
4710 
4711  offset = xts_save_regu_variable_list (list_spec->list_regu_list_probe);
4712  if (offset == ER_FAILED)
4713  {
4714  return NULL;
4715  }
4716  ptr = or_pack_int (ptr, offset);
4717 
4718  ptr = or_pack_int (ptr, list_spec->hash_list_scan_yn);
4719 
4720  return ptr;
4721 }
4722 
4723 static char *
4725 {
4726  int offset;
4727 
4728  ptr = or_pack_int (ptr, showstmt_spec->show_type);
4729 
4730  offset = xts_save_regu_variable_list (showstmt_spec->arg_list);
4731  if (offset == ER_FAILED)
4732  {
4733  return NULL;
4734  }
4735  ptr = or_pack_int (ptr, offset);
4736 
4737  return ptr;
4738 }
4739 
4740 static char *
4742 {
4743  /* here, currently empty implementation, actually, it can do some extra info save. */
4744  return ptr;
4745 }
4746 
4747 static char *
4749 {
4750  int offset;
4751 
4752  offset = xts_save_regu_variable (set_spec->set_ptr);
4753  if (offset == ER_FAILED)
4754  {
4755  return NULL;
4756  }
4757  ptr = or_pack_int (ptr, offset);
4758 
4759  offset = xts_save_regu_variable_list (set_spec->set_regu_list);
4760  if (offset == ER_FAILED)
4761  {
4762  return NULL;
4763  }
4764  ptr = or_pack_int (ptr, offset);
4765 
4766  return ptr;
4767 }
4768 
4769 static char *
4771 {
4772  ptr = or_pack_int (ptr, behavior->m_behavior);
4773 
4774  if (behavior->m_behavior == JSON_TABLE_DEFAULT_VALUE)
4775  {
4776  ptr = xts_process_db_value (ptr, behavior->m_default_value);
4777  }
4778 
4779  return ptr;
4780 }
4781 
4782 static char *
4783 xts_process (char *ptr, const json_table_column & jtc)
4784 {
4785  int offset;
4786  char *start_ptr = ptr;
4787 
4788  // save json function
4789  ptr = or_pack_int (ptr, jtc.m_function);
4790 
4791  // save output db_value pointer
4793  if (offset == ER_FAILED)
4794  {
4795  return NULL;
4796  }
4797  ptr = or_pack_int (ptr, offset);
4798 
4799  if (jtc.m_function == JSON_TABLE_ORDINALITY)
4800  {
4801  // nothing else required
4802  xts_debug_check (jtc, start_ptr, ptr);
4803  return ptr;
4804  }
4805 
4806  // save domain
4807  ptr = or_pack_domain (ptr, jtc.m_domain, 0, 0);
4808 
4809  // save path
4810  assert (jtc.m_path != NULL);
4811  offset = xts_save_string (jtc.m_path);
4812  if (offset == ER_FAILED)
4813  {
4814  return NULL;
4815  }
4816  ptr = or_pack_int (ptr, offset);
4817 
4818  // save column_name
4819  assert (jtc.m_column_name != NULL);
4820  offset = xts_save_string (jtc.m_column_name);
4821  if (offset == ER_FAILED)
4822  {
4823  return NULL;
4824  }
4825  ptr = or_pack_int (ptr, offset);
4826 
4827  if (jtc.m_function == JSON_TABLE_EXISTS)
4828  {
4829  xts_debug_check (jtc, start_ptr, ptr);
4830  return ptr;
4831  }
4832 
4833  // save on_error_behavior
4836 
4837  xts_debug_check (jtc, start_ptr, ptr);
4838 
4839  return ptr;
4840 }
4841 
4842 static char *
4843 xts_process (char *ptr, const json_table_node & jtn)
4844 {
4845  int offset;
4846  char *start_ptr = ptr;
4847 
4848  // save string
4849  offset = xts_save_string (jtn.m_path);
4850  if (offset == ER_FAILED)
4851  {
4852  return NULL;
4853  }
4854  ptr = or_pack_int (ptr, offset);
4855 
4856  // save m_output_columns
4857  ptr = or_pack_int (ptr, (int) jtn.m_output_columns_size);
4858  for (size_t i = 0; i < jtn.m_output_columns_size; ++i)
4859  {
4860  ptr = xts_process (ptr, jtn.m_output_columns[i]);
4861  }
4862 
4863  // save nested nodes
4864  ptr = or_pack_int (ptr, (int) jtn.m_nested_nodes_size);
4865  for (size_t i = 0; i < jtn.m_nested_nodes_size; ++i)
4866  {
4867  ptr = xts_process (ptr, jtn.m_nested_nodes[i]);
4868  }
4869 
4870  ptr = or_pack_int (ptr, (int) jtn.m_id);
4871 
4872  ptr = or_pack_int (ptr, (int) jtn.m_is_iterable_node);
4873 
4874  xts_debug_check (jtn, start_ptr, ptr);
4875 
4876  return ptr;
4877 }
4878 
4879 static char *
4880 xts_process (char *ptr, const json_table_spec_node & json_table_spec)
4881 {
4882  int offset;
4883  char *start_ptr = ptr;
4884 
4885  ptr = or_pack_int (ptr, (int) json_table_spec.m_node_count);
4886 
4887  offset = xts_save_regu_variable (json_table_spec.m_json_reguvar);
4888  if (offset == ER_FAILED)
4889  {
4890  return NULL;
4891  }
4892  ptr = or_pack_int (ptr, offset);
4893 
4894  ptr = xts_process (ptr, *json_table_spec.m_root_node);
4895 
4896  xts_debug_check (json_table_spec, start_ptr, ptr);
4897 
4898  return ptr;
4899 }
4900 
4901 static char *
4903 {
4904  int offset;
4905 
4906  offset = xts_save_xasl_node (method_spec->xasl_node);
4907  if (offset == ER_FAILED)
4908  {
4909  return NULL;
4910  }
4911  ptr = or_pack_int (ptr, offset);
4912 
4913  offset = xts_save_regu_variable_list (method_spec->method_regu_list);
4914  if (offset == ER_FAILED)
4915  {
4916  return NULL;
4917  }
4918  ptr = or_pack_int (ptr, offset);
4919 
4920  offset = xts_save_method_sig_list (method_spec->method_sig_list);
4921  if (offset == ER_FAILED)
4922  {
4923  return NULL;
4924  }
4925  ptr = or_pack_int (ptr, offset);
4926 
4927  return ptr;
4928 }
4929 
4930 static char *
4931 xts_process_list_id (char *ptr, const QFILE_LIST_ID * list_id)
4932 {
4933  /* is from client to server */
4934  assert_release (list_id->type_list.type_cnt == 0);
4935  assert_release (list_id->type_list.domp == NULL);
4936 
4937  return or_pack_listid (ptr, (void *) list_id);
4938 }
4939 
4940 static char *
4941 xts_process_val_list (char *ptr, const VAL_LIST * val_list)
4942 {
4943  int offset;
4944  int i;
4946 
4947  ptr = or_pack_int (ptr, val_list->val_cnt);
4948 
4949  for (i = 0, p = val_list->valp; i < val_list->val_cnt; i++, p = p->next)
4950  {
4951  offset = xts_save_db_value (p->val);
4952  if (offset == ER_FAILED)
4953  {
4954  return NULL;
4955  }
4956 
4957  ptr = or_pack_int (ptr, offset);
4958  }
4959 
4960  return ptr;
4961 }
4962 
4963 static char *
4965 {
4966  int offset;
4967 
4968  /* we prepend the domain before we pack the regu_variable */
4969  ptr = OR_PACK_DOMAIN_OBJECT_TO_OID (ptr, regu_var->domain, 0, 0);
4970 
4971  ptr = or_pack_int (ptr, regu_var->type);
4972 
4975  ptr = or_pack_int (ptr, regu_var->flags);
4976 
4977  offset = xts_save_db_value (regu_var->vfetch_to);
4978  if (offset == ER_FAILED)
4979  {
4980  return NULL;
4981  }
4982  ptr = or_pack_int (ptr, offset);
4983 
4984  offset = xts_save_xasl_node (regu_var->xasl);
4985  if (offset == ER_FAILED)
4986  {
4987  return NULL;
4988  }
4989  ptr = or_pack_int (ptr, offset);
4990 
4991  ptr = xts_pack_regu_variable_value (ptr, regu_var);
4992 
4993  return ptr;
4994 }
4995 
4996 static char *
4998 {
4999  int offset;
5000 
5001  assert (ptr != NULL && regu_var != NULL);
5002 
5003  switch (regu_var->type)
5004  {
5005  case TYPE_REGU_VAR_LIST:
5006  ptr = xts_process_regu_variable_list (ptr, regu_var->value.regu_var_list);
5007  if (ptr == NULL)
5008  {
5009  return NULL;
5010  }
5011  break;
5012 
5013  case TYPE_REGUVAL_LIST:
5014  ptr = xts_process_regu_value_list (ptr, regu_var->value.reguval_list);
5015  if (ptr == NULL)
5016  {
5017  return NULL;
5018  }
5019  break;
5020 
5021  case TYPE_DBVAL:
5022  ptr = xts_process_db_value (ptr, &regu_var->value.dbval);
5023  if (ptr == NULL)
5024  {
5025  return NULL;
5026  }
5027  break;
5028 
5029  case TYPE_CONSTANT:
5030  case TYPE_ORDERBY_NUM:
5031  offset = xts_save_db_value (regu_var->value.dbvalptr);
5032  if (offset == ER_FAILED)
5033  {
5034  return NULL;
5035  }
5036  ptr = or_pack_int (ptr, offset);
5037  break;
5038 
5039  case TYPE_INARITH:
5040  case TYPE_OUTARITH:
5041  offset = xts_save_arith_type (regu_var->value.arithptr);
5042  if (offset == ER_FAILED)
5043  {
5044  return NULL;
5045  }
5046  ptr = or_pack_int (ptr, offset);
5047  break;
5048 
5049  case TYPE_FUNC:
5050  offset = xts_save_function_type (regu_var->value.funcp);
5051  if (offset == ER_FAILED)
5052  {
5053  return NULL;
5054  }
5055  ptr = or_pack_int (ptr, offset);
5056  break;
5057 
5058  case TYPE_ATTR_ID:
5059  case TYPE_SHARED_ATTR_ID:
5060  case TYPE_CLASS_ATTR_ID:
5061  ptr = xts_process_attr_descr (ptr, &regu_var->value.attr_descr);
5062  if (ptr == NULL)
5063  {
5064  return NULL;
5065  }
5066  break;
5067 
5068  case TYPE_LIST_ID:
5069  offset = xts_save_srlist_id (regu_var->value.srlist_id);
5070  if (offset == ER_FAILED)
5071  {
5072  return NULL;
5073  }
5074  ptr = or_pack_int (ptr, offset);
5075  break;
5076 
5077  case TYPE_POSITION:
5078  ptr = xts_process_pos_descr (ptr, &regu_var->value.pos_descr);
5079  if (ptr == NULL)
5080  {
5081  return NULL;
5082  }
5083  break;
5084 
5085  case TYPE_POS_VALUE:
5086  ptr = or_pack_int (ptr, regu_var->value.val_pos);
5087  break;
5088 
5089  case TYPE_OID:
5090  case TYPE_CLASSOID:
5091  break;
5092 
5093  default:
5095  return NULL;
5096  }
5097 
5098  return ptr;
5099 }
5100 
5101 static char *
5102 xts_process_attr_descr (char *ptr, const ATTR_DESCR * attr_descr)
5103 {
5104  int offset;
5105 
5106  ptr = or_pack_int (ptr, attr_descr->id);
5107 
5108  ptr = or_pack_int (ptr, attr_descr->type);
5109 
5110  offset = xts_save_cache_attrinfo (attr_descr->cache_attrinfo);
5111  if (offset == ER_FAILED)
5112  {
5113  return NULL;
5114  }
5115  ptr = or_pack_int (ptr, offset);
5116 
5117  return ptr;
5118 }
5119 
5120 static char *
5122 {
5123  ptr = or_pack_int (ptr, position_descr->pos_no);
5124  ptr = OR_PACK_DOMAIN_OBJECT_TO_OID (ptr, position_descr->dom, 0, 0);
5125 
5126  return ptr;
5127 }
5128 
5129 static char *
5130 xts_process_db_value (char *ptr, const DB_VALUE * value)
5131 {
5132  ptr = or_pack_db_value (ptr, (DB_VALUE *) value);
5133 
5134  return ptr;
5135 }
5136 
5137 static char *
5138 xts_process_arith_type (char *ptr, const ARITH_TYPE * arith)
5139 {
5140  int offset;
5141 
5142  ptr = OR_PACK_DOMAIN_OBJECT_TO_OID (ptr, arith->domain, 0, 0);
5143 
5144  offset = xts_save_db_value (arith->value);
5145  if (offset == ER_FAILED)
5146  {
5147  return NULL;
5148  }
5149  ptr = or_pack_int (ptr, offset);
5150 
5151  ptr = or_pack_int (ptr, arith->opcode);
5152 
5153  offset = xts_save_regu_variable (arith->leftptr);
5154  if (offset == ER_FAILED)
5155  {
5156  return NULL;
5157  }
5158  ptr = or_pack_int (ptr, offset);
5159 
5160  offset = xts_save_regu_variable (arith->rightptr);
5161  if (offset == ER_FAILED)
5162  {
5163  return NULL;
5164  }
5165  ptr = or_pack_int (ptr, offset);
5166 
5167  offset = xts_save_regu_variable (arith->thirdptr);
5168  if (offset == ER_FAILED)
5169  {
5170  return NULL;
5171  }
5172  ptr = or_pack_int (ptr, offset);
5173 
5174  ptr = or_pack_int (ptr, arith->misc_operand);
5175 
5176  if (arith->opcode == T_CASE || arith->opcode == T_DECODE || arith->opcode == T_PREDICATE || arith->opcode == T_IF)
5177  {
5178  offset = xts_save_pred_expr (arith->pred);
5179  if (offset == ER_FAILED)
5180  {
5181  return NULL;
5182  }
5183  ptr = or_pack_int (ptr, offset);
5184  }
5185 
5186  return ptr;
5187 }
5188 
5189 static char *
5191 {
5192  int offset;
5193 
5194  ptr = OR_PACK_DOMAIN_OBJECT_TO_OID (ptr, aggregate->domain, 0, 0);
5195 
5196  offset = xts_save_db_value (aggregate->accumulator.value);
5197  if (offset == ER_FAILED)
5198  {
5199  return NULL;
5200  }
5201  ptr = or_pack_int (ptr, offset);
5202 
5203  offset = xts_save_db_value (aggregate->accumulator.value2);
5204  if (offset == ER_FAILED)
5205  {
5206  return NULL;
5207  }
5208  ptr = or_pack_int (ptr, offset);
5209 
5210  ptr = or_pack_int (ptr, aggregate->accumulator.curr_cnt);
5211 
5212  offset = xts_save_aggregate_type (aggregate->next);
5213  if (offset == ER_FAILED)
5214  {
5215  return NULL;
5216  }
5217  ptr = or_pack_int (ptr, offset);
5218 
5219  ptr = or_pack_int (ptr, aggregate->function);
5220 
5221  ptr = or_pack_int (ptr, aggregate->option);
5222 
5223  ptr = or_pack_int (ptr, (int) aggregate->opr_dbtype);
5224 
5225  ptr = xts_process_regu_variable_list (ptr, aggregate->operands);
5226  if (ptr == NULL)
5227  {
5228  return NULL;
5229  }
5230 
5231  if (aggregate->list_id == NULL)
5232  {
5233  ptr = or_pack_int (ptr, 0);
5234  }
5235  else
5236  {
5237  offset = xts_save_list_id (aggregate->list_id);
5238  if (offset == ER_FAILED)
5239  {
5240  return NULL;
5241  }
5242  ptr = or_pack_int (ptr, offset);
5243  }
5244 
5245  ptr = or_pack_int (ptr, aggregate->flag_agg_optimize);
5246 
5247  ptr = or_pack_btid (ptr, (BTID *) (&aggregate->btid));
5248  if (ptr == NULL)
5249  {
5250  return NULL;
5251  }
5252 
5253  offset = xts_save_sort_list (aggregate->sort_list);
5254  if (offset == ER_FAILED)
5255  {
5256  return NULL;
5257  }
5258  ptr = or_pack_int (ptr, offset);
5259 
5260  if (aggregate->function == PT_PERCENTILE_CONT || aggregate->function == PT_PERCENTILE_DISC)
5261  {
5262  /* percentile_reguvar */
5264  if (offset == ER_FAILED)
5265  {
5266  return NULL;
5267  }
5268 
5269  ptr = or_pack_int (ptr, offset);
5270  }
5271 
5272  return ptr;
5273 }
5274 
5275 static char *
5277 {
5278  int offset;
5279 
5280  offset = xts_save_db_value (function->value);
5281  if (offset == ER_FAILED)
5282  {
5283  return NULL;
5284  }
5285  ptr = or_pack_int (ptr, offset);
5286 
5287  ptr = or_pack_int (ptr, function->ftype);
5288 
5289  offset = xts_save_regu_variable_list (function->operand);
5290  if (offset == ER_FAILED)
5291  {
5292  return NULL;
5293  }
5294  ptr = or_pack_int (ptr, offset);
5295 
5296  return ptr;
5297 }
5298 
5299 static char *
5301 {
5302  int offset;
5303 
5304  ptr = OR_PACK_DOMAIN_OBJECT_TO_OID (ptr, analytic->domain, 0, 0);
5305 
5306  offset = xts_save_db_value (analytic->value);
5307  if (offset == ER_FAILED)
5308  {
5309  return NULL;
5310  }
5311  ptr = or_pack_int (ptr, offset);
5312 
5313  offset = xts_save_db_value (analytic->value2);
5314  if (offset == ER_FAILED)
5315  {
5316  return NULL;
5317  }
5318  ptr = or_pack_int (ptr, offset);
5319 
5320  offset = xts_save_db_value (analytic->out_value);
5321  if (offset == ER_FAILED)
5322  {
5323  return NULL;
5324  }
5325  ptr = or_pack_int (ptr, offset);
5326 
5327  ptr = or_pack_int (ptr, analytic->offset_idx);
5328 
5329  ptr = or_pack_int (ptr, analytic->default_idx);
5330 
5331  offset = xts_save_analytic_type (analytic->next);
5332  if (offset == ER_FAILED)
5333  {
5334  return NULL;
5335  }
5336  ptr = or_pack_int (ptr, offset);
5337 
5338  ptr = or_pack_int (ptr, analytic->function);
5339 
5340  ptr = or_pack_int (ptr, analytic->option);
5341 
5342  ptr = or_pack_int (ptr, (int) analytic->opr_dbtype);
5343 
5344  ptr = xts_process_regu_variable (ptr, &analytic->operand);
5345  if (ptr == NULL)
5346  {
5347  return NULL;
5348  }
5349 
5350  if (analytic->list_id == NULL)
5351  {
5352  ptr = or_pack_int (ptr, 0);
5353  }
5354  else
5355  {
5356  offset = xts_save_list_id (analytic->list_id);
5357  if (offset == ER_FAILED)
5358  {
5359  return NULL;
5360  }
5361  ptr = or_pack_int (ptr, offset);
5362  }
5363 
5364  ptr = or_pack_int (ptr, analytic->sort_prefix_size);
5365 
5366  ptr = or_pack_int (ptr, analytic->sort_list_size);
5367 
5368  ptr = or_pack_int (ptr, analytic->flag);
5369 
5370  ptr = or_pack_int (ptr, analytic->from_last);
5371 
5372  ptr = or_pack_int (ptr, analytic->ignore_nulls);
5373 
5374  ptr = or_pack_int (ptr, analytic->is_const_operand);
5375 
5376  if (analytic->function == PT_PERCENTILE_CONT || analytic->function == PT_PERCENTILE_DISC)
5377  {
5379  if (offset == ER_FAILED)
5380  {
5381  return NULL;
5382  }
5383 
5384  ptr = or_pack_int (ptr, offset);
5385  }
5386 
5387  return ptr;
5388 }
5389 
5390 static char *
5392 {
5393  int offset;
5394 
5395  offset = xts_save_analytic_type (analytic_eval->head);
5396  if (offset == ER_FAILED)
5397  {
5398  return NULL;
5399  }
5400  ptr = or_pack_int (ptr, offset);
5401 
5402  offset = xts_save_sort_list (analytic_eval->sort_list);
5403  if (offset == ER_FAILED)
5404  {
5405  return NULL;
5406  }
5407  ptr = or_pack_int (ptr, offset);
5408 
5409  offset = xts_save_analytic_eval_type (analytic_eval->next);
5410  if (offset == ER_FAILED)
5411  {
5412  return NULL;
5413  }
5414  ptr = or_pack_int (ptr, offset);
5415 
5416  return ptr;
5417 }
5418 
5419 static char *
5420 xts_process_srlist_id (char *ptr, const QFILE_SORTED_LIST_ID * sort_list_id)
5421 {
5422  int offset;
5423 
5424  ptr = or_pack_int (ptr, sort_list_id->sorted);
5425 
5426  offset = xts_save_list_id (sort_list_id->list_id);
5427  if (offset == ER_FAILED)
5428  {
5429  return NULL;
5430  }
5431  ptr = or_pack_int (ptr, offset);
5432 
5433  return ptr;
5434 }
5435 
5436 static char *
5438 {
5439  int offset;
5440 
5441  offset = xts_save_sort_list (sort_list->next);
5442  if (offset == ER_FAILED)
5443  {
5444  return NULL;
5445  }
5446  ptr = or_pack_int (ptr, offset);
5447 
5448  ptr = xts_process_pos_descr (ptr, &sort_list->pos_descr);
5449  if (ptr == NULL)
5450  {
5451  return NULL;
5452  }
5453 
5454  ptr = or_pack_int (ptr, sort_list->s_order);
5455  ptr = or_pack_int (ptr, sort_list->s_nulls);
5456 
5457  /* others (not sent to server) */
5458 
5459  return ptr;
5460 }
5461 
5462 /*
5463  * xts_process_method_sig_list ( ) -
5464  *
5465  * Note: do not use or_pack_method_sig_list
5466  */
5467 static char *
5469 {
5470  int offset;
5471 
5472 #if !defined(NDEBUG)
5473  {
5474  int i = 0;
5475  METHOD_SIG *sig;
5476 
5477  for (sig = method_sig_list->method_sig; sig; sig = sig->next)
5478  {
5479  i++;
5480  }
5481  assert (method_sig_list->num_methods == i);
5482  }
5483 #endif
5484 
5485  ptr = or_pack_int (ptr, method_sig_list->num_methods);
5486 
5487  offset = xts_save_method_sig (method_sig_list->method_sig, method_sig_list->num_methods);
5488  if (offset == ER_FAILED)
5489  {
5490  return NULL;
5491  }
5492  ptr = or_pack_int (ptr, offset);
5493 
5494  return ptr;
5495 }
5496 
5497 static char *
5498 xts_process_method_sig (char *ptr, const METHOD_SIG * method_sig, int count)
5499 {
5500  int offset;
5501  int n;
5502 
5503  assert (method_sig->method_name != NULL);
5504 
5505  offset = xts_save_string (method_sig->method_name);
5506  if (offset == ER_FAILED)
5507  {
5508  return NULL;
5509  }
5510  ptr = or_pack_int (ptr, offset);
5511 
5512  offset = xts_save_string (method_sig->class_name); /* is can be null */
5513  if (offset == ER_FAILED)
5514  {
5515  return NULL;
5516  }
5517  ptr = or_pack_int (ptr, offset);
5518 
5519  ptr = or_pack_int (ptr, method_sig->method_type);
5520  ptr = or_pack_int (ptr, method_sig->num_method_args);
5521 
5522  for (n = 0; n < method_sig->num_method_args + 1; n++)
5523  {
5524  ptr = or_pack_int (ptr, method_sig->method_arg_pos[n]);
5525  }
5526 
5527  offset = xts_save_method_sig (method_sig->next, count - 1);
5528  if (offset == ER_FAILED)
5529  {
5530  return NULL;
5531  }
5532  ptr = or_pack_int (ptr, offset);
5533 
5534  return ptr;
5535 }
5536 
5537 static char *
5538 xts_process_connectby_proc (char *ptr, const CONNECTBY_PROC_NODE * connectby_proc)
5539 {
5540  int offset;
5541 
5542  offset = xts_save_pred_expr (connectby_proc->start_with_pred);
5543  if (offset == ER_FAILED)
5544  {
5545  return NULL;
5546  }
5547  ptr = or_pack_int (ptr, offset);
5548 
5549  offset = xts_save_pred_expr (connectby_proc->after_connect_by_pred);
5550  if (offset == ER_FAILED)
5551  {
5552  return NULL;
5553  }
5554  ptr = or_pack_int (ptr, offset);
5555 
5556  offset = xts_save_list_id (connectby_proc->input_list_id);
5557  if (offset == ER_FAILED)
5558  {
5559  return NULL;
5560  }
5561  ptr = or_pack_int (ptr, offset);
5562 
5563  offset = xts_save_list_id (connectby_proc->start_with_list_id);
5564  if (offset == ER_FAILED)
5565  {
5566  return NULL;
5567  }
5568  ptr = or_pack_int (ptr, offset);
5569 
5570  offset = xts_save_regu_variable_list (connectby_proc->regu_list_pred);
5571  if (offset == ER_FAILED)
5572  {
5573  return NULL;
5574  }
5575  ptr = or_pack_int (ptr, offset);
5576 
5577  offset = xts_save_regu_variable_list (connectby_proc->regu_list_rest);
5578  if (offset == ER_FAILED)
5579  {
5580  return NULL;
5581  }
5582  ptr = or_pack_int (ptr, offset);
5583 
5584  offset = xts_save_val_list (connectby_proc->prior_val_list);
5585  if (offset == ER_FAILED)
5586  {
5587  return NULL;
5588  }
5589  ptr = or_pack_int (ptr, offset);
5590 
5591  offset = xts_save_outptr_list (connectby_proc->prior_outptr_list);
5592  if (offset == ER_FAILED)
5593  {
5594  return NULL;
5595  }
5596  ptr = or_pack_int (ptr, offset);
5597 
5598  offset = xts_save_regu_variable_list (connectby_proc->prior_regu_list_pred);
5599  if (offset == ER_FAILED)
5600  {
5601  return NULL;
5602  }
5603  ptr = or_pack_int (ptr, offset);
5604 
5605  offset = xts_save_regu_variable_list (connectby_proc->prior_regu_list_rest);
5606  if (offset == ER_FAILED)
5607  {
5608  return NULL;
5609  }
5610  ptr = or_pack_int (ptr, offset);
5611 
5612  offset = xts_save_regu_variable_list (connectby_proc->after_cb_regu_list_pred);
5613  if (offset == ER_FAILED)
5614  {
5615  return NULL;
5616  }
5617  ptr = or_pack_int (ptr, offset);
5618 
5619  offset = xts_save_regu_variable_list (connectby_proc->after_cb_regu_list_rest);
5620  if (offset == ER_FAILED)
5621  {
5622  return NULL;
5623  }
5624  ptr = or_pack_int (ptr, offset);
5625 
5626  ptr = or_pack_int (ptr, (int) connectby_proc->single_table_opt);
5627 
5628  return ptr;
5629 }
5630 
5631 /*
5632  * xts_process_regu_value_list () -
5633  * return:
5634  * ptr(in) :
5635  * regu_value_list(int) :
5636  */
5637 static char *
5639 {
5641  REGU_DATATYPE type;
5642 
5643  assert (regu_value_list != NULL);
5644 
5645  ptr = or_pack_int (ptr, regu_value_list->count);
5646  for (regu_value_item = regu_value_list->regu_list; regu_value_item; regu_value_item = regu_value_item->next)
5647  {
5648  type = regu_value_item->value->type;
5649  if (type != TYPE_DBVAL && type != TYPE_INARITH && type != TYPE_POS_VALUE)
5650  {
5652  return NULL;
5653  }
5654  ptr = or_pack_int (ptr, type);
5655 
5656  ptr = xts_pack_regu_variable_value (ptr, regu_value_item->value);
5657  if (ptr == NULL)
5658  {
5659  return NULL;
5660  }
5661  }
5662 
5663  return ptr;
5664 }
5665 
5666 /*
5667  * xts_sizeof_xasl_node () -
5668  * return:
5669  * xasl(in) :
5670  */
5671 static int
5673 {
5674  int size = 0;
5675  int tmp_size = 0;
5676  ACCESS_SPEC_TYPE *access_spec = NULL;
5677 
5678  size += (XASL_NODE_HEADER_SIZE /* header */
5679  + OR_INT_SIZE /* type */
5680  + OR_INT_SIZE /* flag */
5681  + PTR_SIZE /* list_id */
5682  + PTR_SIZE /* after_iscan_list */
5683  + PTR_SIZE /* orderby_list */
5684  + PTR_SIZE /* ordbynum_pred */
5685  + PTR_SIZE /* ordbynum_val */
5686  + PTR_SIZE /* orderby_limit */
5687  + OR_INT_SIZE /* ordbynum_flag */
5688  + PTR_SIZE /* single_tuple */
5689  + OR_INT_SIZE /* is_single_tuple */
5690  + OR_INT_SIZE /* option */
5691  + PTR_SIZE /* outptr_list */
5692  + PTR_SIZE /* selected_upd_list */
5693  + PTR_SIZE /* val_list */
5694  + PTR_SIZE /* merge_val_list */
5695  + PTR_SIZE /* aptr_list */
5696  + PTR_SIZE /* bptr_list */
5697  + PTR_SIZE /* dptr_list */
5698  + PTR_SIZE /* after_join_pred */
5699  + PTR_SIZE /* if_pred */
5700  + PTR_SIZE /* instnum_pred */
5701  + PTR_SIZE /* instnum_val */
5702  + PTR_SIZE /* save_instnum_val */
5703  + OR_INT_SIZE /* instnum_flag */
5704  + PTR_SIZE /* limit_offset */
5705  + PTR_SIZE /* limit_row_count */
5706  + PTR_SIZE /* fptr_list */
5707  + PTR_SIZE /* scan_ptr */
5708  + PTR_SIZE /* connect_by_ptr */
5709  + PTR_SIZE /* level_val */
5710  + PTR_SIZE /* level_regu */
5711  + PTR_SIZE /* isleaf_val */
5712  + PTR_SIZE /* isleaf_regu */
5713  + PTR_SIZE /* iscycle_val */
5714  + PTR_SIZE /* iscycle_regu */
5715  + OR_INT_SIZE /* next_scan_on */
5716  + OR_INT_SIZE /* next_scan_block_on */
5717  + OR_INT_SIZE /* cat_fetched */
5718  + OR_INT_SIZE /* scan_op_type */
5719  + OR_INT_SIZE /* upd_del_class_cnt */
5720  + OR_INT_SIZE); /* mvcc_reev_extra_cls_cnt */
5721 
5722  size += OR_INT_SIZE; /* number of access specs in spec_list */
5723  for (access_spec = xasl->spec_list; access_spec; access_spec = access_spec->next)
5724  {
5725  size += xts_sizeof_access_spec_type (access_spec);
5726  }
5727 
5728  size += OR_INT_SIZE; /* number of access specs in merge_spec */
5729  for (access_spec = xasl->merge_spec; access_spec; access_spec = access_spec->next)
5730  {
5731  size += xts_sizeof_access_spec_type (access_spec);
5732  }
5733 
5734  size += OR_INT_SIZE; /* number of access specs in curr_spec */
5735  for (access_spec = xasl->curr_spec; access_spec; access_spec = access_spec->next)
5736  {
5737  size += xts_sizeof_access_spec_type (access_spec);
5738  }
5739 
5740  switch (xasl->type)
5741  {
5742  case BUILDLIST_PROC:
5743  tmp_size = xts_sizeof_buildlist_proc (&xasl->proc.buildlist);
5744  if (tmp_size == ER_FAILED)
5745  {
5746  return ER_FAILED;
5747  }
5748  size += tmp_size;
5749  break;
5750 
5751  case BUILDVALUE_PROC:
5752  tmp_size = xts_sizeof_buildvalue_proc (&xasl->proc.buildvalue);
5753  if (tmp_size == ER_FAILED)
5754  {
5755  return ER_FAILED;
5756  }
5757  size += tmp_size;
5758  break;
5759 
5760  case MERGELIST_PROC:
5761  tmp_size = xts_sizeof_mergelist_proc (&xasl->proc.mergelist);
5762  if (tmp_size == ER_FAILED)
5763  {
5764  return ER_FAILED;
5765  }
5766  size += tmp_size;
5767  break;
5768 
5769  case CONNECTBY_PROC:
5770  tmp_size = xts_sizeof_connectby_proc (&xasl->proc.connect_by);
5771  if (tmp_size == ER_FAILED)
5772  {
5773  return ER_FAILED;
5774  }
5775  size += tmp_size;
5776  break;
5777 
5778  case UPDATE_PROC:
5779  tmp_size = xts_sizeof_update_proc (&xasl->proc.update);
5780  if (tmp_size == ER_FAILED)
5781  {
5782  return ER_FAILED;
5783  }
5784  size += tmp_size;
5785  break;
5786 
5787  case DELETE_PROC:
5788  tmp_size = xts_sizeof_delete_proc (&xasl->proc.delete_);
5789  if (tmp_size == ER_FAILED)
5790  {
5791  return ER_FAILED;
5792  }
5793  size += tmp_size;
5794  break;
5795 
5796  case INSERT_PROC:
5797  tmp_size = xts_sizeof_insert_proc (&xasl->proc.insert);
5798  if (tmp_size == ER_FAILED)
5799  {
5800  return ER_FAILED;
5801  }
5802  size += tmp_size;
5803  break;
5804 
5805  case UNION_PROC:
5806  case DIFFERENCE_PROC:
5807  case INTERSECTION_PROC:
5808  tmp_size = xts_sizeof_union_proc (&xasl->proc.union_);
5809  if (tmp_size == ER_FAILED)
5810  {
5811  return ER_FAILED;
5812  }
5813  size += tmp_size;
5814  break;
5815 
5816  case OBJFETCH_PROC:
5817  tmp_size = xts_sizeof_fetch_proc (&xasl->proc.fetch);
5818  if (tmp_size == ER_FAILED)
5819  {
5820  return ER_FAILED;
5821  }
5822  size += tmp_size;
5823  break;
5824 
5825  case SCAN_PROC:
5826  break;
5827 
5828  case DO_PROC:
5829  break;
5830 
5831  case BUILD_SCHEMA_PROC:
5832  break;
5833 
5834  case MERGE_PROC:
5835  size += xts_sizeof_merge_proc (&xasl->proc.merge);
5836  break;
5837 
5838  case CTE_PROC:
5839  size += xts_sizeof_cte_proc (&xasl->proc.cte);
5840  break;
5841 
5842  default:
5844  return ER_FAILED;
5845  }
5846 
5847  size += (OR_INT_SIZE /* projected_size */
5848  + OR_DOUBLE_ALIGNED_SIZE /* cardinality */
5849  + OR_INT_SIZE /* iscan_oid_order */
5850  + PTR_SIZE /* query_alias */
5851  + PTR_SIZE); /* next */
5852 
5853  return size;
5854 }
5855 
5856 /*
5857  * xts_sizeof_filter_pred_node () -
5858  * return:
5859  * pred(in): PRED_EXPR_WITH_CONTEXT
5860  */
5861 static int
5863 {
5864  int size = 0;
5865 
5866  size += (PTR_SIZE /* PRED_EXPR pointer: pred */
5867  + OR_INT_SIZE /* num_attrs_pred */
5868  + PTR_SIZE /* array pointer : */
5869  + PTR_SIZE); /* HEAP_CACHE_ATTRINFO pointer: cache_pred */
5870 
5871  return size;
5872 }
5873 
5874 /*
5875  * xts_sizeof_func_pred () -
5876  * return:
5877  * xasl(in):
5878  */
5879 static int
5881 {
5882  int size = 0;
5883 
5884  size += (PTR_SIZE /* REGU_VAR pointer */
5885  + PTR_SIZE); /* HEAP_CACHE_ATTRINFO pointer */
5886 
5887  return size;
5888 }
5889 
5890 /*
5891  * xts_sizeof_cache_attrinfo () -
5892  * return:
5893  * ptr(in) :
5894  */
5895 static int
5897 {
5898  return OR_INT_SIZE; /* dummy 0 */
5899 }
5900 
5901 /*
5902  * xts_sizeof_union_proc () -
5903  * return:
5904  * ptr(in) :
5905  */
5906 static int
5908 {
5909  int size = 0;
5910 
5911  size += (PTR_SIZE /* left */
5912  + PTR_SIZE); /* right */
5913 
5914  return size;
5915 }
5916 
5917 /*
5918  * xts_sizeof_fetch_proc () -
5919  * return:
5920  * ptr(in) :
5921  */
5922 static int
5923 xts_sizeof_fetch_proc (const FETCH_PROC_NODE * obj_set_fetch_proc)
5924 {
5925  int size = 0;
5926 
5927  size += (PTR_SIZE /* arg */
5928  + OR_INT_SIZE /* fetch_res */
5929  + PTR_SIZE /* set_pred */
5930  + OR_INT_SIZE); /* ql_flag */
5931 
5932  return size;
5933 }
5934 
5935 /*
5936  * xts_sizeof_buildlist_proc () -
5937  * return:
5938  * ptr(in) :
5939  */
5940 static int
5942 {
5943  int size = 0;
5944 
5945  size += (0 /* output_columns (not sent to server) */
5946  + PTR_SIZE /* eptr_list */
5947  + PTR_SIZE /* groupby_list */
5948  + PTR_SIZE /* after_groupby_list */
5949  + PTR_SIZE /* push_list_id */
5950  + PTR_SIZE /* g_outptr_list */
5951  + PTR_SIZE /* g_regu_list */
5952  + PTR_SIZE /* g_val_list */
5953  + PTR_SIZE /* g_having_pred */
5954  + PTR_SIZE /* g_grbynum_pred */
5955  + PTR_SIZE /* g_grbynum_val */
5956  + PTR_SIZE /* g_hk_scan_regu_list */
5957  + PTR_SIZE /* g_hk_sort_regu_list */
5958  + PTR_SIZE /* g_scan_regu_list */
5959  + OR_INT_SIZE /* g_grbynum_flag */
5960  + OR_INT_SIZE /* g_with_rollup */
5961  + OR_INT_SIZE /* g_hash_eligible */
5962  + OR_INT_SIZE /* g_output_first_tuple */
5963  + OR_INT_SIZE /* g_hkey_size */
5964  + OR_INT_SIZE /* g_func_count */
5965  + PTR_SIZE /* g_agg_list */
5966  + PTR_SIZE /* a_func_list */
5967  + PTR_SIZE /* a_regu_list */
5968  + PTR_SIZE /* a_outptr_list */
5969  + PTR_SIZE /* a_outptr_list_ex */
5970  + PTR_SIZE /* a_outptr_list_interm */
5971  + PTR_SIZE); /* a_val_list */
5972  return size;
5973 }
5974 
5975 /*
5976  * xts_sizeof_buildvalue_proc () -
5977  * return:
5978  * ptr(in) :
5979  */
5980 static int
5982 {
5983  int size = 0;
5984 
5985  size += (PTR_SIZE /* having_pred */
5986  + PTR_SIZE /* grbynum_val */
5987  + PTR_SIZE /* agg_list */
5988  + PTR_SIZE /* outarith_list */
5989  + OR_INT_SIZE); /* is_always_false */
5990 
5991  return size;
5992 }
5993 
5994 /*
5995  * xts_sizeof_ls_merge_info () -
5996  * return:
5997  * ptr(in) :
5998  */
5999 static int
6001 {
6002  int size = 0;
6003 
6004  size += (OR_INT_SIZE /* join_type */
6005  + OR_INT_SIZE /* single_fetch */
6006  + OR_INT_SIZE /* ls_column_cnt */
6007  + PTR_SIZE /* ls_outer_column */
6008  + PTR_SIZE /* ls_outer_unique */
6009  + PTR_SIZE /* ls_inner_column */
6010  + PTR_SIZE /* ls_inner_unique */
6011  + OR_INT_SIZE /* ls_pos_cnt */
6012  + PTR_SIZE /* ls_outer_inner_list */
6013  + PTR_SIZE); /* ls_pos_list */
6014 
6015  return size;
6016 }
6017 
6018 /*
6019  * xts_sizeof_mergelist_proc () -
6020  * return:
6021  * ptr(in) :
6022  */
6023 static int
6025 {
6026  int size = 0;
6027  ACCESS_SPEC_TYPE *access_spec = NULL;
6028 
6029  size += (PTR_SIZE /* outer_xasl */
6030  + PTR_SIZE /* outer_val_list */
6031  + PTR_SIZE /* inner_xasl */
6032  + PTR_SIZE /* inner_val_list */
6033  + xts_sizeof_ls_merge_info (&merge_list_info->ls_merge)); /* ls_merge_info */
6034 
6035  size += OR_INT_SIZE; /* count of access specs in outer_spec_list */
6036  for (access_spec = merge_list_info->outer_spec_list; access_spec; access_spec = access_spec->next)
6037  {
6038  size += xts_sizeof_access_spec_type (access_spec);
6039  }
6040 
6041  size += OR_INT_SIZE; /* count of access specs in inner_spec_list */
6042  for (access_spec = merge_list_info->inner_spec_list; access_spec; access_spec = access_spec->next)
6043  {
6044  size += xts_sizeof_access_spec_type (access_spec);
6045  }
6046 
6047  return size;
6048 }
6049 
6050 /*
6051  * xts_sizeof_upddel_class_info () -
6052  * return:
6053  * ptr(in) :
6054  */
6055 static int
6057 {
6058  int size = 0;
6059 
6060  size += (OR_INT_SIZE /* num_subclasses */
6061  + PTR_SIZE /* class_oid */
6062  + PTR_SIZE /* class_hfid */
6063  + OR_INT_SIZE /* num_attrs */
6064  + PTR_SIZE /* att_id */
6065  + OR_INT_SIZE /* needs pruning */
6066  + OR_INT_SIZE /* has_uniques */
6067  + PTR_SIZE /* num_lob_attrs */
6068  + PTR_SIZE /* lob_attr_ids */
6069  + OR_INT_SIZE /* num_extra_assign_reev */
6070  + PTR_SIZE); /* mvcc_extra_assign_reev */
6071 
6072  return size;
6073 }
6074 
6075 /*
6076  * xts_sizeof_update_assignment () -
6077  * return:
6078  * ptr(in) :
6079  */
6080 static int
6082 {
6083  int size = 0;
6084 
6085  size += (OR_INT_SIZE /* cls_idx */
6086  + OR_INT_SIZE /* att_idx */
6087  + PTR_SIZE /* constant */
6088  + PTR_SIZE); /* regu_var */
6089 
6090  return size;
6091 }
6092 
6093 static int
6095 {
6096  int size = 0;
6097 
6098  size += (OR_INT_SIZE /* num_assigns */
6099  + PTR_SIZE /* attr_ids */
6100  + PTR_SIZE /* assignments */
6101  + PTR_SIZE /* cons_pred */
6102  + PTR_SIZE); /* attr_info */
6103 
6104  return size;
6105 }
6106 
6107 /*
6108  * xts_sizeof_update_proc () -
6109  * return:
6110  * ptr(in) :
6111  */
6112 static int
6114 {
6115  int size = 0;
6116 
6117  size += (OR_INT_SIZE /* num_classes */
6118  + PTR_SIZE /* classes */
6119  + PTR_SIZE /* cons_pred */
6120  + OR_INT_SIZE /* num_assigns */
6121  + PTR_SIZE /* assignments */
6122  + OR_INT_SIZE /* wait_msecs */
6123  + OR_INT_SIZE /* no_logging */
6124  + OR_INT_SIZE /* num_orderby_keys */
6125  + OR_INT_SIZE /* num_assign_reev_classes */
6126  + OR_INT_SIZE /* num_cond_reev_classes */
6127  + PTR_SIZE); /* mvcc_cond_reev_classes */
6128 
6129  return size;
6130 }
6131 
6132 /*
6133  * xts_sizeof_delete_proc () -
6134  * return:
6135  * ptr(in) :
6136  */
6137 static int
6139 {
6140  int size = 0;
6141 
6142  size += (PTR_SIZE /* classes */
6143  + OR_INT_SIZE /* num_classes */
6144  + OR_INT_SIZE /* wait_msecs */
6145  + OR_INT_SIZE /* no_logging */
6146  + OR_INT_SIZE /* num_cond_reev_classes */
6147  + PTR_SIZE); /* mvcc_cond_reev_classes */
6148 
6149  return size;
6150 }
6151 
6152 /*
6153  * xts_sizeof_insert_proc () -
6154  * return:
6155  * ptr(in) :
6156  */
6157 static int
6159 {
6160  int size = 0;
6161 
6162  size += (OR_OID_SIZE /* class_oid */
6163  + OR_HFID_SIZE /* class_hfid */
6164  + OR_INT_SIZE /* num_vals */
6165  + OR_INT_SIZE /* num_default_expr */
6166  + PTR_SIZE /* array pointer: att_id */
6167  + PTR_SIZE /* constraint predicate: cons_pred */
6168  + PTR_SIZE /* odku */
6169  + OR_INT_SIZE /* has_uniques */
6170  + OR_INT_SIZE /* wait_msecs */
6171  + OR_INT_SIZE /* no_logging */
6172  + OR_INT_SIZE /* do_replace */
6173  + OR_INT_SIZE /* needs pruning */
6174  + OR_INT_SIZE /* num_val_lists */
6175  + PTR_SIZE /* obj_oid */
6176  + (insert_info->num_val_lists * PTR_SIZE)); /* valptr_lists */
6177 
6178  return size;
6179 }
6180 
6181 /*
6182  * xts_sizeof_merge_proc () -
6183  * return:
6184  * ptr(in) :
6185  */
6186 static int
6188 {
6189  int size = 0;
6190 
6191  size += (PTR_SIZE /* update_xasl */
6192  + PTR_SIZE /* insert_xasl */
6193  + OR_INT_SIZE); /* has_delete */
6194 
6195  return size;
6196 }
6197 
6198 /*
6199  * xts_sizeof_cte_proc () -
6200  * return
6201  * ptr(in) :
6202  */
6203 static int
6205 {
6206  int size = 0;
6207 
6208  size += (PTR_SIZE /* non_recursive_part */
6209  + PTR_SIZE /* recursive_part */
6210  + PTR_SIZE); /* list_id */
6211 
6212  return size;
6213 }
6214 
6215 /*
6216  * xts_sizeof_outptr_list () -
6217  * return:
6218  * ptr(in) :
6219  */
6220 static int
6222 {
6223  int size = 0;
6224 
6225  size += (OR_INT_SIZE /* valptr_cnt */
6226  + PTR_SIZE); /* valptrp */
6227 
6228  return size;
6229 }
6230 
6231 /*
6232  * xts_sizeof_pred_expr () -
6233  * return:
6234  * ptr(in) :
6235  */
6236 static int
6237 xts_sizeof_pred_expr (const PRED_EXPR * pred_expr)
6238 {
6239  int size = 0;
6240  int tmp_size = 0;
6241 
6242  size += OR_INT_SIZE; /* type_node */
6243  switch (pred_expr->type)
6244  {
6245  case T_PRED:
6246  tmp_size = xts_sizeof_pred (&pred_expr->pe.m_pred);
6247  if (tmp_size == ER_FAILED)
6248  {
6249  return ER_FAILED;
6250  }
6251  size += tmp_size;
6252  break;
6253 
6254  case T_EVAL_TERM:
6255  tmp_size = xts_sizeof_eval_term (&pred_expr->pe.m_eval_term);
6256  if (tmp_size == ER_FAILED)
6257  {
6258  return ER_FAILED;
6259  }
6260  size += tmp_size;
6261  break;
6262 
6263  case T_NOT_TERM:
6264  size += PTR_SIZE;
6265  break;
6266 
6267  default:
6269  return ER_FAILED;
6270  }
6271 
6272  return size;
6273 }
6274 
6275 /*
6276  * xts_sizeof_selupd_list () -
6277  * return:
6278  * ptr(in) :
6279  */
6280 static int
6282 {
6283  int size = 0;
6284 
6285  size = (OR_OID_SIZE /* class_oid */
6286  + OR_HFID_SIZE /* class_hfid */
6287  + OR_INT_SIZE /* select_list_size */
6288  + PTR_SIZE /* select_list */
6289  + OR_INT_SIZE /* wait_msecs */
6290  + PTR_SIZE); /* next */
6291 
6292  return size;
6293 }
6294 
6295 /*
6296  * xts_sizeof_pred () -
6297  * return:
6298  * ptr(in) :
6299  */
6300 static int
6301 xts_sizeof_pred (const PRED * pred)
6302 {
6303  int size = 0;
6304  PRED_EXPR *rhs;
6305 
6306  size += (PTR_SIZE /* lhs */
6307  + OR_INT_SIZE); /* bool_op */
6308 
6309  rhs = pred->rhs;
6310  size += OR_INT_SIZE; /* rhs-type */
6311 
6312  /* Traverse right-linear chains of AND/OR terms */
6313  while (rhs->type == T_PRED)
6314  {
6315  pred = &rhs->pe.m_pred;
6316 
6317  size += (PTR_SIZE /* lhs */
6318  + OR_INT_SIZE); /* bool_op */
6319 
6320  rhs = pred->rhs;
6321  size += OR_INT_SIZE; /* rhs-type */
6322  }
6323 
6324  size += PTR_SIZE;
6325 
6326  return size;
6327 }
6328 
6329 /*
6330  * xts_sizeof_eval_term () -
6331  * return:
6332  * ptr(in) :
6333  */
6334 static int
6335 xts_sizeof_eval_term (const EVAL_TERM * eval_term)
6336 {
6337  int size = 0;
6338  int tmp_size = 0;
6339 
6340  size += OR_INT_SIZE; /* et_type */
6341  switch (eval_term->et_type)
6342  {
6343  case T_COMP_EVAL_TERM:
6344  tmp_size = xts_sizeof_comp_eval_term (&eval_term->et.et_comp);
6345  if (tmp_size == ER_FAILED)
6346  {
6347  return ER_FAILED;
6348  }
6349  size += tmp_size;
6350  break;
6351 
6352  case T_ALSM_EVAL_TERM:
6353  tmp_size = xts_sizeof_alsm_eval_term (&eval_term->et.et_alsm);
6354  if (tmp_size == ER_FAILED)
6355  {
6356  return ER_FAILED;
6357  }
6358  size += tmp_size;
6359  break;
6360 
6361  case T_LIKE_EVAL_TERM:
6362  tmp_size = xts_sizeof_like_eval_term (&eval_term->et.et_like);
6363  if (tmp_size == ER_FAILED)
6364  {
6365  return ER_FAILED;
6366  }
6367  size += tmp_size;
6368  break;
6369 
6370  case T_RLIKE_EVAL_TERM:
6371  tmp_size = xts_sizeof_rlike_eval_term (&eval_term->et.et_rlike);
6372  if (tmp_size == ER_FAILED)
6373  {
6374  return ER_FAILED;
6375  }
6376  size += tmp_size;
6377  break;
6378 
6379  default:
6381  return ER_FAILED;
6382  }
6383 
6384  return size;
6385 }
6386 
6387 /*
6388  * xts_sizeof_comp_eval_term () -
6389  * return:
6390  * ptr(in) :
6391  */
6392 static int
6394 {
6395  int size = 0;
6396 
6397  size += (PTR_SIZE /* lhs */
6398  + PTR_SIZE /* rhs */
6399  + OR_INT_SIZE /* rel_op */
6400  + OR_INT_SIZE); /* type */
6401 
6402  return size;
6403 }
6404 
6405 /*
6406  * xts_sizeof_alsm_eval_term () -
6407  * return:
6408  * ptr(in) :
6409  */
6410 static int
6412 {
6413  int size = 0;
6414 
6415  size += (PTR_SIZE /* elem */
6416  + PTR_SIZE /* elemset */
6417  + OR_INT_SIZE /* eq_flag */
6418  + OR_INT_SIZE /* rel_op */
6419  + OR_INT_SIZE); /* item_type */
6420 
6421  return size;
6422 }
6423 
6424 /*
6425  * xts_sizeof_like_eval_term () -
6426  * return:
6427  * ptr(in) :
6428  */
6429 static int
6431 {
6432  int size = 0;
6433 
6434  size += (PTR_SIZE /* src */
6435  + PTR_SIZE /* pattern */
6436  + PTR_SIZE); /* esc_char */
6437 
6438  return size;
6439 }
6440 
6441 /*
6442  * xts_sizeof_rlike_eval_term () -
6443  * return: size of rlike eval term
6444  * rlike_eval_term(in):
6445  */
6446 static int
6448 {
6449  int size = 0;
6450 
6451  size += (PTR_SIZE /* src */
6452  + PTR_SIZE /* pattern */
6453  + PTR_SIZE); /* case_sensitive */
6454 
6455  return size;
6456 }
6457 
6458 /*
6459  * xts_sizeof_access_spec_type () -
6460  * return:
6461  * ptr(in) :
6462  */
6463 static int
6465 {
6466  int size = 0;
6467  int tmp_size = 0;
6468 
6469  size += (OR_INT_SIZE /* type */
6470  + OR_INT_SIZE /* access */
6471  + OR_INT_SIZE /* flags */
6472  + PTR_SIZE /* index_ptr */
6473  + PTR_SIZE /* where_key */
6474  + PTR_SIZE /* where_pred */
6475  + PTR_SIZE); /* where_range */
6476 
6477  switch (access_spec->type)
6478  {
6479  case TARGET_CLASS:
6480  case TARGET_CLASS_ATTR:
6481  tmp_size = xts_sizeof_cls_spec_type (&ACCESS_SPEC_CLS_SPEC (access_spec));
6482  if (tmp_size == ER_FAILED)
6483  {
6484  return ER_FAILED;
6485  }
6486  size += tmp_size;
6487  break;
6488 
6489  case TARGET_LIST:
6490  tmp_size = xts_sizeof_list_spec_type (&ACCESS_SPEC_LIST_SPEC (access_spec));
6491  if (tmp_size == ER_FAILED)
6492  {
6493  return ER_FAILED;
6494  }
6495  size += tmp_size;
6496  break;
6497 
6498  case TARGET_SHOWSTMT:
6499  tmp_size = xts_sizeof_showstmt_spec_type (&ACCESS_SPEC_SHOWSTMT_SPEC (access_spec));
6500  if (tmp_size == ER_FAILED)
6501  {
6502  return ER_FAILED;
6503  }
6504  size += tmp_size;
6505  break;
6506 
6507  case TARGET_REGUVAL_LIST:
6508  /* currently do nothing */
6509  break;
6510 
6511  case TARGET_SET:
6512  tmp_size = xts_sizeof_set_spec_type (&ACCESS_SPEC_SET_SPEC (access_spec));
6513  if (tmp_size == ER_FAILED)
6514  {
6515  return ER_FAILED;
6516  }
6517  size += tmp_size;
6518  break;
6519 
6520  case TARGET_METHOD:
6521  tmp_size = xts_sizeof_method_spec_type (&ACCESS_SPEC_METHOD_SPEC (access_spec));
6522  if (tmp_size == ER_FAILED)
6523  {
6524  return ER_FAILED;
6525  }
6526  size += tmp_size;
6527  break;
6528 
6529  case TARGET_JSON_TABLE:
6530  tmp_size = xts_sizeof (ACCESS_SPEC_JSON_TABLE_SPEC (access_spec));
6531  if (tmp_size == ER_FAILED)
6532  {
6533  return ER_FAILED;
6534  }
6535  size += tmp_size;
6536  break;
6537 
6538  default:
6540  return ER_FAILED;
6541  }
6542 
6543  size += (0 /* s_id (not sent to server) */
6544  + OR_INT_SIZE /* grouped_scan */
6545  + OR_INT_SIZE /* fixed_scan */
6546  + OR_INT_SIZE /* qualified_scan */
6547  + OR_INT_SIZE /* single_fetch */
6548  + OR_INT_SIZE /* needs pruning */
6549  + PTR_SIZE); /* s_dbval */
6550 
6551  return size;
6552 }
6553 
6554 /*
6555  * xts_sizeof_indx_info () -
6556  * return:
6557  * ptr(in) :
6558  */
6559 static int
6561 {
6562  int size = 0;
6563  int tmp_size = 0;
6564 
6565  size = OR_BTID_ALIGNED_SIZE; /* btid */
6566 
6567  size += (OR_INT_SIZE /* coverage */
6568  + OR_INT_SIZE); /* range_type */
6569 
6570  tmp_size = xts_sizeof_key_info (&indx_info->key_info);
6571  if (tmp_size == ER_FAILED)
6572  {
6573  return ER_FAILED;
6574  }
6575  size += tmp_size;
6576 
6577  size += (OR_INT_SIZE /* orderby_desc */
6578  + OR_INT_SIZE /* groupby_desc */
6579  + OR_INT_SIZE /* use_desc_index */
6580  + OR_INT_SIZE /* orderby_skip */
6581  + OR_INT_SIZE /* groupby_skip */
6582  + OR_INT_SIZE /* use_iss boolean (int) */
6583  + OR_INT_SIZE /* ils_prefix_len (int) */
6584  + OR_INT_SIZE /* func_idx_col_id (int) */
6585  + OR_INT_SIZE /* iss_range's range */
6586  + PTR_SIZE); /* iss_range's key1 */
6587 
6588  return size;
6589 }
6590 
6591 /*
6592  * xts_sizeof_key_info () -
6593  * return:
6594  * ptr(in) :
6595  */
6596 static int
6598 {
6599  int size = 0;
6600 
6601  size += (OR_INT_SIZE /* key_cnt */
6602  + PTR_SIZE /* key_ranges */
6603  + OR_INT_SIZE /* is_constant */
6604  + OR_INT_SIZE /* key_limit_reset */
6605  + OR_INT_SIZE /* is_user_given_keylimit */
6606  + PTR_SIZE /* key_limit_l */
6607  + PTR_SIZE); /* key_limit_u */
6608 
6609  return size;
6610 }
6611 
6612 /*
6613  * xts_sizeof_cls_spec_type () -
6614  * return:
6615  * ptr(in) :
6616  */
6617 static int
6619 {
6620  int size = 0;
6621 
6622  size += (PTR_SIZE /* cls_regu_list_key */
6623  + PTR_SIZE /* cls_regu_list_pred */
6624  + PTR_SIZE /* cls_regu_list_rest */
6625  + PTR_SIZE /* cls_regu_list_range */
6626  + PTR_SIZE /* cls_output_val_list */
6627  + PTR_SIZE /* regu_val_list */
6628  + OR_HFID_SIZE /* hfid */
6629  + OR_OID_SIZE /* cls_oid */
6630  + OR_INT_SIZE /* num_attrs_key */
6631  + PTR_SIZE /* attrids_key */
6632  + PTR_SIZE /* cache_key */
6633  + OR_INT_SIZE /* num_attrs_pred */
6634  + PTR_SIZE /* attrids_pred */
6635  + PTR_SIZE /* cache_pred */
6636  + OR_INT_SIZE /* num_attrs_rest */
6637  + PTR_SIZE /* attrids_rest */
6638  + PTR_SIZE /* cache_rest */
6639  + OR_INT_SIZE /* schema_type */
6640  + OR_INT_SIZE /* num_attrs_reserved */
6641  + PTR_SIZE /* cache_reserved */
6642  + PTR_SIZE /* cls_regu_list_reserved */
6643  + PTR_SIZE /* atrtrids_range */
6644  + PTR_SIZE /* cache_range */
6645  + OR_INT_SIZE); /* num_attrs_range */
6646 
6647  return size;
6648 }
6649 
6650 /*
6651  * xts_sizeof_list_spec_type () -
6652  * return:
6653  * ptr(in) :
6654  */
6655 static int
6657 {
6658  int size = 0;
6659 
6660  size += (PTR_SIZE /* list_regu_list_pred */
6661  + PTR_SIZE /* list_regu_list_rest */
6662  + PTR_SIZE /* list_regu_list_build */
6663  + PTR_SIZE /* list_regu_list_probe */
6664  + OR_INT_SIZE /* hash_list_scan_yn */
6665  + PTR_SIZE); /* xasl_node */
6666 
6667  return size;
6668 }
6669 
6670 /*
6671  * xts_sizeof_showstmt_spec_type () -
6672  * return:
6673  * ptr(in) :
6674  */
6675 static int
6677 {
6678  int size = 0;
6679 
6680  size += (OR_INT_SIZE /* show_type */
6681  + PTR_SIZE); /* arg_list */
6682 
6683  return size;
6684 }
6685 
6686 /*
6687  * xts_sizeof_set_spec_type () -
6688  * return:
6689  * ptr(in) :
6690  */
6691 static int
6693 {
6694  int size = 0;
6695 
6696  size += (PTR_SIZE /* set_regu_list */
6697  + PTR_SIZE); /* set_ptr */
6698 
6699  return size;
6700 }
6701 
6702 /*
6703  * xts_sizeof_method_spec_type () -
6704  * return:
6705  * ptr(in) :
6706  */
6707 static int
6709 {
6710  int size = 0;
6711 
6712  size += (PTR_SIZE /* method_regu_list */
6713  + PTR_SIZE /* xasl_node */
6714  + PTR_SIZE); /* method_sig_list */
6715 
6716  return size;
6717 }
6718 
6719 static int
6721 {
6722  int size = OR_INT_SIZE; // json_table_column_behavior_type
6723 
6724  if (behavior->m_behavior == JSON_TABLE_DEFAULT_VALUE)
6725  {
6726  size += OR_VALUE_ALIGNED_SIZE (behavior->m_default_value);
6727  }
6728 
6729  return size;
6730 }
6731 
6732 static int
6734 {
6735  int size = 0;
6736 
6737  size += OR_INT_SIZE; /* m_function */
6738  size += PTR_SIZE; /* m_output_value_pointer */
6739 
6740  if (json_table_column.m_function == JSON_TABLE_ORDINALITY)
6741  {
6742  // that's all
6743  return size;
6744  }
6745 
6746  size += or_packed_domain_size (json_table_column.m_domain, 0); /* m_domain */
6747  size += PTR_SIZE; /* m_path */
6748  size += PTR_SIZE; /* m_column_name */
6749 
6750  if (json_table_column.m_function == JSON_TABLE_EXISTS)
6751  {
6752  return size;
6753  }
6754 
6755  size += xts_sizeof_json_table_column_behavior (&json_table_column.m_on_error);
6756  size += xts_sizeof_json_table_column_behavior (&json_table_column.m_on_empty);
6757 
6758  return size;
6759 }
6760 
6761 static int
6763 {
6764  int size = 0;
6765 
6766  size += PTR_SIZE; // m_path
6767 
6768  size += OR_INT_SIZE; // m_output_columns_size
6769  for (size_t i = 0; i < jtn.m_output_columns_size; ++i)
6770  {
6771  size += xts_sizeof (jtn.m_output_columns[i]); // m_output_columns
6772  }
6773 
6774  size += OR_INT_SIZE; // m_nested_nodes_size
6775  for (size_t i = 0; i < jtn.m_nested_nodes_size; ++i)
6776  {
6777  size += xts_sizeof (jtn.m_nested_nodes[i]); // m_nested_nodes
6778  }
6779 
6780  size += OR_INT_SIZE; // m_id
6781 
6782  size += OR_INT_SIZE; // expand type
6783 
6784  return size;
6785 }
6786 
6787 /*
6788  * xts_sizeof_json_table_spec_type () -
6789  * return:
6790  * ptr(in) :
6791  */
6792 static int
6793 xts_sizeof (const json_table_spec_node & json_table_spec)
6794 {
6795  int size = 0;
6796 
6797  // reguvar needs to be set
6798  size += (PTR_SIZE /* regu_var */
6799  + OR_INT_SIZE /* json_table_node number */
6800  ); /* json_table_node */
6801 
6802  size += xts_sizeof (*json_table_spec.m_root_node);
6803 
6804  return size;
6805 }
6806 
6807 /*
6808  * xts_sizeof_list_id () -
6809  * return:xts_process_db_value
6810  * ptr(in) :
6811  */
6812 static int
6814 {
6815  int size = 0;
6816 
6817  size = or_listid_length ((void *) list_id);
6818 
6819  return size;
6820 }
6821 
6822 /*
6823  * xts_sizeof_val_list () -
6824  * return:
6825  * ptr(in) :
6826  */
6827 static int
6828 xts_sizeof_val_list (const VAL_LIST * val_list)
6829 {
6830  int size = 0;
6832 
6833  size += OR_INT_SIZE; /* val_cnt */
6834 
6835  for (p = val_list->valp; p; p = p->next)
6836  {
6837  size += PTR_SIZE; /* p->val */
6838  }
6839 
6840  return size;
6841 }
6842 
6843 /*
6844  * xts_sizeof_regu_variable () -
6845  * return:
6846  * ptr(in) :
6847  */
6848 static int
6850 {
6851  int size = 0;
6852  int tmp_size = 0;
6853 
6854  if (regu_var == NULL)
6855  {
6856  return 0;
6857  }
6858 
6859  /* we prepend the domain before we pack the regu_variable */
6860  size += (or_packed_domain_size (regu_var->domain, 0) /* domain */
6861  + OR_INT_SIZE /* type */
6862  + OR_INT_SIZE /* flags */
6863  + PTR_SIZE /* vfetch_to */
6864  + PTR_SIZE); /* REGU_VARIABLE_XASL */
6865 
6866  tmp_size = xts_get_regu_variable_value_size (regu_var);
6867  if (tmp_size == ER_FAILED)
6868  {
6869  return ER_FAILED;
6870  }
6871  size += tmp_size;
6872 
6873  return size;
6874 }
6875 
6876 /*
6877  * xts_get_regu_variable_value_size () -
6878  * return:
6879  * regu_var(in) :
6880  */
6881 static int
6883 {
6884  int size = ER_FAILED;
6885 
6886  assert (regu_var);
6887 
6888  switch (regu_var->type)
6889  {
6890  case TYPE_REGU_VAR_LIST:
6891  size = xts_sizeof_regu_variable_list (regu_var->value.regu_var_list);
6892  break;
6893 
6894  case TYPE_REGUVAL_LIST:
6895  size = xts_sizeof_regu_value_list (regu_var->value.reguval_list);
6896  break;
6897 
6898  case TYPE_DBVAL:
6899  size = OR_VALUE_ALIGNED_SIZE ((DB_VALUE *) (&regu_var->value.dbval));
6900  break;
6901 
6902  case TYPE_CONSTANT:
6903  case TYPE_ORDERBY_NUM:
6904  size = PTR_SIZE; /* dbvalptr */
6905  break;
6906 
6907  case TYPE_INARITH:
6908  case TYPE_OUTARITH:
6909  size = PTR_SIZE; /* arithptr */
6910  break;
6911 
6912  case TYPE_FUNC:
6913  size = PTR_SIZE; /* funcp */
6914  break;
6915 
6916  case TYPE_ATTR_ID:
6917  case TYPE_SHARED_ATTR_ID:
6918  case TYPE_CLASS_ATTR_ID:
6919  size = xts_sizeof_attr_descr (&regu_var->value.attr_descr);
6920  break;
6921 
6922  case TYPE_LIST_ID:
6923  size = PTR_SIZE; /* srlist_id */
6924  break;
6925 
6926  case TYPE_POSITION:
6927  size = xts_sizeof_pos_descr (&regu_var->value.pos_descr);
6928  break;
6929 
6930  case TYPE_POS_VALUE:
6931  size = OR_INT_SIZE; /* val_pos */
6932  break;
6933 
6934  case TYPE_OID:
6935  case TYPE_CLASSOID:
6936  size = 0;
6937  break;
6938  default:
6940  }
6941 
6942  return size;
6943 }
6944 
6945 /*
6946  * xts_sizeof_attr_descr () -
6947  * return:
6948  * ptr(in) :
6949  */
6950 static int
6951 xts_sizeof_attr_descr (const ATTR_DESCR * attr_descr)
6952 {
6953  int size = 0;
6954 
6955  size += (OR_INT_SIZE /* id */
6956  + OR_INT_SIZE /* type */
6957  + PTR_SIZE); /* cache_attrinfo */
6958 
6959  return size;
6960 }
6961 
6962 /*
6963  * xts_sizeof_pos_descr () -
6964  * return:
6965  * ptr(in) :
6966  */
6967 static int
6969 {
6970  int size = 0;
6971 
6972  size += (OR_INT_SIZE /* pos_no */
6973  + or_packed_domain_size (position_descr->dom, 0)); /* type */
6974 
6975  return size;
6976 }
6977 
6978 /*
6979  * xts_sizeof_db_value () -
6980  * return:
6981  * ptr(in) :
6982  */
6983 static int
6985 {
6986  return or_db_value_size ((DB_VALUE *) value);
6987 }
6988 
6989 /*
6990  * xts_sizeof_arith_type () -
6991  * return:
6992  * ptr(in) :
6993  */
6994 static int
6996 {
6997  int size = 0;
6998  int case_pred_size = 0;
6999 
7000  case_pred_size = ((arith->opcode == T_CASE || arith->opcode == T_DECODE || arith->opcode == T_PREDICATE
7001  || arith->opcode == T_IF) ? PTR_SIZE : 0);
7002 
7003  size += (PTR_SIZE /* next */
7004  + PTR_SIZE /* value */
7005  + OR_INT_SIZE /* operator */
7006  + PTR_SIZE /* leftptr */
7007  + PTR_SIZE /* rightptr */
7008  + PTR_SIZE /* thirdptr */
7009  + OR_INT_SIZE /* misc_operand */
7010  + case_pred_size /* case pred */
7011  + or_packed_domain_size (arith->domain, 0));
7012 
7013  return size;
7014 }
7015 
7016 /*
7017  * xts_sizeof_aggregate_type () -
7018  * return:
7019  * ptr(in) :
7020  */
7021 static int
7023 {
7024  int size = 0;
7025  int tmp_size = 0;
7026 
7027  size += (or_packed_domain_size (aggregate->domain, 0) /* domain */
7028  + PTR_SIZE /* next */
7029  + PTR_SIZE /* value */
7030  + PTR_SIZE /* value2 */
7031  + OR_INT_SIZE /* curr_cnt */
7032  + OR_INT_SIZE /* function */
7033  + OR_INT_SIZE /* option */
7034  + OR_INT_SIZE); /* opr_dbtype */
7035 
7036  tmp_size = xts_sizeof_regu_variable_list (aggregate->operands);
7037  if (tmp_size == ER_FAILED)
7038  {
7039  return ER_FAILED;
7040  }
7041  size += tmp_size;
7042 
7043  size += (PTR_SIZE /* list_id */
7045 
7046  size += PTR_SIZE; /* sort_info */
7047 
7048  /* percentile value */
7049  if (aggregate->function == PT_PERCENTILE_CONT || aggregate->function == PT_PERCENTILE_DISC)
7050  {
7051  /* percentile_reguvar */
7052  size += OR_INT_SIZE;
7053  if (aggregate->info.percentile.percentile_reguvar != NULL)
7054  {
7056  if (tmp_size == ER_FAILED)
7057  {
7058  return ER_FAILED;
7059  }
7060 
7061  size += tmp_size;
7062  }
7063  }
7064 
7065  return size;
7066 }
7067 
7068 /*
7069  * xts_sizeof_function_type () -
7070  * return:
7071  * ptr(in) :
7072  */
7073 static int
7075 {
7076  int size = 0;
7077 
7078  size += (PTR_SIZE /* value */
7079  + OR_INT_SIZE /* ftype */
7080  + PTR_SIZE); /* operand */
7081 
7082  return size;
7083 }
7084 
7085 /*
7086  * xts_sizeof_analytic_type () -
7087  * return:
7088  * ptr(in) :
7089  */
7090 static int
7092 {
7093  int size = 0;
7094  int tmp_size = 0;
7095 
7096  size += (or_packed_domain_size (analytic->domain, 0) + PTR_SIZE /* next */
7097  + PTR_SIZE /* value */
7098  + PTR_SIZE /* value2 */
7099  + PTR_SIZE /* valptr_value */
7100  + PTR_SIZE /* list_id */
7101  + OR_INT_SIZE /* function */
7102  + OR_INT_SIZE /* offset_idx */
7103  + OR_INT_SIZE /* default_idx */
7104  + OR_INT_SIZE /* option */
7105  + OR_INT_SIZE /* opr_dbtype */
7106  + OR_INT_SIZE /* sort_prefix_size */
7107  + OR_INT_SIZE /* sort_list_size */
7108  + OR_INT_SIZE /* flag */
7109  + OR_INT_SIZE /* from_last */
7110  + OR_INT_SIZE /* ignore_nulls */
7111  + OR_INT_SIZE); /* is_const_opr */
7112 
7113  tmp_size = xts_sizeof_regu_variable (&analytic->operand);
7114  if (tmp_size == ER_FAILED)
7115  {
7116  return ER_FAILED;
7117  }
7118  size += tmp_size;
7119 
7120  /* percentile value */
7121  if (analytic->function == PT_PERCENTILE_CONT || analytic->function == PT_PERCENTILE_DISC)
7122  {
7123  size += OR_INT_SIZE;
7124  if (analytic->info.percentile.percentile_reguvar != NULL)
7125  {
7127  if (tmp_size == ER_FAILED)
7128  {
7129  return ER_FAILED;
7130  }
7131 
7132  size += tmp_size;
7133  }
7134  }
7135 
7136  return size;
7137 }
7138 
7139 /*
7140  * xts_sizeof_analytic_eval_type () -
7141  * return:
7142  * ptr(in) :
7143  */
7144 static int
7146 {
7147  int size = 0;
7148 
7149  size = (PTR_SIZE /* next */
7150  + PTR_SIZE /* head */
7151  + PTR_SIZE); /* sort_list */
7152 
7153  return size;
7154 }
7155 
7156 /*
7157  * xts_sizeof_srlist_id () -
7158  * return:
7159  * ptr(in) :
7160  */
7161 static int
7163 {
7164  int size = 0;
7165 
7166  size += (OR_INT_SIZE /* sorted */
7167  + PTR_SIZE); /* list_id */
7168 
7169  return size;
7170 }
7171 
7172 /*
7173  * xts_sizeof_sort_list () -
7174  * return:
7175  * ptr(in) :
7176  */
7177 static int
7179 {
7180  int size = 0;
7181  int tmp_size = 0;
7182 
7183  size += PTR_SIZE; /* next */
7184 
7185  tmp_size = xts_sizeof_pos_descr (&sort_lis->pos_descr);
7186  if (tmp_size == ER_FAILED)
7187  {
7188  return ER_FAILED;
7189  }
7190  size += tmp_size;
7191 
7192  size += (0 /* other (not sent to server) */
7193  + OR_INT_SIZE /* s_order */
7194  + OR_INT_SIZE); /* s_nulls */
7195 
7196  return size;
7197 }
7198 
7199 /*
7200  * xts_sizeof_method_sig_list () -
7201  * return:
7202  * ptr(in) :
7203  */
7204 static int
7206 {
7207  int size = 0;
7208 
7209  size += (OR_INT_SIZE /* num_methods */
7210  + PTR_SIZE); /* method_sig */
7211 
7212  return size;
7213 }
7214 
7215 static int
7216 xts_sizeof_method_sig (const METHOD_SIG * method_sig)
7217 {
7218  int size = 0;
7219 
7220  size += (PTR_SIZE /* method_name */
7221  + PTR_SIZE /* class_name */
7222  + OR_INT_SIZE /* method_type */
7223  + OR_INT_SIZE /* num_method_args */
7224  + (OR_INT_SIZE * (method_sig->num_method_args + 1)) /* method_arg_pos */
7225  + PTR_SIZE); /* next */
7226 
7227  return size;
7228 }
7229 
7230 /*
7231  * xts_sizeof_connectby_proc () -
7232  * return:
7233  * ptr(in) :
7234  */
7235 static int
7237 {
7238  int size = 0;
7239 
7240  size += (PTR_SIZE /* start_with_pred */
7241  + PTR_SIZE /* after_connect_by_pred */
7242  + PTR_SIZE /* input_list_id */
7243  + PTR_SIZE /* start_with_list_id */
7244  + PTR_SIZE /* regu_list_pred */
7245  + PTR_SIZE /* regu_list_rest */
7246  + PTR_SIZE /* prior_val_list */
7247  + PTR_SIZE /* prior_outptr_list */
7248  + PTR_SIZE /* prior_regu_list_pred */
7249  + PTR_SIZE /* prior_regu_list_rest */
7250  + PTR_SIZE /* after_cb_regu_list_pred */
7251  + PTR_SIZE /* after_cb_regu_list_rest */
7252  + OR_INT_SIZE); /* single_table_opt */
7253 
7254  return size;
7255 }
7256 
7257 /*
7258  * xts_sizeof_regu_value_list () -
7259  * return:
7260  * regu_value_list(in) :
7261  */
7262 static int
7264 {
7265  int size, tmp_size;
7267 
7268  assert (regu_value_list);
7269 
7270  size = tmp_size = 0;
7271 
7272  size += OR_INT_SIZE;
7273  for (regu_value_item = regu_value_list->regu_list; regu_value_item; regu_value_item = regu_value_item->next)
7274  {
7275  tmp_size = xts_get_regu_variable_value_size (regu_value_item->value);
7276 
7277  if (tmp_size == ER_FAILED)
7278  {
7279  return ER_FAILED;
7280  }
7281 
7282  size += OR_INT_SIZE + tmp_size; /* OR_INT_SIZE for type */
7283  }
7284 
7285  return size;
7286 }
7287 
7288 /*
7289  * xts_sizeof_regu_variable_list () -
7290  * return: size or ER_FAILED
7291  * regu_value_list(in) :
7292  */
7293 static int
7295 {
7296  int size = 0, tmp_size = 0;
7297  REGU_VARIABLE_LIST regu_var = regu_var_list;
7298 
7299  assert (regu_var_list != NULL);
7300 
7301  size += OR_INT_SIZE;
7302  while (regu_var)
7303  {
7304  tmp_size = xts_get_regu_variable_value_size (&regu_var->value);
7305  regu_var = regu_var->next;
7306 
7307  if (tmp_size == ER_FAILED)
7308  {
7309  return ER_FAILED;
7310  }
7311 
7312  size += OR_INT_SIZE + tmp_size; /* OR_INT_SIZE for type */
7313  }
7314 
7315  return size;
7316 }
7317 
7318 /*
7319  * xts_mark_ptr_visited () -
7320  * return: if successful, return NO_ERROR, otherwise
7321  * ER_FAILED and error code is set to xasl_errcode
7322  * ptr(in) : pointer constant to be marked visited
7323  * offset(in) : where the node pointed by 'ptr' is stored
7324  *
7325  * Note: mark the given pointer constant as visited to avoid
7326  * duplicated stored of a node which is pointed by more than one node
7327  */
7328 static int
7329 xts_mark_ptr_visited (const void *ptr, int offset)
7330 {
7331  int new_lwm;
7332  int block_no;
7333 
7334  block_no = xasl_stream_get_ptr_block (ptr);
7335 
7336  new_lwm = xts_Ptr_lwm[block_no];
7337 
7338  if (xts_Ptr_max[block_no] == 0)
7339  {
7340  xts_Ptr_max[block_no] = START_PTR_PER_BLOCK;
7341  xts_Ptr_blocks[block_no] = (XTS_VISITED_PTR *) malloc (sizeof (XTS_VISITED_PTR) * xts_Ptr_max[block_no]);
7342  }
7343  else if (xts_Ptr_max[block_no] <= new_lwm)
7344  {
7345  xts_Ptr_max[block_no] *= 2;
7346  xts_Ptr_blocks[block_no] =
7347  (XTS_VISITED_PTR *) realloc (xts_Ptr_blocks[block_no], sizeof (XTS_VISITED_PTR) * xts_Ptr_max[block_no]);
7348  }
7349 
7350  if (xts_Ptr_blocks[block_no] == (XTS_VISITED_PTR *) NULL)
7351  {
7353  return ER_FAILED;
7354  }
7355 
7356  xts_Ptr_blocks[block_no][new_lwm].ptr = ptr;
7357  xts_Ptr_blocks[block_no][new_lwm].offset = offset;
7358 
7359  xts_Ptr_lwm[block_no]++;
7360 
7361  return NO_ERROR;
7362 }
7363 
7364 /*
7365  * xts_get_offset_visited_ptr () -
7366  * return: if the ptr is already visited, the offset of
7367  * position where the node pointed by 'ptr' is stored,
7368  * otherwise, ER_FAILED (xasl_errcode is NOT set)
7369  * ptr(in) : pointer constant to be checked if visited or not
7370  *
7371  * Note: check if the node pointed by `ptr` is already stored or
7372  * not to avoid multiple store of the same node
7373  */
7374 static int
7376 {
7377  int block_no;
7378  int element_no;
7379 
7380  block_no = xasl_stream_get_ptr_block (ptr);
7381 
7382  if (xts_Ptr_lwm[block_no] <= 0)
7383  {
7384  return ER_FAILED;
7385  }
7386 
7387  for (element_no = 0; element_no < xts_Ptr_lwm[block_no]; element_no++)
7388  {
7389  if (ptr == xts_Ptr_blocks[block_no][element_no].ptr)
7390  {
7391  return xts_Ptr_blocks[block_no][element_no].offset;
7392  }
7393  }
7394 
7395  return ER_FAILED;
7396 }
7397 
7398 /*
7399  * xts_free_visited_ptrs () -
7400  * return:
7401  *
7402  * Note: free memory allocated to manage visited ptr constants
7403  */
7404 static void
7406 {
7407  size_t i;
7408 
7409  for (i = 0; i < MAX_PTR_BLOCKS; i++)
7410  {
7411  xts_Ptr_lwm[i] = 0;
7412  }
7413 }
7414 
7415 /*
7416  * xts_reserve_location_in_stream () -
7417  * return: if successful, return the offset of position
7418  * where the given item is to be stored, otherwise ER_FAILED
7419  * and error code is set to xasl_errcode
7420  * size(in) : # of bytes of the node
7421  *
7422  * Note: reserve size bytes in the stream
7423  */
7424 static int
7426 {
7427  int needed;
7428  int grow;
7429  int org_size = size;
7430 
7431  size = xasl_stream_make_align (size);
7432  needed = size - (xts_Stream_size - xts_Free_offset_in_stream);
7433 
7434  if (needed >= 0)
7435  {
7436  /* expansion is needed */
7437  grow = needed;
7438 
7439  if (grow < (int) STREAM_EXPANSION_UNIT)
7440  {
7441  grow = STREAM_EXPANSION_UNIT;
7442  }
7443  if (grow < (xts_Stream_size / 2))
7444  {
7445  grow = xts_Stream_size / 2;
7446  }
7447 
7448  xts_Stream_size += grow;
7449 
7450  if (xts_Stream_buffer == NULL)
7451  {
7452  xts_Stream_buffer = (char *) malloc (xts_Stream_size);
7453  }
7454  else
7455  {
7456  xts_Stream_buffer = (char *) realloc (xts_Stream_buffer, xts_Stream_size);
7457  }
7458 
7459  if (xts_Stream_buffer == NULL)
7460  {
7462  return ER_FAILED;
7463  }
7464  }
7465 
7466 #if !defined(NDEBUG)
7467  /* suppress valgrind UMW error */
7468  if (size > org_size)
7469  {
7470  memset (xts_Stream_buffer + xts_Free_offset_in_stream + org_size, 0, size - org_size);
7471  }
7472 #endif
7473 
7474  xts_Free_offset_in_stream += size;
7476 
7477  return (xts_Free_offset_in_stream - size);
7478 }
7479 
7480 
7481 /*
7482  * xts_process_regu_variable_list () -
7483  * return:
7484  * ptr(in):
7485  * regu_value_list(in):
7486  */
7487 static char *
7489 {
7490  int offset = 0;
7491 
7492  assert (regu_var_list != NULL);
7493 
7494  /* save regu variable list */
7495  offset = xts_save_regu_variable_list (regu_var_list);
7496  if (offset == ER_FAILED)
7497  {
7498  return NULL;
7499  }
7500  ptr = or_pack_int (ptr, offset);
7501 
7502  return ptr;
7503 }
7504 
7505 // *INDENT-OFF*
7506 //
7507 // xts_save () - template function to pack structure into XASL stream buffer and save its offset
7508 //
7509 // template T - type having an overload of xts_sizeof and xts_process functions
7510 //
7511 // return : offset
7512 // t (in) :
7513 //
7514 template <typename T>
7515 int static
7516 xts_save (const T &t)
7517 {
7518  int packed_length;
7519  char *ptr;
7520 
7522  if (offset != ER_FAILED)
7523  {
7524  return offset;
7525  }
7526 
7527  packed_length = xts_reserve_location_in_stream (xts_sizeof (t));
7528 
7529  offset = xts_reserve_location_in_stream (packed_length);
7530  if (offset == ER_FAILED || xts_mark_ptr_visited (&t, offset) == ER_FAILED)
7531  {
7532  return ER_FAILED;
7533  }
7534  ptr = &xts_Stream_buffer[offset];
7535  ptr = xts_process (ptr, t);
7536 
7537  return offset;
7538 }
7539 
7540 template <typename T>
7541 static void
7542 xts_debug_check (const T &t, char *pack_start, const char *pack_end)
7543 {
7544 #if !defined (NDEBUG)
7545 
7546  // check for common mistakes:
7547  //
7548  // 1. size underestimation:
7549  // buffer overflow may occur
7550  //
7551  // 2. pack_end does not match unpack_end
7552  // if unpack_end is not same as pack_end, building next structure will start at the wrong offset
7553  //
7554  // 3. data consistency
7555  // check original data is same as resulted data after pack/unpack
7556  //
7557 
7559 
7560  // check sizeof is correct
7561  std::size_t buf_size = pack_end - pack_start;
7562  std::size_t estimate_size = xts_sizeof (t);
7563  assert (buf_size <= estimate_size); // estimation should be accurate or pessimistic
7564 
7565  // build object from packed data
7566  T unpack_t;
7567  char * unpack_end = stx_build (NULL, pack_start, unpack_t);
7568  if (unpack_end != pack_end)
7569  {
7570  // this leads to build corruption
7571  assert (false);
7572  }
7573 
7574  if (!xasl_stream_compare (t, unpack_t))
7575  {
7576  // data is not consistent
7577  assert (false);
7578  }
7579 
7580  xts_debug_clear (unpack_t);
7581 
7583  db_private_free_and_init (NULL, unpack_info);
7585 #endif // DEBUG
7586 }
7587 
7588 template <typename T>
7589 static void
7591 {
7592  t.clear_xasl ();
7593 }
7594 
7595 // *INDENT-ON*
QPROC_SINGLE_FETCH single_fetch
Definition: query_list.h:339
pred_expr * lhs
regu_variable_node * key1
Definition: access_spec.hpp:67
int * mvcc_extra_assign_reev
Definition: xasl.h:243
static char * xts_save_update_assignment(char *ptr, const UPDATE_ASSIGNMENT *assign)
OUTPTR_LIST * outptr_list
Definition: xasl.h:968
int stx_init_xasl_unpack_info(THREAD_ENTRY *thread_p, char *xasl_stream, int xasl_stream_size)
Definition: xasl_stream.cpp:72
REGU_VARIABLE_LIST prior_regu_list_pred
Definition: xasl.h:427
int num_extra_assign_reev
Definition: xasl.h:242
SORT_LIST * orderby_list
Definition: xasl.h:957
#define OR_BTID_ALIGNED_SIZE
REGU_VALUE_ITEM * regu_list
Definition: regu_var.hpp:105
static int xts_sizeof_connectby_proc(const CONNECTBY_PROC_NODE *ptr)
static int xts_sizeof_analytic_eval_type(const ANALYTIC_EVAL_TYPE *ptr)
char * or_pack_btid(char *buf, const BTID *btid)
static char * xts_pack_regu_variable_value(char *ptr, const REGU_VARIABLE *regu_var)
static int xts_sizeof_method_spec_type(const METHOD_SPEC_TYPE *ptr)
#define NO_ERROR
Definition: error_code.h:46
aggregate_specific_function_info info
static int xts_sizeof_outptr_list(const OUTPTR_LIST *ptr)
PRED_EXPR * set_pred
Definition: xasl.h:298
static char * xts_process_method_spec_type(char *ptr, const METHOD_SPEC_TYPE *method_spec)
static int xts_save_db_value_array(DB_VALUE **ptr, int size)
static int xts_sizeof_alsm_eval_term(const ALSM_EVAL_TERM *ptr)
VAL_LIST * prior_val_list
Definition: xasl.h:425
HEAP_CACHE_ATTRINFO * cache_pred
Definition: xasl.h:733
XASL_NODE * fptr_list
Definition: xasl.h:984
key_range * key_ranges
Definition: access_spec.hpp:75
static int xts_sizeof_odku_info(const ODKU_INFO *odku_info)
DB_VALUE * save_instnum_val
Definition: xasl.h:981
ACCESS_SPEC_TYPE * merge_spec
Definition: xasl.h:971
static char * xts_process_update_proc(char *ptr, const UPDATE_PROC_NODE *update_info)
static int xts_sizeof_merge_proc(const MERGE_PROC_NODE *ptr)
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
static char * xts_process_insert_proc(char *ptr, const INSERT_PROC_NODE *insert_proc)
REGU_VARIABLE * rightptr
Definition: regu_var.hpp:129
struct db_value * m_default_value
VAL_LIST * a_val_list
Definition: xasl.h:327
int g_hash_eligible
Definition: xasl.h:330
REGU_VARIABLE * value
Definition: regu_var.hpp:96
OUTPTR_LIST * a_outptr_list_interm
Definition: xasl.h:326
METHOD_SIG * method_sig
Definition: method_def.hpp:69
static int xts_sizeof_showstmt_spec_type(const SHOWSTMT_SPEC_TYPE *ptr)
static char * xts_process_outptr_list(char *ptr, const OUTPTR_LIST *outptr_list)
static char * xts_process_rlike_eval_term(char *ptr, const RLIKE_EVAL_TERM *rlike_eval_term)
PRED_EXPR * if_pred
Definition: xasl.h:978
regu_variable_node * m_json_reguvar
int or_listid_length(void *listid)
int needs_pruning
Definition: xasl.h:236
BUILDVALUE_PROC_NODE buildvalue
Definition: xasl.h:1020
static void xts_debug_check(const T &t, char *pack_start, const char *pack_end)
static char * xts_process_union_proc(char *ptr, const UNION_PROC_NODE *union_proc)
int val_cnt
Definition: xasl.h:208
int ils_prefix_len
analytic_list_node * head
char * method_name
Definition: method_def.hpp:57
ATTR_ID * attrids_key
Definition: xasl.h:728
json_table_column_behavior m_on_empty
int n_oid_list
Definition: xasl.h:1035
regu_variable_node * src
INDX_INFO * indexptr
Definition: xasl.h:927
DB_VALUE ** cache_reserved
Definition: xasl.h:738
#define ER_FAILED
Definition: error_code.h:47
TYPE_EVAL_TERM et_type
REGU_VARIABLE_LIST next
Definition: regu_var.hpp:221
bool ql_flag
Definition: xasl.h:300
static int xts_save_method_sig_list(const METHOD_SIG_LIST *ptr)
int wait_msecs
Definition: xasl.h:224
static char * xts_process_pred(char *ptr, const PRED *pred)
static char * xts_process_merge_proc(char *ptr, const MERGE_PROC_NODE *merge_info)
int * mvcc_reev_classes
Definition: xasl.h:412
UPDDEL_CLASS_INFO * classes
Definition: xasl.h:407
REGU_VARIABLE * limit_row_count
Definition: xasl.h:983
static int xts_save_list_id(const QFILE_LIST_ID *list_id)
#define ACCESS_SPEC_SHOWSTMT_SPEC(ptr)
Definition: xasl.h:812
static int xts_sizeof_update_assignment(const UPDATE_ASSIGNMENT *assign)
char * or_pack_db_value(char *buffer, DB_VALUE *var)
union xasl_node::@155 proc
ATTR_ID * attrids_pred
Definition: xasl.h:1060
static int xts_sizeof_insert_proc(const INSERT_PROC_NODE *ptr)
bool has_delete
Definition: xasl.h:440
int orderby_desc
Definition: access_spec.hpp:92
static int xts_save(const T &t)
static int xts_save_string(const char *str)
REGU_VARIABLE * leftptr
Definition: regu_var.hpp:128
#define ER_QPROC_INVALID_XASLNODE
Definition: error_code.h:532
int no_logging
Definition: xasl.h:410
#define OR_HFID_SIZE
QFILE_LIST_MERGE_INFO ls_merge
Definition: xasl.h:363
static int xts_sizeof_regu_value_list(const REGU_VALUE_LIST *regu_value_list)
REGU_VARIABLE_LIST set_regu_list
Definition: xasl.h:764
int num_assign_reev_classes
Definition: xasl.h:377
SHOWSTMT_TYPE show_type
Definition: xasl.h:758
regu_variable_node * elem
static int xts_sizeof(const json_table_column &ptr)
#define ACCESS_SPEC_METHOD_SPEC(ptr)
Definition: xasl.h:842
analytic_eval_type * next
PRED_EXPR * g_grbynum_pred
Definition: xasl.h:316
int num_val_lists
Definition: xasl.h:399
static int xts_Xasl_errcode
static int xts_sizeof_cte_proc(const CTE_PROC_NODE *ptr)
static int xts_sizeof_set_spec_type(const SET_SPEC_TYPE *ptr)
static int xts_save_analytic_type(const ANALYTIC_TYPE *analytic)
#define assert_release(e)
Definition: error_manager.h:96
#define OFFSET_BUFFER_SIZE
XASL_UNPACK_INFO * get_xasl_unpack_info_ptr(THREAD_ENTRY *thread_p)
TARGET_TYPE type
Definition: xasl.h:925
ATTR_ID * attrids_pred
Definition: xasl.h:732
static int xts_sizeof_selupd_list(const SELUPD_LIST *ptr)
static int xts_save_xasl_node(const XASL_NODE *ptr)
METHOD_TYPE method_type
Definition: method_def.hpp:59
static int xts_sizeof_aggregate_type(const AGGREGATE_TYPE *ptr)
static int xts_get_regu_variable_value_size(const REGU_VARIABLE *ptr)
REGU_VARLIST_LIST select_list
Definition: xasl.h:223
XASL_NODE * inner_xasl
Definition: xasl.h:359
REGU_VARIABLE * orderby_limit
Definition: xasl.h:960
CL_ATTR_ID id
Definition: regu_var.hpp:76
static int xts_save_key_range_array(const KEY_RANGE *ptr, int size)
int select_list_size
Definition: xasl.h:222
QUERY_OPTIONS option
Definition: xasl.h:967
#define OR_ALIGNED_BUF(size)
int num_default_expr
Definition: xasl.h:389
UNION_PROC_NODE union_
Definition: xasl.h:1017
int * mvcc_reev_classes
Definition: xasl.h:379
static int xts_sizeof_mergelist_proc(const MERGELIST_PROC_NODE *ptr)
ANALYTIC_EVAL_TYPE * a_eval_list
Definition: xasl.h:322
VALPTR_LIST ** valptr_lists
Definition: xasl.h:400
static int xts_save_cache_attrinfo(const HEAP_CACHE_ATTRINFO *ptr)
int projected_size
Definition: xasl.h:1034
int groupby_desc
Definition: access_spec.hpp:93
const size_t STREAM_EXPANSION_UNIT
Definition: xasl_stream.hpp:52
bool REGU_VARIABLE_IS_FLAGED(const regu_variable_node *regu, int flag)
Definition: regu_var.hpp:253
aggregate_accumulator accumulator
int has_uniques
Definition: xasl.h:237
#define ACCESS_SPEC_LIST_SPEC(ptr)
Definition: xasl.h:809
static int xts_save_func_pred(const FUNC_PRED *ptr)
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
#define OR_ALIGNED_BUF_SIZE(abuf)
#define OR_PACK_DOMAIN_OBJECT_TO_OID(p, d, o, n)
static int xts_sizeof_list_spec_type(const LIST_SPEC_TYPE *ptr)
char * or_pack_oid(char *ptr, const OID *oid)
OID class_oid
Definition: xasl.h:386
UPDDEL_CLASS_INFO * classes
Definition: xasl.h:370
int no_logging
Definition: xasl.h:375
#define PTR_ALIGN(addr, boundary)
Definition: memory_alloc.h:77
DB_VALUE * arg
Definition: xasl.h:297
int num_reev_classes
Definition: xasl.h:411
BUILDLIST_PROC_NODE buildlist
Definition: xasl.h:1019
int or_packed_domain_size(struct tp_domain *domain, int include_classoids)
static int xts_save_srlist_id(const QFILE_SORTED_LIST_ID *sort_list_id)
static int xts_sizeof_cls_spec_type(const CLS_SPEC_TYPE *ptr)
static int xts_sizeof_update_proc(const UPDATE_PROC_NODE *ptr)
Definition: xasl.h:189
int * attr_ids
Definition: xasl.h:266
regu_variable_node operand
int * att_id
Definition: xasl.h:390
static int xts_sizeof_fetch_proc(const FETCH_PROC_NODE *ptr)
UPDATE_PROC_NODE update
Definition: xasl.h:1022
static char * xts_process_buildvalue_proc(char *ptr, const BUILDVALUE_PROC_NODE *build_value_proc)
regu_variable_node * lhs
ACCESS_SPEC_TYPE * inner_spec_list
Definition: xasl.h:360
METHOD_SIG * next
Definition: method_def.hpp:56
XASL_NODE_HEADER header
Definition: xasl.h:951
DELETE_PROC_NODE delete_
Definition: xasl.h:1024
static int xts_sizeof_upddel_class_info(const UPDDEL_CLASS_INFO *upd_cls)
#define MAX_ALIGNMENT
Definition: memory_alloc.h:70
const int REGU_VARIABLE_FETCH_NOT_CONST
Definition: regu_var.hpp:164
static char * xts_process_regu_value_list(char *ptr, const REGU_VALUE_LIST *regu_value_list)
DB_VALUE * g_grbynum_val
Definition: xasl.h:317
static int xts_save_selupd_list(const SELUPD_LIST *selupd_list)
static int xts_save_outptr_list(const OUTPTR_LIST *outptr_list)
SORT_ORDER s_order
Definition: query_list.h:417
int num_attrs_reserved
Definition: xasl.h:739
json_table_column_behavior m_on_error
SELUPD_LIST * selected_upd_list
Definition: xasl.h:969
int is_single_tuple
Definition: xasl.h:965
static char * xts_process_list_id(char *ptr, const QFILE_LIST_ID *list_id)
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
bool iscan_oid_order
Definition: xasl.h:1041
REGU_VARIABLE_LIST list_regu_list_build
Definition: xasl.h:750
static char * xts_process_indx_info(char *ptr, const INDX_INFO *indx_info)
static int xts_get_offset_visited_ptr(const void *ptr)
static char * xts_process_comp_eval_term(char *ptr, const COMP_EVAL_TERM *comp_eval_term)
int xasl_stream_make_align(int x)
static int xts_save_oid_array(OID *ptr, int size)
DB_VALUE * val
Definition: xasl.h:196
int no_logging
Definition: xasl.h:396
static char * xts_process_analytic_eval_type(char *ptr, const ANALYTIC_EVAL_TYPE *analytic)
static char * xts_process_pred_expr(char *ptr, const PRED_EXPR *pred_expr)
static int xts_Ptr_lwm[MAX_PTR_BLOCKS]
static int xts_Free_offset_in_stream
#define OR_ALIGNED_BUF_START(abuf)
const size_t START_PTR_PER_BLOCK
Definition: xasl_stream.hpp:47
static int xts_sizeof_method_sig_list(const METHOD_SIG_LIST *ptr)
HEAP_CACHE_ATTRINFO * attr_info
Definition: xasl.h:265
RANGE range
Definition: access_spec.hpp:69
static int xts_Ptr_max[MAX_PTR_BLOCKS]
OPERATOR_TYPE opcode
Definition: regu_var.hpp:131
KEY_INFO key_info
Definition: access_spec.hpp:91
ACCESS_METHOD access
Definition: xasl.h:926
SCAN_OPERATION_TYPE scan_op_type
Definition: xasl.h:1005
XASL_NODE * next
Definition: xasl.h:952
char * or_pack_double(char *ptr, double number)
HEAP_CACHE_ATTRINFO * cache_rest
Definition: xasl.h:735
bool single_table_opt
Definition: xasl.h:431
DB_VALUE * s_dbval
Definition: xasl.h:934
int flag
Definition: xasl.h:954
XASL_NODE * recursive_part
Definition: xasl.h:447
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
#define PTR_SIZE
char * or_pack_hfid(const char *ptr, const HFID *hfid)
ACCESS_SPEC_TYPE * next
Definition: xasl.h:935
PRED_EXPR * start_with_pred
Definition: xasl.h:419
cubxasl::pred_expr * pred
Definition: regu_var.hpp:133
int num_assigns
Definition: xasl.h:372
analytic_percentile_function_info percentile
static int xts_sizeof_regu_variable(const REGU_VARIABLE *ptr)
KEY_RANGE iss_range
Definition: access_spec.hpp:99
XASL_NODE * outer_xasl
Definition: xasl.h:356
static int xts_save_aggregate_type(const AGGREGATE_TYPE *aggregate)
MISC_OPERAND misc_operand
Definition: regu_var.hpp:132
#define ACCESS_SPEC_JSON_TABLE_SPEC(ptr)
Definition: xasl.h:845
#define assert(x)
ACCESS_SPEC_TYPE * curr_spec
Definition: xasl.h:996
REGU_VARIABLE * func_regu
Definition: xasl.h:277
int ordbynum_flag
Definition: xasl.h:961
CONNECTBY_PROC_NODE connect_by
Definition: xasl.h:1025
int use_desc_index
Definition: access_spec.hpp:94
int or_packed_string_length(const char *string, int *strlen)
#define ASSERT_ALIGN(ptr, alignment)
static char * xts_process_method_sig(char *ptr, const METHOD_SIG *method_sig, int size)
XASL_NODE * dptr_list
Definition: xasl.h:976
REGU_VARIABLE_LIST after_cb_regu_list_rest
Definition: xasl.h:430
PRED_EXPR * where_range
Definition: xasl.h:931
PRED_EXPR * cons_pred
Definition: xasl.h:392
int num_vals
Definition: xasl.h:388
static char * xts_process_eval_term(char *ptr, const EVAL_TERM *eval_term)
INSERT_PROC_NODE insert
Definition: xasl.h:1023
static char * xts_process_rlist_spec_type(char *ptr, const LIST_SPEC_TYPE *list_spec)
static int xts_save_odku_info(const ODKU_INFO *odku_info)
static char * xts_save_upddel_class_info(char *ptr, const UPDDEL_CLASS_INFO *upd_cls)
struct sort_list * next
Definition: query_list.h:415
comp_eval_term et_comp
#define ER_OUT_OF_VIRTUAL_MEMORY
Definition: error_code.h:50
#define OR_PACK_XASL_NODE_HEADER(PTR, X)
Definition: xasl.h:74
REGU_VARIABLE value
Definition: regu_var.hpp:222
static int xts_sizeof_like_eval_term(const LIKE_EVAL_TERM *ptr)
static char * xts_process_json_table_column_behavior(char *ptr, const json_table_column_behavior *behavior)
QFILE_LIST_ID * list_id
Definition: xasl.h:955
REGU_VARIABLE_LIST list_regu_list_pred
Definition: xasl.h:748
#define OR_VALUE_ALIGNED_SIZE(value)
json_table_column_function m_function
HEAP_CACHE_ATTRINFO * cache_range
Definition: xasl.h:742
static int xts_sizeof_sort_list(const SORT_LIST *ptr)
static char * xts_process_ls_merge_info(char *ptr, const QFILE_LIST_MERGE_INFO *qfile_list_merge_info)
union cubxasl::pred_expr::@185 pe
static char * xts_process_mergelist_proc(char *ptr, const MERGELIST_PROC_NODE *merge_list_info)
int or_db_value_size(DB_VALUE *var)
OID class_oid
Definition: xasl.h:220
char * stx_build(THREAD_ENTRY *thread_p, char *ptr, regu_variable_node &reguvar)
regu_variable_node * percentile_reguvar
ACCESS_SPEC_FLAG flags
Definition: xasl.h:937
int orderby_skip
Definition: access_spec.hpp:95
static char * xts_process_set_spec_type(char *ptr, const SET_SPEC_TYPE *set_spec)
UPDATE_ASSIGNMENT * assigns
Definition: xasl.h:373
static char * xts_process_connectby_proc(char *ptr, const CONNECTBY_PROC_NODE *connectby_proc)
static int xts_sizeof_json_table_column_behavior(const json_table_column_behavior *behavior)
static int xts_sizeof_pred(const PRED *ptr)
static int xts_sizeof_rlike_eval_term(const RLIKE_EVAL_TERM *ptr)
REGU_VARIABLE_LIST cls_regu_val_list
Definition: xasl.h:725
#define ACCESS_SPEC_CLS_SPEC(ptr)
Definition: xasl.h:797
int next_scan_on
Definition: xasl.h:998
REGU_VARIABLE_LIST method_regu_list
Definition: xasl.h:770
REGU_VARIABLE * level_regu
Definition: xasl.h:989
int * method_arg_pos
Definition: method_def.hpp:61
static int xts_save_filter_pred_node(const PRED_EXPR_WITH_CONTEXT *pred)
ARITH_TYPE * outarith_list
Definition: xasl.h:348
static char * xts_process_xasl_node(char *ptr, const XASL_NODE *xasl)
REGU_VARIABLE_LIST a_regu_list
Definition: xasl.h:323
static char * xts_process_cache_attrinfo(char *ptr)
static int xts_sizeof_method_sig(const METHOD_SIG *ptr)
XASL_NODE * xasl_node
Definition: xasl.h:771
static int xts_save_pred_expr(const PRED_EXPR *ptr)
REGU_VALUE_ITEM * next
Definition: regu_var.hpp:97
int pruning_type
Definition: xasl.h:398
REGU_VARIABLE * iscycle_regu
Definition: xasl.h:994
PRED_EXPR * after_connect_by_pred
Definition: xasl.h:420
static char * xts_process_analytic_type(char *ptr, const ANALYTIC_TYPE *analytic)
int wait_msecs
Definition: xasl.h:374
DB_VALUE * isleaf_val
Definition: xasl.h:991
static char * xts_process_srlist_id(char *ptr, const QFILE_SORTED_LIST_ID *sort_list_id)
static int xts_sizeof_key_info(const KEY_INFO *ptr)
#define NULL
Definition: freelistheap.h:34
int next_scan_block_on
Definition: xasl.h:999
int * att_id
Definition: xasl.h:235
static int xts_sizeof_list_id(const QFILE_LIST_ID *ptr)
ATTR_ID * attrids_rest
Definition: xasl.h:734
int ** lob_attr_ids
Definition: xasl.h:240
XASL_NODE * connect_by_ptr
Definition: xasl.h:987
int groupby_skip
Definition: access_spec.hpp:96
#define OR_DOUBLE_ALIGNED_SIZE
REGU_VARIABLE_LIST regu_list_rest
Definition: xasl.h:424
ACCESS_SCHEMA_TYPE schema_type
Definition: xasl.h:737
static char * xts_process_attr_descr(char *ptr, const ATTR_DESCR *attr_descr)
REGU_VARIABLE_LIST regu_list_pred
Definition: xasl.h:423
OUTPTR_LIST * a_outptr_list_ex
Definition: xasl.h:325
static char * xts_Stream_buffer
VAL_LIST * single_tuple
Definition: xasl.h:963
static int xts_sizeof_eval_term(const EVAL_TERM *ptr)
int num_assigns
Definition: xasl.h:263
REGU_VARIABLE_LIST after_cb_regu_list_pred
Definition: xasl.h:429
regu_variable_node * rhs
static int xts_save_val_list(const VAL_LIST *ptr)
QFILE_TUPLE_VALUE_POSITION pos_descr
Definition: query_list.h:416
REGU_DATATYPE
Definition: regu_var.hpp:42
HFID class_hfid
Definition: xasl.h:221
static void xts_debug_clear(T &t)
static char * xts_process_delete_proc(char *ptr, const DELETE_PROC_NODE *delete_proc)
VAL_LIST * g_val_list
Definition: xasl.h:314
aggregate_list_node * next
static int xts_sizeof_arith_type(const ARITH_TYPE *ptr)
#define db_private_free_and_init(thrd, ptr)
Definition: memory_alloc.h:141
static int xts_sizeof_srlist_id(const QFILE_SORTED_LIST_ID *ptr)
XASL_NODE * insert_xasl
Definition: xasl.h:439
REGU_VARIABLE_LIST list_regu_list_rest
Definition: xasl.h:749
char * or_unpack_int(char *ptr, int *number)
static int xts_sizeof_xasl_node(const XASL_NODE *ptr)
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 void xts_free_visited_ptrs(void)
int func_idx_col_id
Definition: access_spec.hpp:98
QFILE_LIST_ID * push_list_id
Definition: xasl.h:311
static char * xts_process_regu_variable_list(char *ptr, const REGU_VARIABLE_LIST regu_var_list)
static int xts_sizeof_ls_merge_info(const QFILE_LIST_MERGE_INFO *ptr)
int num_orderby_keys
Definition: xasl.h:376
int num_attrs_key
Definition: xasl.h:730
static int xts_sizeof_pos_descr(const QFILE_TUPLE_VALUE_POSITION *ptr)
static int xts_sizeof_cache_attrinfo(const HEAP_CACHE_ATTRINFO *ptr)
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
static char * xts_process_function_type(char *ptr, const FUNCTION_TYPE *function)
static XTS_VISITED_PTR * xts_Ptr_blocks[MAX_PTR_BLOCKS]
static int xts_save_upddel_class_info_array(const UPDDEL_CLASS_INFO *classes, int nelements)
static char * xts_process_db_value(char *ptr, const DB_VALUE *value)
static int xts_sizeof_function_type(const FUNCTION_TYPE *ptr)
DB_TYPE type
Definition: regu_var.hpp:77
OID * class_oid
Definition: xasl.h:232
FETCH_PROC_NODE fetch
Definition: xasl.h:1018
static int xts_reserve_location_in_stream(int size)
AGGREGATE_TYPE * g_agg_list
Definition: xasl.h:318
static int xts_save_analytic_eval_type(const ANALYTIC_EVAL_TYPE *analytic)
int num_attrs_rest
Definition: xasl.h:736
PRED_EXPR * where_pred
Definition: xasl.h:930
PRED_EXPR * after_join_pred
Definition: xasl.h:977
static int xts_sizeof_val_list(const VAL_LIST *ptr)
#define CAST_BUFLEN
Definition: porting.h:471
CTE_PROC_NODE cte
Definition: xasl.h:1027
XASL_NODE * eptr_list
Definition: xasl.h:308
OID creator_oid
Definition: xasl.h:1033
static int xts_sizeof_delete_proc(const DELETE_PROC_NODE *ptr)
PRED_EXPR * cons_pred
Definition: xasl.h:371
int g_grbynum_flag
Definition: xasl.h:328
char * or_pack_int(char *ptr, int number)
#define ACCESS_SPEC_SET_SPEC(ptr)
Definition: xasl.h:833
static char * xts_process_showstmt_spec_type(char *ptr, const SHOWSTMT_SPEC_TYPE *list_spec)
static int xts_sizeof_func_pred(const FUNC_PRED *ptr)
static int xts_save_regu_varlist_list(const REGU_VARLIST_LIST ptr)
double cardinality
Definition: xasl.h:1030
int g_output_first_tuple
Definition: xasl.h:331
#define ARG_FILE_LINE
Definition: error_manager.h:44
analytic_function_info info
static int xts_sizeof_attr_descr(const ATTR_DESCR *ptr)
char * or_pack_listid(char *ptr, void *listid)
XASL_NODE * left
Definition: xasl.h:289
static int xts_save_indx_info(const INDX_INFO *indx_info)
const char * query_alias
Definition: xasl.h:1039
VAL_LIST * outer_val_list
Definition: xasl.h:358
static int xts_save_db_value(const DB_VALUE *ptr)
XASL_NODE * right
Definition: xasl.h:290
static int xts_save_int_array(int *ptr, int size)
OUTPTR_LIST * prior_outptr_list
Definition: xasl.h:426
int instnum_flag
Definition: xasl.h:997
int xts_map_func_pred_to_stream(const FUNC_PRED *xasl_tree, char **xasl_stream, int *xasl_stream_size)
bool key_limit_reset
Definition: access_spec.hpp:78
DB_VALUE * level_val
Definition: xasl.h:988
int buffer_size
Definition: xasl.h:614
OID * class_oid_list
Definition: xasl.h:1036
static char * xts_process_list_spec_type(char *ptr, const LIST_SPEC_TYPE *list_spec)
static char * xts_process_func_pred(char *ptr, const FUNC_PRED *xasl)
static char * xts_process_filter_pred_node(char *ptr, const PRED_EXPR_WITH_CONTEXT *pred)
static int xts_save_update_assignment_array(const UPDATE_ASSIGNMENT *assigns, int nelements)
const void * ptr
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
static char * xts_process_pos_descr(char *ptr, const QFILE_TUPLE_VALUE_POSITION *position_descr)
void set_xasl_unpack_info_ptr(THREAD_ENTRY *thread_p, XASL_UNPACK_INFO *ptr)
RANGE_TYPE range_type
Definition: access_spec.hpp:90
static char * xts_process_cte_proc(char *ptr, const CTE_PROC_NODE *cte_proc)
XASL_NODE * scan_ptr
Definition: xasl.h:985
#define free_and_init(ptr)
Definition: memory_alloc.h:147
SORT_LIST * after_groupby_list
Definition: xasl.h:310
ACCESS_SPEC_TYPE * spec_list
Definition: xasl.h:970
ODKU_INFO * odku
Definition: xasl.h:393
bool is_user_given_keylimit
Definition: access_spec.hpp:79
enum json_table_column_behavior_type m_behavior
SELUPD_LIST * next
Definition: xasl.h:219
int num_subclasses
Definition: xasl.h:231
HEAP_CACHE_ATTRINFO * cache_attrinfo
Definition: regu_var.hpp:78
char * or_pack_string_with_length(char *ptr, const char *string, int length)
static char * xts_process_selupd_list(char *ptr, const SELUPD_LIST *selupd_list)
OUTPTR_LIST * a_outptr_list
Definition: xasl.h:324
int num_classes
Definition: xasl.h:408
char * or_pack_domain(char *ptr, struct tp_domain *domain, int include_classoids, int is_null)
int mvcc_reev_extra_cls_cnt
Definition: xasl.h:1008
int hash_list_scan_yn
Definition: xasl.h:752
QPROC_DB_VALUE_LIST valp
Definition: xasl.h:207
static int xts_sizeof_indx_info(const INDX_INFO *ptr)
QFILE_LIST_ID * input_list_id
Definition: xasl.h:421
REGU_VARIABLE_LIST g_hk_scan_regu_list
Definition: xasl.h:319
static char * xts_process_fetch_proc(char *ptr, const FETCH_PROC_NODE *obj_set_fetch_proc)
static char * xts_process_regu_variable(char *ptr, const REGU_VARIABLE *regu_var)
#define INT_ALIGNMENT
Definition: memory_alloc.h:61
OUTPTR_LIST * cls_output_val_list
Definition: xasl.h:724
int * num_lob_attrs
Definition: xasl.h:239
class regu_variable_node REGU_VARIABLE
Definition: regu_var.hpp:64
HEAP_CACHE_ATTRINFO * cache_attrinfo
Definition: xasl.h:278
static char * xts_process_aggregate_type(char *ptr, const AGGREGATE_TYPE *aggregate)
REGU_VARIABLE_LIST g_hk_sort_regu_list
Definition: xasl.h:320
static int xts_save_regu_variable(const REGU_VARIABLE *ptr)
PRED_EXPR * where_key
Definition: xasl.h:929
static char * xts_process_cls_spec_type(char *ptr, const CLS_SPEC_TYPE *cls_spec)
UPDATE_ASSIGNMENT * assignments
Definition: xasl.h:264
int upd_del_class_cnt
Definition: xasl.h:1006
REGU_VARIABLE_LIST cls_regu_list_pred
Definition: xasl.h:720
DB_VALUE * grbynum_val
Definition: xasl.h:346
REGU_VARIABLE * regu_var
Definition: xasl.h:254
static char * xts_process_arith_type(char *ptr, const ARITH_TYPE *arith)
#define XASL_NODE_HEADER_SIZE
Definition: xasl.h:72
static int xts_save_method_sig(const METHOD_SIG *ptr, int size)
PRED_EXPR * cons_pred
Definition: xasl.h:262
int xts_map_xasl_to_stream(const XASL_NODE *xasl_tree, XASL_STREAM *stream)
static char * xts_process_xasl_header(char *ptr, const XASL_NODE_HEADER header)
PRED_EXPR * pred
Definition: xasl.h:1058
char * buffer
Definition: xasl.h:613
int xts_map_filter_pred_to_stream(const PRED_EXPR_WITH_CONTEXT *pred, char **pred_stream, int *pred_stream_size)
int i
Definition: dynamic_load.c:954
static int xts_save_hfid_array(HFID *ptr, int size)
OID cls_oid
Definition: xasl.h:727
const size_t MAX_PTR_BLOCKS
static int xts_mark_ptr_visited(const void *ptr, int offset)
HFID * class_hfid
Definition: xasl.h:233
static int xts_sizeof_regu_variable_list(const REGU_VARIABLE_LIST regu_var_list)
static char * xts_process(char *ptr, const json_table_column &json_table_col)
REGU_VARIABLE_LIST cls_regu_list_rest
Definition: xasl.h:721
int has_uniques
Definition: xasl.h:394
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 int xts_sizeof_filter_pred_node(const PRED_EXPR_WITH_CONTEXT *ptr)
VAL_LIST * merge_val_list
Definition: xasl.h:973
int wait_msecs
Definition: xasl.h:409
int wait_msecs
Definition: xasl.h:395
ATTR_ID * attrids_range
Definition: xasl.h:741
TYPE_PRED_EXPR type
static int xts_sizeof_union_proc(const UNION_PROC_NODE *ptr)
SORT_LIST * groupby_list
Definition: xasl.h:309
const int REGU_VARIABLE_FETCH_ALL_CONST
Definition: regu_var.hpp:163
HFID hfid
Definition: xasl.h:726
static char * xts_process_val_list(char *ptr, const VAL_LIST *val_list)
int * class_locks
Definition: xasl.h:1037
REGU_VARIABLE_LIST cls_regu_list_range
Definition: xasl.h:722
static char * xts_process_alsm_eval_term(char *ptr, const ALSM_EVAL_TERM *alsm_eval_term)
analytic_list_node * next
REGU_VARIABLE_LIST arg_list
Definition: xasl.h:759
static int xts_sizeof_pred_expr(const PRED_EXPR *ptr)
REGU_VARIABLE * thirdptr
Definition: regu_var.hpp:130
alsm_eval_term et_alsm
REGU_VARIABLE * limit_offset
Definition: xasl.h:982
static int xts_save_sort_list(const SORT_LIST *ptr)
regu_variable_node * pattern
union cubxasl::eval_term::@184 et
QFILE_LIST_ID * start_with_list_id
Definition: xasl.h:422
SORT_NULLS s_nulls
Definition: query_list.h:418
like_eval_term et_like
regu_variable_node * pattern
REGU_VARIABLE_LIST g_regu_list
Definition: xasl.h:313
QPROC_SINGLE_FETCH single_fetch
Definition: xasl.h:933
static char * xts_process_buildlist_proc(char *ptr, const BUILDLIST_PROC_NODE *build_list_proc)
static char * xts_process_method_sig_list(char *ptr, const METHOD_SIG_LIST *method_sig_list)
pred_expr * rhs
REGU_VARIABLE_LIST g_scan_regu_list
Definition: xasl.h:321
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
REGU_VARLIST_LIST next
Definition: regu_var.hpp:228
int xasl_stream_get_ptr_block(const void *ptr)
static int xts_sizeof_access_spec_type(const ACCESS_SPEC_TYPE *ptr)
HEAP_CACHE_ATTRINFO * cache_key
Definition: xasl.h:729
regu_variable_node * esc_char
static char * xts_process_key_info(char *ptr, const KEY_INFO *key_info)
Definition: xasl.h:186
static int xts_sizeof_analytic_type(const ANALYTIC_TYPE *ptr)
VAL_LIST * inner_val_list
Definition: xasl.h:361
static int xts_save_function_type(const FUNCTION_TYPE *function)
int pruning_type
Definition: xasl.h:936
DB_VALUE * iscycle_val
Definition: xasl.h:993
MERGE_PROC_NODE merge
Definition: xasl.h:1026
METHOD_SIG_LIST * method_sig_list
Definition: xasl.h:774
REGU_VARIABLE_LIST valptrp
Definition: regu_var.hpp:116
static char * xts_process_access_spec_type(char *ptr, const ACCESS_SPEC_TYPE *access_spec)
static char * xts_process_sort_list(char *ptr, const SORT_LIST *sort_list)
DB_VALUE * instnum_val
Definition: xasl.h:980
rlike_eval_term et_rlike
SORT_LIST * after_iscan_list
Definition: xasl.h:956
int num_classes
Definition: xasl.h:369
static char * xts_process_like_eval_term(char *ptr, const LIKE_EVAL_TERM *like_eval_term)
static int xts_sizeof_comp_eval_term(const COMP_EVAL_TERM *ptr)
int num_attrs_pred
Definition: xasl.h:731
int num_attrs_range
Definition: xasl.h:743
bool xasl_stream_compare(const cubxasl::json_table::column &first, const cubxasl::json_table::column &second)
const char ** p
Definition: dynamic_load.c:945
HFID class_hfid
Definition: xasl.h:387
static int xts_sizeof_buildvalue_proc(const BUILDVALUE_PROC_NODE *ptr)
REGU_VARIABLE * isleaf_regu
Definition: xasl.h:992
static int xts_save_arith_type(const ARITH_TYPE *arithmetic)
static int xts_Stream_size
REGU_VARIABLE_LIST cls_regu_list_reserved
Definition: xasl.h:740
static int xts_sizeof_db_value(const DB_VALUE *ptr)
XASL_NODE * non_recursive_part
Definition: xasl.h:446
int num_reev_classes
Definition: xasl.h:378
static int xts_sizeof_buildlist_proc(const BUILDLIST_PROC_NODE *ptr)
regu_variable_list_node * operands
HEAP_CACHE_ATTRINFO * cache_pred
Definition: xasl.h:1061
static int xts_save_regu_variable_list(const REGU_VARIABLE_LIST ptr)
REGU_VARIABLE * set_ptr
Definition: xasl.h:765
bool g_with_rollup
Definition: xasl.h:329
int * tcard_list
Definition: xasl.h:1038
DB_VALUE * constant
Definition: xasl.h:253
int do_replace
Definition: xasl.h:397
regu_variable_node * case_sensitive
DB_VALUE * obj_oid
Definition: xasl.h:401
bool is_constant
Definition: access_spec.hpp:77
QFILE_LIST_ID * list_id
Definition: query_list.h:533
regu_variable_node * key_limit_l
Definition: access_spec.hpp:80
TP_DOMAIN * domain
Definition: regu_var.hpp:125