CUBRID Engine  latest
network_interface_cl.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  * network_interface_cl.c - Interface functions for client requests.
21  */
22 
23 #ident "$Id$"
24 
25 #include "config.h"
26 
27 #include <stdio.h>
28 #include <string.h>
29 #include <assert.h>
30 
31 #include "porting.h"
32 #include "network.h"
33 #include "network_interface_cl.h"
34 #include "memory_alloc.h"
35 #include "mem_block.hpp"
36 #include "storage_common.h"
37 #if defined(CS_MODE)
38 #include "server_interface.h"
39 #include "boot_cl.h"
40 #include "schema_manager.h"
41 #else /* !defined (CS_MODE) == defined (SA_MODE) */
42 #include "xserver_interface.h"
43 #include "boot_sr.h"
44 #include "locator_sr.h"
45 #include "query_executor.h"
46 #include "transaction_sr.h"
47 #include "jsp_sr.h"
48 #include "vacuum.h"
49 #include "serial.h"
50 #endif /* defined (SA_MODE) */
51 #include "oid.h"
52 #include "error_manager.h"
53 #include "object_primitive.h"
54 #include "object_representation.h"
55 #include "log_comm.h"
56 #include "log_writer.h"
57 #include "arithmetic.h"
58 #include "transaction_cl.h"
59 #include "language_support.h"
60 #include "statistics.h"
61 #include "system_parameter.h"
62 #include "replication.h"
63 #include "es.h"
64 #include "db.h"
65 #include "db_query.h"
66 #include "dbtype.h"
67 #include "compile_context.h"
68 #if defined (SA_MODE)
69 #include "thread_manager.hpp"
70 #endif // SA_MODE
71 #include "xasl.h"
72 #include "lob_locator.hpp"
73 
74 /*
75  * Use db_clear_private_heap instead of db_destroy_private_heap
76  */
77 
78 #define NET_COPY_AREA_SENDRECV_SIZE (OR_INT_SIZE * 3)
79 #define NET_SENDRECV_BUFFSIZE (OR_INT_SIZE)
80 
81 #if defined (CS_MODE)
82 #define NET_DEFER_END_QUERIES_MAX 5
83 static QUERY_ID net_Deferred_end_queries[NET_DEFER_END_QUERIES_MAX];
84 static int net_Deferred_end_queries_count = 0;
85 #endif /* CS_MODE */
86 
87 /*
88  * Flag to indicate whether we've crossed the client/server boundary.
89  * It really only comes into play in standalone.
90  */
91 unsigned int db_on_server = 0;
92 
93 #if defined(CS_MODE)
94 static char *pack_const_string (char *buffer, const char *cstring);
95 static char *pack_string_with_null_padding (char *buffer, const char *stream, int len);
96 static int length_const_string (const char *cstring, int *strlen);
97 static int length_string_with_null_padding (int len);
98 #endif /* CS_MODE */
99 #if defined (SA_MODE)
100 static void enter_server_no_thread_entry (void);
101 static THREAD_ENTRY *enter_server (void);
102 static void exit_server_no_thread_entry (void);
103 static void exit_server (const THREAD_ENTRY & thread_ref);
104 #endif // SERVER_MODE
105 
106 #if defined (SA_MODE)
107 //
108 // enter_server_no_thread_entry () - enter server mode without getting a thread entry (e.g. when "starting" server).
109 //
110 static void
111 enter_server_no_thread_entry (void)
112 {
113  db_on_server++;
115 
116  if (private_heap_id == 0)
117  {
118  assert (db_on_server == 1);
120  }
121 }
122 
123 //
124 // enter_server () - start simulating server mode
125 //
126 // return : pointer to thread entry
127 //
128 static THREAD_ENTRY *
129 enter_server ()
130 {
131  enter_server_no_thread_entry ();
133 }
134 
135 //
136 // exit_server_no_thread_entry () - exit server mode without getting a thread entry (e.g. when "starting" server).
137 //
138 static void
139 exit_server_no_thread_entry (void)
140 {
141  if ((db_on_server - 1) == 0 && private_heap_id != 0)
142  {
144  }
146  db_on_server--;
147 }
148 
149 //
150 // exit_server () - exit server mode simulation
151 //
152 // thread_ref (in) : reference to thread entry used to enter server mode
153 //
154 static void
155 exit_server (const THREAD_ENTRY & thread_ref)
156 {
157  (void) thread_ref; // not really used; just to force caller declare obtain thread entry
158 
159  exit_server_no_thread_entry ();
160 }
161 #endif // SA_MODE
162 
163 #if defined(CS_MODE)
164 /*
165  * pack_const_string -
166  *
167  * return:
168  *
169  * buffer(in):
170  * cstring(in):
171  *
172  * NOTE:
173  */
174 static char *
175 pack_const_string (char *buffer, const char *cstring)
176 {
177  return or_pack_string (buffer, cstring);
178 }
179 
180 /*
181  * pack_string_with_null_padding - pack stream and add null.
182  * so stream is made as null terminated string.
183  *
184  * return:
185  *
186  * buffer(in):
187  * stream(in):
188  * len(in):
189  *
190  * NOTE:
191  */
192 static char *
193 pack_string_with_null_padding (char *buffer, const char *stream, int len)
194 {
195  return or_pack_string_with_null_padding (buffer, stream, len);
196 }
197 
198 /*
199  * pack_const_string_with_length -
200  *
201  * return:
202  *
203  * buffer(in):
204  * cstring(in):
205  * strlen(in):
206  *
207  * NOTE:
208  */
209 static char *
210 pack_const_string_with_length (char *buffer, const char *cstring, int strlen)
211 {
212  return or_pack_string_with_length (buffer, cstring, strlen);
213 }
214 
215 /*
216  * length_const_string -
217  *
218  * return:
219  *
220  * cstring(in):
221  * strlen(out): strlen(cstring)
222  */
223 static int
224 length_const_string (const char *cstring, int *strlen)
225 {
226  return or_packed_string_length (cstring, strlen);
227 }
228 
229 /*
230  * length_string_with_null_padding - calculate length with null padding
231  *
232  * return:
233  *
234  * len(in): stream length
235  */
236 static int
237 length_string_with_null_padding (int len)
238 {
239  return or_packed_stream_length (len + 1); /* 1 for NULL padding */
240 }
241 #endif /* CS_MODE */
242 
243 /*
244  * locator_fetch -
245  *
246  * return:
247  *
248  * oidp(in):
249  * chn(in):
250  * lock(in):
251  * fetch_type(in): fetch version type
252  * class_oid(in):
253  * class_chn(in):
254  * prefetch(in):
255  * fetch_copyarea(in):
256  */
257 int
258 locator_fetch (OID * oidp, int chn, LOCK lock, LC_FETCH_VERSION_TYPE fetch_version_type, OID * class_oid, int class_chn,
259  int prefetch, LC_COPYAREA ** fetch_copyarea)
260 {
261 #if defined(CS_MODE)
262  int success = ER_FAILED;
263  int req_error;
264  char *ptr;
265  OR_ALIGNED_BUF ((OR_OID_SIZE * 2) + (OR_INT_SIZE * 5)) a_request;
266  char *request;
268  char *reply;
269 
270  request = OR_ALIGNED_BUF_START (a_request);
271  reply = OR_ALIGNED_BUF_START (a_reply);
272 
273  assert (oidp->volid >= 0 && oidp->pageid >= 0 && oidp->slotid >= 0);
274 
275  ptr = or_pack_oid (request, oidp);
276  ptr = or_pack_int (ptr, chn);
277  ptr = or_pack_lock (ptr, lock);
278  ptr = or_pack_int (ptr, (int) fetch_version_type);
279  ptr = or_pack_oid (ptr, class_oid);
280  ptr = or_pack_int (ptr, class_chn);
281  ptr = or_pack_int (ptr, prefetch);
282  *fetch_copyarea = NULL;
283 
284  req_error =
286  OR_ALIGNED_BUF_SIZE (a_reply), fetch_copyarea);
287  if (!req_error)
288  {
289  ptr = reply + NET_COPY_AREA_SENDRECV_SIZE;
290  ptr = or_unpack_int (ptr, &success);
291  }
292  else
293  {
294  *fetch_copyarea = NULL;
295  }
296 
297  return success;
298 #else /* CS_MODE */
299  int success = ER_FAILED;
300 
301  THREAD_ENTRY *thread_p = enter_server ();
302 
303  success =
304  xlocator_fetch (thread_p, oidp, chn, lock, fetch_version_type, fetch_version_type, class_oid, class_chn, prefetch,
305  fetch_copyarea);
306 
307  exit_server (*thread_p);
308 
309  return success;
310 #endif /* !CS_MODE */
311 }
312 
313 /*
314  * locator_get_class -
315  *
316  * return:
317  *
318  * class_oid(in):
319  * class_chn(in):
320  * oid(in):
321  * lock(in):
322  * prefetching(in):
323  * fetch_copyarea(in):
324  *
325  * NOTE:
326  */
327 int
328 locator_get_class (OID * class_oid, int class_chn, const OID * oid, LOCK lock, int prefetching,
329  LC_COPYAREA ** fetch_copyarea)
330 {
331 #if defined(CS_MODE)
332  int req_error;
333  char *ptr;
334  int return_value = ER_FAILED;
335  OR_ALIGNED_BUF ((OR_OID_SIZE * 2) + (OR_INT_SIZE * 3)) a_request;
336  char *request;
338  char *reply;
339 
340  request = OR_ALIGNED_BUF_START (a_request);
341  reply = OR_ALIGNED_BUF_START (a_reply);
342 
343  ptr = or_pack_oid (request, class_oid);
344  ptr = or_pack_int (ptr, class_chn);
345  ptr = or_pack_oid (ptr, (OID *) oid);
346  ptr = or_pack_lock (ptr, lock);
347  ptr = or_pack_int (ptr, prefetching);
348  *fetch_copyarea = NULL;
349 
350  req_error =
352  OR_ALIGNED_BUF_SIZE (a_reply), fetch_copyarea);
353  if (!req_error)
354  {
355  ptr = reply + NET_COPY_AREA_SENDRECV_SIZE;
356  ptr = or_unpack_oid (ptr, class_oid);
357  ptr = or_unpack_int (ptr, &return_value);
358  }
359  else
360  {
361  *fetch_copyarea = NULL;
362  }
363 
364  return return_value;
365 #else /* CS_MODE */
366  int success = ER_FAILED;
367 
368  THREAD_ENTRY *thread_p = enter_server ();
369 
370  success = xlocator_get_class (thread_p, class_oid, class_chn, oid, lock, prefetching, fetch_copyarea);
371 
372  exit_server (*thread_p);
373 
374  return success;
375 #endif /* !CS_MODE */
376 }
377 
378 /*
379  * locator_fetch_all -
380  *
381  * return:
382  *
383  * hfid(in):
384  * lock(in):
385  * fetch_version_type(in): fetch version type
386  * class_oidp(in):
387  * nobjects(in):
388  * nfetched(in):
389  * last_oidp(in):
390  * fetch_copyarea(in):
391  *
392  * NOTE:
393  */
394 int
395 locator_fetch_all (const HFID * hfid, LOCK * lock, LC_FETCH_VERSION_TYPE fetch_version_type, OID * class_oidp,
396  int *nobjects, int *nfetched, OID * last_oidp, LC_COPYAREA ** fetch_copyarea)
397 {
398 #if defined(CS_MODE)
399  int req_error;
400  char *ptr;
401  int return_value = ER_FAILED;
402  OR_ALIGNED_BUF (OR_HFID_SIZE + (OR_INT_SIZE * 4) + (OR_OID_SIZE * 2)) a_request;
403  char *request;
405  char *reply;
406 
407  request = OR_ALIGNED_BUF_START (a_request);
408  reply = OR_ALIGNED_BUF_START (a_reply);
409 
410  ptr = or_pack_hfid (request, hfid);
411  ptr = or_pack_lock (ptr, *lock);
412  ptr = or_pack_int (ptr, fetch_version_type);
413  ptr = or_pack_oid (ptr, class_oidp);
414  ptr = or_pack_int (ptr, *nobjects);
415  ptr = or_pack_int (ptr, *nfetched);
416  ptr = or_pack_oid (ptr, last_oidp);
417  *fetch_copyarea = NULL;
418 
419  req_error =
421  OR_ALIGNED_BUF_SIZE (a_reply), fetch_copyarea);
422  if (req_error == NO_ERROR)
423  {
424  ptr = reply + NET_COPY_AREA_SENDRECV_SIZE;
425  ptr = or_unpack_lock (ptr, lock);
426  ptr = or_unpack_int (ptr, nobjects);
427  ptr = or_unpack_int (ptr, nfetched);
428  ptr = or_unpack_oid (ptr, last_oidp);
429  ptr = or_unpack_int (ptr, &return_value);
430  }
431  else
432  {
433  *fetch_copyarea = NULL;
434  }
435 
436  return return_value;
437 #else /* CS_MODE */
438  int success = ER_FAILED;
439 
440  THREAD_ENTRY *thread_p = enter_server ();
441 
442  success =
443  xlocator_fetch_all (thread_p, hfid, lock, fetch_version_type, class_oidp, nobjects, nfetched, last_oidp,
444  fetch_copyarea);
445 
446  exit_server (*thread_p);
447 
448  return success;
449 #endif /* !CS_MODE */
450 }
451 
452 /*
453  * locator_does_exist -
454  *
455  * return:
456  *
457  * oidp(in):
458  * chn(in):
459  * lock(in):
460  * class_oid(in):
461  * class_chn(in):
462  * need_fetching(in):
463  * prefetch(in):
464  * fetch_copyarea(in):
465  *
466  * NOTE:
467  */
468 int
469 locator_does_exist (OID * oidp, int chn, LOCK lock, OID * class_oid, int class_chn, int need_fetching, int prefetch,
470  LC_COPYAREA ** fetch_copyarea, LC_FETCH_VERSION_TYPE fetch_version_type)
471 {
472 #if defined(CS_MODE)
473  int does_exist = LC_ERROR;
474  int req_error;
475  char *ptr;
476  OR_ALIGNED_BUF ((OR_OID_SIZE * 2) + (OR_INT_SIZE * 6)) a_request;
477  char *request;
479  char *reply;
480  OID class_;
481 
482  request = OR_ALIGNED_BUF_START (a_request);
483  reply = OR_ALIGNED_BUF_START (a_reply);
484 
485  ptr = or_pack_oid (request, oidp);
486  ptr = or_pack_int (ptr, chn);
487  ptr = or_pack_lock (ptr, lock);
488  ptr = or_pack_int (ptr, (int) fetch_version_type);
489  ptr = or_pack_oid (ptr, class_oid);
490  ptr = or_pack_int (ptr, class_chn);
491  ptr = or_pack_int (ptr, need_fetching);
492  ptr = or_pack_int (ptr, prefetch);
493 
494  if (fetch_copyarea != NULL && need_fetching)
495  {
496  *fetch_copyarea = NULL;
497  }
498 
499  req_error =
501  OR_ALIGNED_BUF_SIZE (a_reply), fetch_copyarea);
502  if (!req_error)
503  {
504  ptr = reply + NET_COPY_AREA_SENDRECV_SIZE;
505  ptr = or_unpack_int (ptr, &does_exist);
506  ptr = or_unpack_oid (ptr, &class_);
507  if (does_exist == LC_EXIST && class_oid)
508  {
509  COPY_OID (class_oid, &class_);
510  }
511  }
512  else if (fetch_copyarea != NULL)
513  {
514  *fetch_copyarea = NULL;
515  }
516 
517  return does_exist;
518 #else /* CS_MODE */
519  int success = ER_FAILED;
520 
521  THREAD_ENTRY *thread_p = enter_server ();
522 
523  success =
524  xlocator_does_exist (thread_p, oidp, chn, lock, fetch_version_type, class_oid, class_chn, need_fetching, prefetch,
525  fetch_copyarea);
526 
527  exit_server (*thread_p);
528 
529  return success;
530 #endif /* !CS_MODE */
531 }
532 
533 /*
534  * locator_notify_isolation_incons -
535  *
536  * return:
537  *
538  * synch_copyarea(in):
539  *
540  * NOTE:
541  */
542 int
544 {
545 #if defined(CS_MODE)
546  int success = ER_FAILED;
547  int req_error;
548  char *ptr;
550  char *reply;
551 
552  reply = OR_ALIGNED_BUF_START (a_reply);
553 
554  *synch_copyarea = NULL;
555  req_error =
557  OR_ALIGNED_BUF_SIZE (a_reply), synch_copyarea);
558 
559  if (!req_error)
560  {
561  ptr = reply + NET_COPY_AREA_SENDRECV_SIZE;
562  ptr = or_unpack_int (ptr, &success);
563  }
564  else
565  {
566  *synch_copyarea = NULL;
567  }
568 
569  return (success);
570 #else /* CS_MODE */
571  int success = ER_FAILED;
572 
573  THREAD_ENTRY *thread_p = enter_server ();
574 
575  success = xlocator_notify_isolation_incons (thread_p, synch_copyarea);
576 
577  exit_server (*thread_p);
578 
579  return success;
580 #endif /* !CS_MODE */
581 }
582 
583 /*
584  * locator_repl_force - flush copy area containing replication objects and receive error occurred in server
585  *
586  * return:
587  *
588  * copy_area(in):
589  * reply_copy_area(out):
590  *
591  * NOTE:
592  */
593 int
594 locator_repl_force (LC_COPYAREA * copy_area, LC_COPYAREA ** reply_copy_area)
595 {
596 #if defined(CS_MODE)
597  int error_code = ER_FAILED;
599  char *request;
600  char *request_ptr;
602  char *reply;
603  char *desc_ptr = NULL;
604  int desc_size;
605  char *content_ptr;
606  int content_size;
607  int num_objs = 0;
608  int req_error;
609 
610  request = OR_ALIGNED_BUF_START (a_request);
611  reply = OR_ALIGNED_BUF_START (a_reply);
612 
613  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
614 
615  request_ptr = or_pack_int (request, num_objs);
616  request_ptr = or_pack_int (request_ptr, desc_size);
617  request_ptr = or_pack_int (request_ptr, content_size);
618 
619  req_error =
621  desc_size, content_ptr, content_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
622  reply_copy_area);
623 
624  if (req_error == NO_ERROR)
625  {
626  /* skip first 3 */
627  (void) or_unpack_int (reply + NET_COPY_AREA_SENDRECV_SIZE, &error_code);
628  }
629  else
630  {
631  assert (er_errid () != NO_ERROR);
632  error_code = er_errid ();
633  }
634 
635  if (desc_ptr)
636  {
637  free_and_init (desc_ptr);
638  }
639 
640  return error_code;
641 #else /* CS_MODE */
642  /* Not allowed in SA_MODE */
643  return ER_FAILED;
644 #endif /* !CS_MODE */
645 }
646 
647 /*
648  * locator_force -
649  *
650  * return:
651  *
652  * copy_area(in):
653  *
654  * NOTE:
655  */
656 int
657 locator_force (LC_COPYAREA * copy_area, int num_ignore_error_list, int *ignore_error_list, int content_size)
658 {
659 #if defined(CS_MODE)
660  int error_code = ER_FAILED;
661  char *request;
662  char *request_ptr;
663  int request_size;
664  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
665  char *reply;
666  char *desc_ptr = NULL;
667  int desc_size;
668  char *content_ptr;
669  int num_objs = 0;
670  int req_error;
671  int i;
672  LC_COPYAREA_MANYOBJS *mobjs;
673 
674  mobjs = LC_MANYOBJS_PTR_IN_COPYAREA (copy_area);
675 
676  request_size = OR_INT_SIZE * (5 + num_ignore_error_list);
677  request = (char *) malloc (request_size);
678 
679  if (request == NULL)
680  {
681  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
683  }
684 
685  reply = OR_ALIGNED_BUF_START (a_reply);
686 
687  num_objs = locator_send_copy_area (copy_area, &content_ptr, NULL, &desc_ptr, &desc_size);
688 
689  request_ptr = or_pack_int (request, num_objs);
690  request_ptr = or_pack_int (request_ptr, mobjs->multi_update_flags);
691 
692  // unset start_multi_update flag after first request containing it set
694  {
696  }
697  request_ptr = or_pack_int (request_ptr, desc_size);
698  request_ptr = or_pack_int (request_ptr, content_size);
699 
700  request_ptr = or_pack_int (request_ptr, num_ignore_error_list);
701  for (i = 0; i < num_ignore_error_list; i++)
702  {
703  request_ptr = or_pack_int (request_ptr, ignore_error_list[i]);
704  }
705 
706  req_error =
707  net_client_request_3_data (NET_SERVER_LC_FORCE, request, request_size, desc_ptr, desc_size, content_ptr,
708  content_size, reply, OR_ALIGNED_BUF_SIZE (a_reply), desc_ptr, desc_size, NULL, 0);
709  if (!req_error)
710  {
711  (void) or_unpack_int (reply, &error_code);
712  if (error_code == NO_ERROR)
713  {
714  locator_unpack_copy_area_descriptor (num_objs, copy_area, desc_ptr);
715  }
716  }
717  if (desc_ptr)
718  {
719  free_and_init (desc_ptr);
720  }
721  if (request)
722  {
723  free_and_init (request);
724  }
725 
726  return error_code;
727 #else /* CS_MODE */
728  int error_code = ER_FAILED;
729  LC_COPYAREA *copy_area_clone;
730 
731  /* If xlocator_force returns error, the original copy_area should not be changed. So copy_area_clone will be used. */
732  copy_area_clone = locator_allocate_copy_area_by_length (copy_area->length);
733  if (copy_area_clone == NULL)
734  {
736  }
737 
738  memcpy (copy_area_clone->mem, copy_area->mem, copy_area->length);
739 
740  THREAD_ENTRY *thread_p = enter_server ();
741 
742  error_code = xlocator_force (thread_p, copy_area, num_ignore_error_list, ignore_error_list);
743 
744  exit_server (*thread_p);
745 
746  if (error_code != NO_ERROR)
747  {
748  /* Restore copy_area */
749  memcpy (copy_area->mem, copy_area_clone->mem, copy_area->length);
750  }
751 
752  locator_free_copy_area (copy_area_clone);
753 
754  return error_code;
755 #endif /* !CS_MODE */
756 }
757 
758 /*
759  * locator_fetch_lockset -
760  *
761  * return:
762  *
763  * lockset(in):
764  * fetch_copyarea(in):
765  *
766  * NOTE:
767  */
768 int
769 locator_fetch_lockset (LC_LOCKSET * lockset, LC_COPYAREA ** fetch_copyarea)
770 {
771 #if defined(CS_MODE)
772  int success = ER_FAILED;
773  int req_error;
774  char *ptr;
776  char *reply;
777  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
778  char *request;
779  static int eid;
780  char *packed = NULL;
781  int packed_size;
782  int send_size;
783 
784  request = OR_ALIGNED_BUF_START (a_request);
785  reply = OR_ALIGNED_BUF_START (a_reply);
786 
787  if (lockset->first_fetch_lockset_call == true)
788  {
789  send_size = locator_pack_lockset (lockset, true, true);
790 
791  packed = lockset->packed;
792  packed_size = lockset->packed_size;
793 
794  if (!packed)
795  {
796  return ER_FAILED;
797  }
798 
799  ptr = or_pack_int (request, send_size);
800 
801  req_error =
803  OR_ALIGNED_BUF_SIZE (a_reply), packed, send_size, packed, packed_size,
804  fetch_copyarea, &eid);
805  }
806  else
807  {
808  /* Don't need to send the lockset information any more */
809  packed = lockset->packed;
810  packed_size = lockset->packed_size;
811  req_error =
813  packed_size, fetch_copyarea, eid);
814  }
815 
816  if (!req_error)
817  {
819  ptr = or_unpack_int (ptr, &success);
820  if (success == NO_ERROR)
821  {
822  locator_unpack_lockset (lockset, lockset->first_fetch_lockset_call, false);
823  }
824  }
825  else
826  {
827  *fetch_copyarea = NULL;
828  }
829 
830  /*
831  * We will not need to send the lockset structure any more. We do not
832  * need to receive the classes and objects in the lockset structure
833  * any longer
834  */
835  lockset->first_fetch_lockset_call = false;
836 
837  return success;
838 #else /* CS_MODE */
839  int success = ER_FAILED;
840 
841  THREAD_ENTRY *thread_p = enter_server ();
842 
843  success = xlocator_fetch_lockset (thread_p, lockset, fetch_copyarea);
844 
845  exit_server (*thread_p);
846 
847  return success;
848 #endif /* !CS_MODE */
849 }
850 
851 /*
852  * locator_fetch_all_reference_lockset -
853  *
854  * return:
855  *
856  * oid(in):
857  * chn(in):
858  * class_oid(in):
859  * class_chn(in):
860  * lock(in):
861  * quit_on_errors(in):
862  * prune_level(in):
863  * lockset(in):
864  * fetch_copyarea(in):
865  *
866  * NOTE:
867  */
868 int
869 locator_fetch_all_reference_lockset (OID * oid, int chn, OID * class_oid, int class_chn, LOCK lock, int quit_on_errors,
870  int prune_level, LC_LOCKSET ** lockset, LC_COPYAREA ** fetch_copyarea)
871 {
872 #if defined(CS_MODE)
873  int success = ER_FAILED;
874  int req_error;
875  char *ptr;
876  OR_ALIGNED_BUF ((OR_OID_SIZE * 2) + (OR_INT_SIZE * 5)) a_request;
877  char *request;
879  char *reply;
880  char *packed;
881  int packed_size;
882 
883  request = OR_ALIGNED_BUF_START (a_request);
884  reply = OR_ALIGNED_BUF_START (a_reply);
885 
886  *fetch_copyarea = NULL;
887  *lockset = NULL;
888 
889  ptr = or_pack_oid (request, oid);
890  ptr = or_pack_int (ptr, chn);
891  ptr = or_pack_oid (ptr, class_oid);
892  ptr = or_pack_int (ptr, class_chn);
893  ptr = or_pack_lock (ptr, lock);
894  ptr = or_pack_int (ptr, quit_on_errors);
895  ptr = or_pack_int (ptr, prune_level);
896 
897  req_error =
899  reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &packed, &packed_size,
900  fetch_copyarea);
901 
902  if (!req_error)
903  {
905  ptr = or_unpack_int (ptr, &success);
906  if (packed_size > 0 && packed != NULL)
907  {
908  *lockset = locator_allocate_and_unpack_lockset (packed, packed_size, true, true, false);
909  }
910  else
911  {
912  *lockset = NULL;
913  }
914 
915  if (packed)
916  {
917  free_and_init (packed);
918  }
919  }
920  else
921  {
922  *fetch_copyarea = NULL;
923  *lockset = NULL;
924  }
925 
926  return success;
927 
928 #else /* CS_MODE */
929  int success = ER_FAILED;
930 
931  THREAD_ENTRY *thread_p = enter_server ();
932 
933  success =
934  xlocator_fetch_all_reference_lockset (thread_p, oid, chn, class_oid, class_chn, lock, quit_on_errors, prune_level,
935  lockset, fetch_copyarea);
936 
937  exit_server (*thread_p);
938 
939  return success;
940 #endif /* !CS_MODE */
941 }
942 
943 /*
944  * locator_find_class_oid -
945  *
946  * return:
947  *
948  * class_name(in):
949  * class_oid(in):
950  * lock(in):
951  *
952  * NOTE:
953  */
955 locator_find_class_oid (const char *class_name, OID * class_oid, LOCK lock)
956 {
957 #if defined(CS_MODE)
959  int xfound;
960  int req_error;
961  char *ptr;
962  int request_size, strlen;
963  char *request;
965  char *reply;
966 
967  reply = OR_ALIGNED_BUF_START (a_reply);
968 
969  request_size = length_const_string (class_name, &strlen) + OR_OID_SIZE + OR_INT_SIZE;
970  request = (char *) malloc (request_size);
971  if (request == NULL)
972  {
973  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
974  return LC_CLASSNAME_ERROR;
975  }
976 
977  ptr = pack_const_string_with_length (request, class_name, strlen);
978  ptr = or_pack_oid (ptr, class_oid);
979  ptr = or_pack_lock (ptr, lock);
980 
981  req_error = net_client_request (NET_SERVER_LC_FIND_CLASSOID, request, request_size, reply,
982  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
983  if (!req_error)
984  {
985  ptr = or_unpack_int (reply, &xfound);
986  found = (LC_FIND_CLASSNAME) xfound;
987  ptr = or_unpack_oid (ptr, class_oid);
988  }
989  free_and_init (request);
990 
991  return found;
992 #else /* CS_MODE */
994 
995  THREAD_ENTRY *thread_p = enter_server ();
996 
997  found = xlocator_find_class_oid (thread_p, class_name, class_oid, lock);
998 
999  exit_server (*thread_p);
1000 
1001  return found;
1002 #endif /* !CS_MODE */
1003 }
1004 
1005 /*
1006  * locator_reserve_class_names -
1007  *
1008  * return:
1009  *
1010  * num_classes(in)
1011  * class_names(in):
1012  * class_oids(in):
1013  *
1014  * NOTE:
1015  */
1017 locator_reserve_class_names (const int num_classes, const char **class_names, OID * class_oids)
1018 {
1019 #if defined(CS_MODE)
1021  int xreserved;
1022  int request_size;
1023  int req_error;
1024  char *request, *ptr;
1025  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1026  char *reply;
1027  int i;
1028 
1029  reply = OR_ALIGNED_BUF_START (a_reply);
1030 
1031  request_size = OR_INT_SIZE;
1032  for (i = 0; i < num_classes; ++i)
1033  {
1034  request_size += length_const_string (class_names[i], NULL) + OR_OID_SIZE;
1035  }
1036  request = (char *) malloc (request_size);
1037  if (request == NULL)
1038  {
1039  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
1040  return LC_CLASSNAME_ERROR;
1041  }
1042 
1043  ptr = or_pack_int (request, num_classes);
1044  for (i = 0; i < num_classes; ++i)
1045  {
1046  ptr = pack_const_string (ptr, class_names[i]);
1047  ptr = or_pack_oid (ptr, &class_oids[i]);
1048  }
1049 
1050  req_error = net_client_request (NET_SERVER_LC_RESERVE_CLASSNAME, request, request_size, reply,
1051  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1052  if (!req_error)
1053  {
1054  (void) or_unpack_int (reply, &xreserved);
1055  reserved = (LC_FIND_CLASSNAME) xreserved;
1056  }
1057 
1058  free_and_init (request);
1059 
1060  return reserved;
1061 #else /* CS_MODE */
1063 
1064  THREAD_ENTRY *thread_p = enter_server ();
1065 
1066  reserved = xlocator_reserve_class_names (thread_p, num_classes, class_names, class_oids);
1067 
1068  exit_server (*thread_p);
1069 
1070  return reserved;
1071 #endif /* !CS_MODE */
1072 }
1073 
1074 /*
1075  * locator_get_reserved_class_name_oid () - Get OID of reserved class.
1076  *
1077  * return : Error code.
1078  * classname (in) : Class name.
1079  * class_oid (out) : Class OID.
1080  */
1081 int
1082 locator_get_reserved_class_name_oid (const char *classname, OID * class_oid)
1083 {
1084 #if defined(CS_MODE)
1085  int request_size;
1086  int request_error = NO_ERROR;
1087  char *request = NULL;
1088  OR_ALIGNED_BUF (OR_OID_SIZE) a_reply;
1089  char *reply = NULL;
1090 
1091  assert (classname != NULL);
1092  assert (class_oid != NULL);
1093 
1094  OID_SET_NULL (class_oid);
1095 
1096  reply = OR_ALIGNED_BUF_START (a_reply);
1097 
1098  request_size = length_const_string (classname, NULL);
1099  request = (char *) malloc (request_size);
1100  if (request == NULL)
1101  {
1103  return ER_OUT_OF_VIRTUAL_MEMORY;
1104  }
1105 
1106  (void) pack_const_string (request, classname);
1107 
1108  request_error = net_client_request (NET_SERVER_LC_RESERVE_CLASSNAME_GET_OID, request, request_size, reply,
1109  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1110  free_and_init (request);
1111 
1112  if (request_error != NO_ERROR)
1113  {
1114  return request_error;
1115  }
1116 
1117  (void) or_unpack_oid (reply, class_oid);
1118 
1119  return NO_ERROR;
1120 #else
1121  int is_reserved;
1122 
1123  THREAD_ENTRY *thread_p = enter_server ();
1124 
1125  is_reserved = xlocator_get_reserved_class_name_oid (thread_p, classname, class_oid);
1126 
1127  exit_server (*thread_p);
1128 
1129  return is_reserved;
1130 #endif
1131 }
1132 
1133 /*
1134  * locator_delete_class_name -
1135  *
1136  * return:
1137  *
1138  * class_name(in):
1139  *
1140  * NOTE:
1141  */
1143 locator_delete_class_name (const char *class_name)
1144 {
1145 #if defined(CS_MODE)
1147  int xdeleted;
1148  int req_error, request_size, strlen;
1149  char *request;
1150  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1151  char *reply;
1152 
1153  reply = OR_ALIGNED_BUF_START (a_reply);
1154 
1155  request_size = length_const_string (class_name, &strlen);
1156  request = (char *) malloc (request_size);
1157  if (request == NULL)
1158  {
1159  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
1160  return LC_CLASSNAME_ERROR;
1161  }
1162 
1163  (void) pack_const_string_with_length (request, class_name, strlen);
1164  req_error = net_client_request (NET_SERVER_LC_DELETE_CLASSNAME, request, request_size, reply,
1165  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1166  if (!req_error)
1167  {
1168  or_unpack_int (reply, &xdeleted);
1169  deleted = (LC_FIND_CLASSNAME) xdeleted;
1170  }
1171 
1172  free_and_init (request);
1173 
1174  return deleted;
1175 #else /* CS_MODE */
1177 
1178  THREAD_ENTRY *thread_p = enter_server ();
1179 
1180  deleted = xlocator_delete_class_name (thread_p, class_name);
1181 
1182  exit_server (*thread_p);
1183 
1184  return deleted;
1185 #endif /* !CS_MODE */
1186 }
1187 
1188 /*
1189  * locator_rename_class_name -
1190  *
1191  * return:
1192  *
1193  * old_name(in):
1194  * new_name(in):
1195  * class_oid(in):
1196  *
1197  * NOTE:
1198  */
1200 locator_rename_class_name (const char *old_name, const char *new_name, OID * class_oid)
1201 {
1202 #if defined(CS_MODE)
1204  int xrenamed;
1205  int request_size, strlen1, strlen2;
1206  int req_error;
1207  char *request, *ptr;
1208  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1209  char *reply;
1210 
1211  reply = OR_ALIGNED_BUF_START (a_reply);
1212 
1213  request_size = length_const_string (old_name, &strlen1) + length_const_string (new_name, &strlen2) + OR_OID_SIZE;
1214  request = (char *) malloc (request_size);
1215  if (request == NULL)
1216  {
1217  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
1218  return LC_CLASSNAME_ERROR;
1219  }
1220 
1221  ptr = pack_const_string_with_length (request, old_name, strlen1);
1222  ptr = pack_const_string_with_length (ptr, new_name, strlen2);
1223  ptr = or_pack_oid (ptr, class_oid);
1224 
1225  req_error = net_client_request (NET_SERVER_LC_RENAME_CLASSNAME, request, request_size, reply,
1226  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1227  if (!req_error)
1228  {
1229  ptr = or_unpack_int (reply, &xrenamed);
1230  renamed = (LC_FIND_CLASSNAME) xrenamed;
1231  }
1232  free_and_init (request);
1233 
1234  return renamed;
1235 #else /* CS_MODE */
1237 
1238  THREAD_ENTRY *thread_p = enter_server ();
1239 
1240  renamed = xlocator_rename_class_name (thread_p, old_name, new_name, class_oid);
1241 
1242  exit_server (*thread_p);
1243 
1244  return renamed;
1245 #endif /* !CS_MODE */
1246 }
1247 
1248 /*
1249  * locator_assign_oid -
1250  *
1251  * return:
1252  *
1253  * hfid(in):
1254  * perm_oid(in):
1255  * expected_length(in):
1256  * class_oid(in):
1257  * class_name(in):
1258  *
1259  * NOTE:
1260  */
1261 int
1262 locator_assign_oid (const HFID * hfid, OID * perm_oid, int expected_length, OID * class_oid, const char *class_name)
1263 {
1264 #if defined(CS_MODE)
1265  int success = ER_FAILED;
1266  int request_size, strlen;
1267  int req_error;
1268  char *request, *ptr;
1270  char *reply;
1271 
1272  reply = OR_ALIGNED_BUF_START (a_reply);
1273 
1274  request_size = OR_HFID_SIZE + OR_INT_SIZE + OR_OID_SIZE + length_const_string (class_name, &strlen);
1275  request = (char *) malloc (request_size);
1276  if (request == NULL)
1277  {
1278  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
1279  return ER_FAILED;
1280  }
1281 
1282  ptr = or_pack_hfid (request, hfid);
1283  ptr = or_pack_int (ptr, expected_length);
1284  ptr = or_pack_oid (ptr, class_oid);
1285  ptr = pack_const_string_with_length (ptr, class_name, strlen);
1286 
1287  req_error = net_client_request (NET_SERVER_LC_ASSIGN_OID, request, request_size, reply,
1288  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1289  if (!req_error)
1290  {
1291  ptr = or_unpack_int (reply, &success);
1292  ptr = or_unpack_oid (ptr, perm_oid);
1293  }
1294  free_and_init (request);
1295 
1296  return success;
1297 #else /* CS_MODE */
1298  int success = ER_FAILED;
1299 
1300  THREAD_ENTRY *thread_p = enter_server ();
1301 
1302  success = xlocator_assign_oid (thread_p, hfid, perm_oid, expected_length, class_oid, class_name);
1303 
1304  exit_server (*thread_p);
1305 
1306  return success;
1307 #endif /* !CS_MODE */
1308 }
1309 
1310 /*
1311  * locator_assign_oid_batch -
1312  *
1313  * return:
1314  *
1315  * oidset(in):
1316  *
1317  * NOTE:
1318  */
1319 int
1321 {
1322 #if defined(CS_MODE)
1323  int success = ER_FAILED;
1324  int packed_size;
1325  char *buffer, *ptr;
1326  int req_error;
1327 
1328  /*
1329  * Build a buffer in which to send and receive the goobers. We'll
1330  * reuse the same buffer to receive the data as we used to send it.
1331  * First word is reserved for the return code.
1332  */
1333  packed_size = locator_get_packed_oid_set_size (oidset) + OR_INT_SIZE;
1334  buffer = (char *) malloc (packed_size);
1335  if (buffer == NULL)
1336  {
1337  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) packed_size);
1338  return ER_FAILED;
1339  }
1340 
1341  ptr = buffer;
1342  ptr = or_pack_int (ptr, 0);
1343 
1344  if (locator_pack_oid_set (ptr, oidset) == NULL)
1345  {
1346  free_and_init (buffer);
1347  return ER_FAILED;
1348  }
1349 
1350  req_error =
1351  net_client_request (NET_SERVER_LC_ASSIGN_OID_BATCH, buffer, packed_size, buffer, packed_size, NULL, 0, NULL, 0);
1352 
1353  if (!req_error)
1354  {
1355  ptr = buffer;
1356  ptr = or_unpack_int (ptr, &success);
1357  if (success == NO_ERROR)
1358  {
1359  if (locator_unpack_oid_set_to_exist (ptr, oidset) == false)
1360  {
1361  success = ER_FAILED;
1362  }
1363  }
1364  }
1365 
1366  free_and_init (buffer);
1367 
1368  return success;
1369 #else /* CS_MODE */
1370  int success = ER_FAILED;
1371 
1372  THREAD_ENTRY *thread_p = enter_server ();
1373 
1374  success = xlocator_assign_oid_batch (thread_p, oidset);
1375 
1376  exit_server (*thread_p);
1377 
1378  return (success);
1379 #endif /* !CS_MODE */
1380 }
1381 
1382 /*
1383  * locator_find_lockhint_class_oids -
1384  *
1385  * return:
1386  *
1387  * num_classes(in):
1388  * many_classnames(in):
1389  * many_locks(in):
1390  * many_need_subclasses(in):
1391  * many_flags(in):
1392  * guessed_class_oids(in):
1393  * guessed_class_chns(in):
1394  * quit_on_errors(in):
1395  * lock_rr_tran(in):
1396  * lockhint(in):
1397  * fetch_copyarea(in):
1398  *
1399  * NOTE:
1400  */
1402 locator_find_lockhint_class_oids (int num_classes, const char **many_classnames, LOCK * many_locks,
1403  int *many_need_subclasses, LC_PREFETCH_FLAGS * many_flags, OID * guessed_class_oids,
1404  int *guessed_class_chns, int quit_on_errors, LOCK lock_rr_tran,
1405  LC_LOCKHINT ** lockhint, LC_COPYAREA ** fetch_copyarea)
1406 {
1407 #if defined(CS_MODE)
1409  int xallfind;
1410  int req_error;
1411  char *ptr;
1412  int request_size;
1413  char *request, *packed;
1414  int packed_size;
1416  char *reply;
1417  int i;
1418 
1419  reply = OR_ALIGNED_BUF_START (a_reply);
1420 
1421  *lockhint = NULL;
1422  *fetch_copyarea = NULL;
1423 
1424  request_size = OR_INT_SIZE + OR_INT_SIZE + OR_INT_SIZE;
1425  for (i = 0; i < num_classes; i++)
1426  {
1427  request_size += (length_const_string (many_classnames[i], NULL) + OR_INT_SIZE + OR_INT_SIZE + OR_INT_SIZE
1428  + OR_OID_SIZE + OR_INT_SIZE);
1429  }
1430 
1431  request = (char *) malloc (request_size);
1432  if (request == NULL)
1433  {
1434  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
1435  return allfind;
1436  }
1437 
1438  ptr = or_pack_int (request, num_classes);
1439  ptr = or_pack_int (ptr, quit_on_errors);
1440  ptr = or_pack_int (ptr, (int) lock_rr_tran);
1441  for (i = 0; i < num_classes; i++)
1442  {
1443  ptr = pack_const_string (ptr, many_classnames[i]);
1444  ptr = or_pack_lock (ptr, many_locks[i]);
1445  ptr = or_pack_int (ptr, many_need_subclasses[i]);
1446  ptr = or_pack_int (ptr, (int) many_flags[i]);
1447  ptr = or_pack_oid (ptr, &guessed_class_oids[i]);
1448  ptr = or_pack_int (ptr, guessed_class_chns[i]);
1449  }
1450 
1451  req_error =
1453  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &packed, &packed_size, fetch_copyarea);
1454 
1455  if (!req_error)
1456  {
1458  ptr = or_unpack_int (ptr, &xallfind);
1459  allfind = (LC_FIND_CLASSNAME) xallfind;
1460 
1461  if (packed_size > 0 && packed != NULL)
1462  {
1463  *lockhint = locator_allocate_and_unpack_lockhint (packed, packed_size, true, false);
1464  }
1465  else
1466  {
1467  *lockhint = NULL;
1468  }
1469 
1470  if (packed)
1471  {
1472  free_and_init (packed);
1473  }
1474  }
1475  else
1476  {
1477  *lockhint = NULL;
1478  *fetch_copyarea = NULL;
1479  }
1480 
1481  if (request != NULL)
1482  {
1483  free_and_init (request);
1484  }
1485 
1486  tm_Tran_rep_read_lock = lock_rr_tran;
1487 
1488  return allfind;
1489 #else /* CS_MODE */
1491 
1492  THREAD_ENTRY *thread_p = enter_server ();
1493 
1494  allfind =
1495  xlocator_find_lockhint_class_oids (thread_p, num_classes, many_classnames, many_locks, many_need_subclasses,
1496  many_flags, guessed_class_oids, guessed_class_chns, quit_on_errors, lockhint,
1497  fetch_copyarea);
1498 
1499  exit_server (*thread_p);
1500 
1501  return allfind;
1502 #endif /* !CS_MODE */
1503 }
1504 
1505 /*
1506  * locator_fetch_lockhint_classes -
1507  *
1508  * return:
1509  *
1510  * lockhint(in):
1511  * fetch_copyarea(in):
1512  *
1513  * NOTE:
1514  */
1515 int
1517 {
1518 #if defined(CS_MODE)
1519  static int eid; /* TODO: remove static */
1520  int success = ER_FAILED;
1521  int req_error;
1522  char *ptr;
1524  char *reply;
1525  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
1526  char *request;
1527  char *packed = NULL;
1528  int packed_size;
1529  int send_size;
1530 
1531  request = OR_ALIGNED_BUF_START (a_request);
1532  reply = OR_ALIGNED_BUF_START (a_reply);
1533 
1534  *fetch_copyarea = NULL;
1535 
1536  if (lockhint->first_fetch_lockhint_call == true)
1537  {
1538  send_size = locator_pack_lockhint (lockhint, true);
1539 
1540  packed = lockhint->packed;
1541  packed_size = lockhint->packed_size;
1542 
1543  if (!packed)
1544  {
1545  return ER_FAILED;
1546  }
1547 
1548  ptr = or_pack_int (request, send_size);
1549 
1550  req_error =
1552  OR_ALIGNED_BUF_SIZE (a_request), reply, OR_ALIGNED_BUF_SIZE (a_reply),
1553  packed, send_size, packed, packed_size, fetch_copyarea, &eid);
1554  }
1555  else
1556  {
1557  /* Don't need to send the lockhint information any more */
1558  packed = lockhint->packed;
1559  packed_size = lockhint->packed_size;
1560  req_error =
1562  packed_size, fetch_copyarea, eid);
1563  }
1564 
1565  if (!req_error)
1566  {
1568  ptr = or_unpack_int (ptr, &success);
1569  if (success == NO_ERROR)
1570  {
1571  locator_unpack_lockhint (lockhint, lockhint->first_fetch_lockhint_call);
1572  }
1573  }
1574  else
1575  {
1576  *fetch_copyarea = NULL;
1577  }
1578 
1579  lockhint->first_fetch_lockhint_call = false;
1580 
1581  return success;
1582 
1583 #else /* CS_MODE */
1584  int success = ER_FAILED;
1585 
1586  THREAD_ENTRY *thread_p = enter_server ();
1587 
1588  success = xlocator_fetch_lockhint_classes (thread_p, lockhint, fetch_copyarea);
1589 
1590  exit_server (*thread_p);
1591 
1592  return success;
1593 #endif /* !CS_MODE */
1594 }
1595 
1596 /*
1597  * heap_create -
1598  *
1599  * return:
1600  *
1601  * hfid(in):
1602  * class_oid(in):
1603  * reuse_oid(in):
1604  *
1605  * NOTE:
1606  */
1607 int
1608 heap_create (HFID * hfid, const OID * class_oid, bool reuse_oid)
1609 {
1610 #if defined(CS_MODE)
1612  int req_error;
1613  char *ptr;
1615  char *request;
1617  char *reply;
1618 
1619  request = OR_ALIGNED_BUF_START (a_request);
1620  reply = OR_ALIGNED_BUF_START (a_reply);
1621 
1622  ptr = or_pack_hfid (request, hfid);
1623  ptr = or_pack_oid (ptr, (OID *) class_oid);
1624  ptr = or_pack_int (ptr, (int) reuse_oid);
1625  req_error =
1626  net_client_request (NET_SERVER_HEAP_CREATE, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
1627  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1628  if (!req_error)
1629  {
1630  ptr = or_unpack_errcode (reply, &error);
1631  ptr = or_unpack_hfid (ptr, hfid);
1632  }
1633 
1634  return error;
1635 #else /* CS_MODE */
1636  int success;
1637 
1638  THREAD_ENTRY *thread_p = enter_server ();
1639 
1640  success = xheap_create (thread_p, hfid, class_oid, reuse_oid);
1641 
1642  exit_server (*thread_p);
1643 
1644  return success;
1645 #endif /* !CS_MODE */
1646 }
1647 
1648 #if defined(ENABLE_UNUSED_FUNCTION)
1649 /*
1650  * heap_destroy -
1651  *
1652  * return:
1653  *
1654  * hfid(in):
1655  *
1656  * NOTE:
1657  */
1658 int
1659 heap_destroy (const HFID * hfid)
1660 {
1661 #if defined(CS_MODE)
1663  int req_error;
1664  char *ptr;
1665  OR_ALIGNED_BUF (OR_HFID_SIZE) a_request;
1666  char *request;
1667  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1668  char *reply;
1669 
1670  request = OR_ALIGNED_BUF_START (a_request);
1671  reply = OR_ALIGNED_BUF_START (a_reply);
1672 
1673  (void) or_pack_hfid (request, hfid);
1674 
1675  req_error =
1676  net_client_request (NET_SERVER_HEAP_DESTROY, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
1677  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1678  if (!req_error)
1679  {
1680  ptr = or_unpack_errcode (reply, &error);
1681  }
1682 
1683  return error;
1684 #else /* CS_MODE */
1685  int success;
1686 
1687  THREAD_ENTRY *thread_p = enter_server ();
1688 
1689  success = xheap_destroy (thread_p, hfid, NULL);
1690 
1691  exit_server (*thread_p);
1692 
1693  return success;
1694 #endif /* !CS_MODE */
1695 }
1696 #endif /* ENABLE_UNUSED_FUNCTION */
1697 
1698 /*
1699  * heap_destroy_newly_created -
1700  *
1701  * return:
1702  *
1703  * hfid(in):
1704  *
1705  * NOTE:
1706  */
1707 int
1708 heap_destroy_newly_created (const HFID * hfid, const OID * class_oid)
1709 {
1710 #if defined(CS_MODE)
1712  int req_error;
1713  char *ptr;
1714  OR_ALIGNED_BUF (OR_HFID_SIZE + OR_OID_SIZE) a_request;
1715  char *request;
1716  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1717  char *reply;
1718 
1719  request = OR_ALIGNED_BUF_START (a_request);
1720  reply = OR_ALIGNED_BUF_START (a_reply);
1721 
1722  ptr = or_pack_hfid (request, hfid);
1723  ptr = or_pack_oid (ptr, class_oid);
1724 
1725  req_error =
1727  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1728  if (!req_error)
1729  {
1730  ptr = or_unpack_errcode (reply, &error);
1731  }
1732 
1733  return error;
1734 #else /* CS_MODE */
1735  int success = ER_FAILED;
1736 
1737  THREAD_ENTRY *thread_p = enter_server ();
1738 
1739  success = xheap_destroy_newly_created (thread_p, hfid, class_oid);
1740 
1741  exit_server (*thread_p);
1742 
1743  return success;
1744 #endif /* !CS_MODE */
1745 }
1746 
1747 /*
1748  * heap_reclaim_addresses -
1749  *
1750  * return:
1751  *
1752  * hfid(in):
1753  * reclaim_mvcc_next_versions(in):
1754  *
1755  * NOTE:
1756  */
1757 int
1759 {
1760 #if defined(CS_MODE)
1762  int req_error;
1763  char *ptr;
1764  OR_ALIGNED_BUF (OR_HFID_SIZE + OR_INT_SIZE) a_request;
1765  char *request;
1766  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1767  char *reply;
1768 
1769  request = OR_ALIGNED_BUF_START (a_request);
1770  reply = OR_ALIGNED_BUF_START (a_reply);
1771 
1772  ptr = or_pack_hfid (request, hfid);
1773 
1774  req_error =
1776  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1777  if (!req_error)
1778  {
1779  ptr = or_unpack_errcode (reply, &error);
1780  }
1781 
1782  return error;
1783 #else /* CS_MODE */
1784  int success = ER_FAILED;
1785 
1786  THREAD_ENTRY *thread_p = enter_server ();
1787 
1788  success = xheap_reclaim_addresses (thread_p, hfid);
1789 
1790  exit_server (*thread_p);
1791 
1792  return success;
1793 #endif /* !CS_MODE */
1794 }
1795 
1796 /*
1797  * file_apply_tde_to_class_files -
1798  *
1799  * return:
1800  *
1801  * class_oid(in):
1802  *
1803  * NOTE:
1804  */
1805 int
1807 {
1808 #if defined(CS_MODE)
1810  int req_error;
1811  char *ptr;
1812  OR_ALIGNED_BUF (OR_OID_SIZE) a_request;
1813  char *request;
1814  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1815  char *reply;
1816 
1817  request = OR_ALIGNED_BUF_START (a_request);
1818  reply = OR_ALIGNED_BUF_START (a_reply);
1819 
1820  ptr = or_pack_oid (request, class_oid);
1821  req_error =
1823  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
1824  if (!req_error)
1825  {
1826  ptr = or_unpack_errcode (reply, &error);
1827  }
1828 
1829  return error;
1830 #else /* CS_MODE */
1831  int success;
1832 
1833  THREAD_ENTRY *thread_p = enter_server ();
1834 
1835  success = xfile_apply_tde_to_class_files (thread_p, class_oid);
1836 
1837  exit_server (*thread_p);
1838 
1839  return success;
1840 #endif /* !CS_MODE */
1841 }
1842 
1843 #ifdef UNSTABLE_TDE_FOR_REPLICATION_LOG
1844 /*
1845  * tde_get_data_keys -
1846  *
1847  * return:
1848  *
1849  * dks(out):
1850  *
1851  * NOTE:
1852  */
1853 int
1854 tde_get_data_keys ()
1855 {
1856 #if defined(CS_MODE)
1858  int req_error, area_size;
1859  char *ptr;
1861  char *reply, *area;
1862 
1863  reply = OR_ALIGNED_BUF_START (a_reply);
1864 
1865  req_error =
1867  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
1868  if (!req_error)
1869  {
1870  ptr = or_unpack_int (reply, &area_size);
1871  ptr = or_unpack_int (ptr, &error);
1872  if (area_size > 0)
1873  {
1877  }
1878  free_and_init (area);
1879  }
1880 
1881  return error;
1882 #else /* CS_MODE */
1883  return NO_ERROR;
1884 #endif /* !CS_MODE */
1885 }
1886 #endif /* UNSTABLE_TDE_FOR_REPLICATION_LOG */
1887 
1888 /*
1889  * tde_get_mk_file_path -
1890  *
1891  * return:
1892  *
1893  * dks(out):
1894  *
1895  * NOTE:
1896  */
1897 int
1898 tde_get_mk_file_path (char *mk_path)
1899 {
1900 #if defined(CS_MODE)
1902  int req_error, area_size;
1903  char *ptr;
1905  char *reply, *area;
1906  char *path = NULL;
1907 
1908  reply = OR_ALIGNED_BUF_START (a_reply);
1909 
1910  req_error =
1912  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
1913  if (!req_error)
1914  {
1915  ptr = or_unpack_int (reply, &area_size);
1916  ptr = or_unpack_int (ptr, &error);
1917  if (area_size > 0)
1918  {
1919  ptr = or_unpack_string_nocopy (area, &path);
1920  strncpy (mk_path, path, DB_MAX_PATH_LENGTH);
1921  }
1922  free_and_init (area);
1923  }
1924 
1925  return error;
1926 #else /* CS_MODE */
1927  tde_make_keys_file_fullname (mk_path, boot_db_full_name (), false);
1928  return NO_ERROR;
1929 #endif /* !CS_MODE */
1930 }
1931 
1932 /*
1933  * tde_get_set_mk_info -
1934  *
1935  * return:
1936  *
1937  * dks(out):
1938  *
1939  * NOTE:
1940  */
1941 int
1942 tde_get_mk_info (int *mk_index, time_t * created_time, time_t * set_time)
1943 {
1944 #if defined(CS_MODE)
1946  int req_error, area_size;
1947  char *ptr;
1949  char *reply, *area;
1950  char *path = NULL;
1951 
1952  reply = OR_ALIGNED_BUF_START (a_reply);
1953 
1954  req_error =
1956  if (!req_error)
1957  {
1958  ptr = or_unpack_errcode (reply, &error);
1959  ptr = or_unpack_int (ptr, mk_index);
1960  ptr = or_unpack_int64 (ptr, created_time);
1961  ptr = or_unpack_int64 (ptr, set_time);
1962  }
1963 
1964  return error;
1965 #else /* CS_MODE */
1966  int success;
1967 
1968  THREAD_ENTRY *thread_p = enter_server ();
1969 
1970  success = xtde_get_mk_info (thread_p, mk_index, created_time, set_time);
1971 
1972  exit_server (*thread_p);
1973 
1974  return success;
1975 #endif /* !CS_MODE */
1976 }
1977 
1978 /*
1979  * tde_change_mk_server -
1980  *
1981  * return:
1982  *
1983  * dks(out):
1984  *
1985  * NOTE:
1986  */
1987 int
1989 {
1990 #if defined(CS_MODE)
1992  int req_error;
1993  char *ptr;
1994  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
1995  char *request;
1996  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1997  char *reply;
1998 
1999  request = OR_ALIGNED_BUF_START (a_request);
2000  reply = OR_ALIGNED_BUF_START (a_reply);
2001 
2002  ptr = or_pack_int (request, mk_index);
2003  req_error =
2005  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2006  if (!req_error)
2007  {
2008  ptr = or_unpack_errcode (reply, &error);
2009  }
2010 
2011  return error;
2012 #else /* CS_MODE */
2013  int success;
2014 
2015  THREAD_ENTRY *thread_p = enter_server ();
2016 
2017  success = xtde_change_mk_without_flock (thread_p, mk_index);
2018 
2019  exit_server (*thread_p);
2020 
2021  return success;
2022 #endif /* !CS_MODE */
2023 }
2024 
2025 /*
2026  * disk_get_total_numpages -
2027  *
2028  * return:
2029  *
2030  * volid(in):
2031  *
2032  * NOTE:
2033  */
2034 DKNPAGES
2036 {
2037 #if defined(CS_MODE)
2038  DKNPAGES npages = 0;
2039  int req_error;
2040  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2041  char *request;
2042  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2043  char *reply;
2044 
2045  request = OR_ALIGNED_BUF_START (a_request);
2046  reply = OR_ALIGNED_BUF_START (a_reply);
2047 
2048  (void) or_pack_int (request, (int) volid);
2049 
2050  req_error =
2051  net_client_request (NET_SERVER_DISK_TOTALPGS, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
2052  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2053  if (!req_error)
2054  {
2055  (void) or_unpack_int (reply, &npages);
2056  }
2057 
2058  return npages;
2059 #else /* CS_MODE */
2060  DKNPAGES npages = 0;
2061 
2062  THREAD_ENTRY *thread_p = enter_server ();
2063 
2064  npages = xdisk_get_total_numpages (thread_p, volid);
2065 
2066  exit_server (*thread_p);
2067 
2068  return npages;
2069 #endif /* !CS_MODE */
2070 }
2071 
2072 /*
2073  * disk_get_free_numpages -
2074  *
2075  * return:
2076  *
2077  * volid(in):
2078  *
2079  * NOTE:
2080  */
2081 DKNPAGES
2083 {
2084 #if defined(CS_MODE)
2085  DKNPAGES npages = 0;
2086  int req_error;
2087  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2088  char *request;
2089  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2090  char *reply;
2091 
2092  request = OR_ALIGNED_BUF_START (a_request);
2093  reply = OR_ALIGNED_BUF_START (a_reply);
2094 
2095  (void) or_pack_int (request, (int) volid);
2096 
2097  req_error =
2098  net_client_request (NET_SERVER_DISK_FREEPGS, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
2099  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2100  if (!req_error)
2101  {
2102  (void) or_unpack_int (reply, &npages);
2103  }
2104 
2105  return npages;
2106 
2107 #else /* CS_MODE */
2108  DKNPAGES npages = 0;
2109 
2110  THREAD_ENTRY *thread_p = enter_server ();
2111 
2112  npages = xdisk_get_free_numpages (thread_p, volid);
2113 
2114  exit_server (*thread_p);
2115 
2116  return npages;
2117 #endif /* !CS_MODE */
2118 }
2119 
2120 /*
2121  * disk_get_remarks -
2122  *
2123  * return:
2124  *
2125  * volid(in):
2126  *
2127  * NOTE:
2128  */
2129 char *
2131 {
2132 #if defined(CS_MODE)
2133  int req_error;
2134  char *area = NULL;
2135  int area_size;
2136  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2137  char *request;
2138  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2139  char *reply;
2140  char *remark = NULL, *p = NULL;
2141 
2142  request = OR_ALIGNED_BUF_START (a_request);
2143  reply = OR_ALIGNED_BUF_START (a_reply);
2144 
2145  (void) or_pack_int (request, (int) volid);
2146 
2147  req_error =
2148  net_client_request2 (NET_SERVER_DISK_REMARKS, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
2149  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
2150  if (!req_error && area != NULL)
2151  {
2152  or_unpack_int (reply, &area_size);
2153  or_unpack_string_nocopy (area, &p);
2154  if (p != NULL)
2155  {
2156  remark = strdup (p);
2157  }
2158  free_and_init (area);
2159  }
2160 
2161  return remark;
2162 #else /* CS_MODE */
2163  char *remark = NULL;
2164 
2165  THREAD_ENTRY *thread_p = enter_server ();
2166 
2167  remark = xdisk_get_remarks (thread_p, volid);
2168 
2169  exit_server (*thread_p);
2170 
2171  return remark;
2172 #endif /* !CS_MODE */
2173 }
2174 
2175 /*
2176  * disk_get_fullname -
2177  *
2178  * return:
2179  *
2180  * volid(in):
2181  * vol_fullname(in):
2182  *
2183  * NOTE:
2184  */
2185 char *
2186 disk_get_fullname (VOLID volid, char *vol_fullname)
2187 {
2188 #if defined(CS_MODE)
2189  int req_error;
2190  char *area = NULL;
2191  int area_size;
2192  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2193  char *request;
2194  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2195  char *reply;
2196  char *name = NULL;
2197 
2198  request = OR_ALIGNED_BUF_START (a_request);
2199  reply = OR_ALIGNED_BUF_START (a_reply);
2200 
2201  (void) or_pack_int (request, (int) volid);
2202 
2203  req_error =
2204  net_client_request2 (NET_SERVER_DISK_VLABEL, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
2205  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
2206  if (!req_error && area != NULL)
2207  {
2208  or_unpack_int (reply, &area_size);
2209  or_unpack_string_nocopy (area, &name);
2210  if (name != NULL)
2211  {
2212  strcpy (vol_fullname, name);
2213  }
2214  free_and_init (area);
2215  }
2216  else
2217  {
2218  vol_fullname = NULL;
2219  }
2220 
2221  return vol_fullname;
2222 #else /* CS_MODE */
2223 
2224  THREAD_ENTRY *thread_p = enter_server ();
2225 
2226  vol_fullname = xdisk_get_fullname (thread_p, volid, vol_fullname);
2227 
2228  exit_server (*thread_p);
2229 
2230  return vol_fullname;
2231 #endif /* !CS_MODE */
2232 }
2233 
2234 /*
2235  * log_reset_wait_msecs -
2236  *
2237  * return:
2238  *
2239  * wait_msecs(in): in milliseconds
2240  *
2241  * NOTE:
2242  */
2243 int
2244 log_reset_wait_msecs (int wait_msecs)
2245 {
2246 #if defined(CS_MODE)
2247  int wait = -1;
2248  int req_error;
2249  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2250  char *request;
2251  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2252  char *reply;
2253 
2254  request = OR_ALIGNED_BUF_START (a_request);
2255  reply = OR_ALIGNED_BUF_START (a_reply);
2256 
2257  (void) or_pack_int (request, wait_msecs);
2258 
2259  req_error =
2261  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2262  if (!req_error)
2263  {
2264  (void) or_unpack_int (reply, &wait);
2265  }
2266 
2267  return wait;
2268 #else /* CS_MODE */
2269  int wait = -1;
2270 
2271  THREAD_ENTRY *thread_p = enter_server ();
2272 
2273  wait = xlogtb_reset_wait_msecs (thread_p, wait_msecs);
2274 
2275  exit_server (*thread_p);
2276 
2277  return wait;
2278 #endif /* !CS_MODE */
2279 }
2280 
2281 /*
2282  * log_reset_isolation -
2283  *
2284  * return:
2285  *
2286  * isolation(in):
2287  *
2288  * NOTE:
2289  */
2290 int
2292 {
2293 #if defined(CS_MODE)
2294  int req_error, error_code = ER_NET_CLIENT_DATA_RECEIVE;
2295  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2296  char *request, *ptr;
2297  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2298  char *reply;
2299 
2300  request = OR_ALIGNED_BUF_START (a_request);
2301  reply = OR_ALIGNED_BUF_START (a_reply);
2302 
2303  ptr = or_pack_int (request, (int) isolation);
2304 
2305  req_error =
2307  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2308  if (!req_error)
2309  {
2310  or_unpack_int (reply, &error_code);
2311  }
2312 
2313  return error_code;
2314 #else /* CS_MODE */
2315  int error_code = NO_ERROR;
2316 
2317  THREAD_ENTRY *thread_p = enter_server ();
2318 
2319  error_code = xlogtb_reset_isolation (thread_p, isolation);
2320 
2321  exit_server (*thread_p);
2322 
2323  return error_code;
2324 #endif /* !CS_MODE */
2325 }
2326 
2327 /*
2328  * log_set_interrupt -
2329  *
2330  * return:
2331  *
2332  * set(in):
2333  *
2334  * NOTE:
2335  */
2336 void
2338 {
2339 #if defined(CS_MODE)
2340  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2341  char *request;
2342 
2343  request = OR_ALIGNED_BUF_START (a_request);
2344  or_pack_int (request, set);
2345 
2347 #else /* CS_MODE */
2348 
2349  THREAD_ENTRY *thread_p = enter_server ();
2350 
2351  xlogtb_set_interrupt (thread_p, set);
2352 
2353  exit_server (*thread_p);
2354 #endif /* !CS_MODE */
2355 }
2356 
2357 /*
2358  * log_checkpoint -
2359  *
2360  * return:
2361  *
2362  * NOTE:
2363  */
2364 int
2366 {
2367 #if defined(CS_MODE)
2369  int req_error;
2370  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2371  char *reply;
2372 
2373  reply = OR_ALIGNED_BUF_START (a_reply);
2374 
2375  req_error =
2377  if (!req_error)
2378  {
2379  or_unpack_errcode (reply, &error);
2380  }
2381 
2382  return error;
2383 #else /* CS_MODE */
2384  /* Cannot run in standalone mode */
2386 
2387  return ER_NOT_IN_STANDALONE;
2388 #endif /* !CS_MODE */
2389 }
2390 
2391 /*
2392  * log_dump_stat -
2393  *
2394  * return:
2395  *
2396  * outfp(in):
2397  *
2398  * NOTE:
2399  */
2400 void
2401 log_dump_stat (FILE * outfp)
2402 {
2403 #if defined(CS_MODE)
2404  int req_error;
2405 
2406  if (outfp == NULL)
2407  {
2408  outfp = stdout;
2409  }
2410 
2411  req_error = net_client_request_recv_stream (NET_SERVER_LOG_DUMP_STAT, NULL, 0, NULL, 0, NULL, 0, outfp);
2412 #else /* CS_MODE */
2413 
2414  THREAD_ENTRY *thread_p = enter_server ();
2415 
2416  xlogpb_dump_stat (outfp);
2417 
2418  exit_server (*thread_p);
2419 #endif /* !CS_MODE */
2420 }
2421 
2422 /*
2423  * log_set_suppress_repl_on_transaction -
2424  *
2425  * return:
2426  *
2427  * set(in):
2428  *
2429  * NOTE:
2430  */
2431 int
2433 {
2434 #if defined(CS_MODE)
2435  int req_error = NO_ERROR;
2436  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2437  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2438  char *request, *reply;
2439 
2440  request = OR_ALIGNED_BUF_START (a_request);
2441  or_pack_int (request, set);
2442 
2443  reply = OR_ALIGNED_BUF_START (a_reply);
2444 
2445  req_error =
2447  reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2448 
2449  if (req_error == NO_ERROR)
2450  {
2451  or_unpack_int (reply, &req_error);
2452  }
2453 
2454  return req_error;
2455 #else /* CS_MODE */
2456  THREAD_ENTRY *thread_p = enter_server ();
2457 
2459 
2460  exit_server (*thread_p);
2461 
2462  return NO_ERROR;
2463 #endif /* !CS_MODE */
2464 }
2465 
2466 #if defined(CS_MODE)
2467 /*
2468  * log_find_lob_locator -
2469  *
2470  * return:
2471  *
2472  * locator(in):
2473  * real_locator(out):
2474  *
2475  * NOTE:
2476  */
2478 log_find_lob_locator (const char *locator, char *real_locator)
2479 {
2481  int req_error, state_int, request_size, strlen;
2482  char *request, *reply, *ptr;
2484  int real_loc_size;
2485 
2486  reply = OR_ALIGNED_BUF_START (a_reply);
2487 
2488  request_size = length_const_string (locator, &strlen);
2489  request = (char *) malloc (request_size);
2490  if (request == NULL)
2491  {
2492  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
2493  return LOB_UNKNOWN;
2494  }
2495 
2496  (void) pack_const_string_with_length (request, locator, strlen);
2497  req_error = net_client_request2_no_malloc (NET_SERVER_LOG_FIND_LOB_LOCATOR, request, request_size, reply,
2498  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, real_locator, &real_loc_size);
2499  if (!req_error)
2500  {
2501  ptr = or_unpack_int (reply, &real_loc_size);
2502  (void) or_unpack_int (ptr, &state_int);
2503  state = (LOB_LOCATOR_STATE) state_int;
2504  }
2505  free_and_init (request);
2506 
2507  return state;
2508 }
2509 
2510 /*
2511  * log_add_lob_locator -
2512  *
2513  * return: NO_ERROR or error status
2514  *
2515  * locator(in):
2516  * state(in);
2517  *
2518  * NOTE:
2519  */
2520 int
2521 log_add_lob_locator (const char *locator, LOB_LOCATOR_STATE state)
2522 {
2523  int req_error, error_code = ER_FAILED, request_size, strlen;
2524  char *request, *reply;
2525  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2526  char *ptr;
2527 
2528  reply = OR_ALIGNED_BUF_START (a_reply);
2529 
2530  request_size = length_const_string (locator, &strlen) + OR_INT_SIZE;
2531  request = (char *) malloc (request_size);
2532  if (request == NULL)
2533  {
2534  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
2535  return ER_OUT_OF_VIRTUAL_MEMORY;
2536  }
2537 
2538  ptr = pack_const_string_with_length (request, locator, strlen);
2539  ptr = or_pack_int (ptr, (int) state);
2540  req_error = net_client_request (NET_SERVER_LOG_ADD_LOB_LOCATOR, request, request_size, reply,
2541  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2542  if (!req_error)
2543  {
2544  or_unpack_int (reply, &error_code);
2545  }
2546  free_and_init (request);
2547 
2548  return error_code;
2549 }
2550 
2551 /*
2552  * log_change_state_of_locator -
2553  *
2554  * return: NO_ERROR or error status
2555  *
2556  * locator(in):
2557  * state(in);
2558  *
2559  * NOTE:
2560  */
2561 int
2562 log_change_state_of_locator (const char *locator, const char *new_locator, LOB_LOCATOR_STATE state)
2563 {
2564  int req_error, error_code = ER_NET_CLIENT_DATA_RECEIVE;
2565  int request_size, strlen, strlen2;
2566  char *request, *reply;
2567  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2568  char *ptr;
2569 
2570  reply = OR_ALIGNED_BUF_START (a_reply);
2571 
2572  request_size = length_const_string (locator, &strlen) + length_const_string (new_locator, &strlen2) + OR_INT_SIZE;
2573  request = (char *) malloc (request_size);
2574  if (request == NULL)
2575  {
2576  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
2577  return ER_OUT_OF_VIRTUAL_MEMORY;
2578  }
2579 
2580  ptr = pack_const_string_with_length (request, locator, strlen);
2581  ptr = pack_const_string_with_length (ptr, new_locator, strlen2);
2582  ptr = or_pack_int (ptr, (int) state);
2583  req_error = net_client_request (NET_SERVER_LOG_CHANGE_STATE_OF_LOCATOR, request, request_size, reply,
2584  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2585  if (!req_error)
2586  {
2587  or_unpack_int (reply, &error_code);
2588  }
2589  free_and_init (request);
2590 
2591  return error_code;
2592 }
2593 
2594 /*
2595  * log_drop_lob_locator -
2596  *
2597  * return: NO_ERROR or error status
2598  *
2599  * locator(in):
2600  *
2601  * NOTE:
2602  */
2603 int
2604 log_drop_lob_locator (const char *locator)
2605 {
2606  int req_error, error_code = ER_NET_CLIENT_DATA_RECEIVE;
2607  int request_size, strlen;
2608  char *request, *reply;
2609  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2610  char *ptr;
2611 
2612  reply = OR_ALIGNED_BUF_START (a_reply);
2613 
2614  request_size = length_const_string (locator, &strlen);
2615  request = (char *) malloc (request_size);
2616  if (request == NULL)
2617  {
2618  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
2619  return ER_OUT_OF_VIRTUAL_MEMORY;
2620  }
2621 
2622  ptr = pack_const_string_with_length (request, locator, strlen);
2623  req_error = net_client_request (NET_SERVER_LOG_DROP_LOB_LOCATOR, request, request_size, reply,
2624  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2625  if (!req_error)
2626  {
2627  or_unpack_int (reply, &error_code);
2628  }
2629  free_and_init (request);
2630 
2631  return error_code;
2632 }
2633 #endif // CS_MODE
2634 
2635 /*
2636  * tran_server_commit -
2637  *
2638  * return:
2639  *
2640  * retain_lock(in):
2641  *
2642  * NOTE:
2643  */
2644 TRAN_STATE
2645 tran_server_commit (bool retain_lock)
2646 {
2647 #if defined(CS_MODE)
2648  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
2649  int req_error, tran_state_int, should_conn_reset;
2650  int i = 0;
2651  char *ptr;
2652  OR_ALIGNED_BUF (OR_INT_SIZE /* retain_lock */
2653  + OR_INT_SIZE /* row_count */
2654  + OR_INT_SIZE /* count of end query requests */
2655  + OR_PTR_SIZE * NET_DEFER_END_QUERIES_MAX /* query ids */
2656  + MAX_ALIGNMENT /* aligmnent */
2657  )a_request;
2658  char *request;
2660  char *reply;
2661  int row_count = 0;
2662 
2663  request = OR_ALIGNED_BUF_START (a_request);
2664  reply = OR_ALIGNED_BUF_START (a_reply);
2665 
2666  /* Pack retain_lock */
2667  ptr = or_pack_int (request, (int) retain_lock);
2668  /* Pack row_count */
2669  row_count = db_get_row_count_cache ();
2670  ptr = or_pack_int (ptr, row_count);
2671  /* Pack query ids to end */
2672  assert (net_Deferred_end_queries_count <= NET_DEFER_END_QUERIES_MAX);
2673  ptr = or_pack_int (ptr, net_Deferred_end_queries_count);
2674  for (i = 0; i < net_Deferred_end_queries_count; i++)
2675  {
2676  ptr = or_pack_ptr (ptr, net_Deferred_end_queries[i]);
2677  }
2678  net_Deferred_end_queries_count = 0;
2679  assert (CAST_BUFLEN (ptr - request) <= (int) OR_ALIGNED_BUF_SIZE (a_request));
2680 
2681  req_error =
2682  net_client_request (NET_SERVER_TM_SERVER_COMMIT, request, CAST_BUFLEN (ptr - request), reply,
2683  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2684  if (!req_error)
2685  {
2686  ptr = or_unpack_int (reply, &tran_state_int);
2687  tran_state = (TRAN_STATE) tran_state_int;
2688  ptr = or_unpack_int (ptr, &should_conn_reset);
2689  if (should_conn_reset != 0 && log_does_allow_replication ())
2690  {
2691  /*
2692  * fail-back action
2693  * make the client to reconnect to the active server
2694  */
2696  er_log_debug (ARG_FILE_LINE, "tran_server_commit: DB_CONNECTION_STATUS_RESET\n");
2697  }
2698  }
2699 
2701 
2702  return tran_state;
2703 #else /* CS_MODE */
2704  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
2705 
2706  THREAD_ENTRY *thread_p = enter_server ();
2707 
2708  tran_state = xtran_server_commit (thread_p, retain_lock);
2709 
2710  exit_server (*thread_p);
2711 
2712  return tran_state;
2713 #endif /* !CS_MODE */
2714 }
2715 
2716 /*
2717  * tran_server_abort -
2718  *
2719  * return:
2720  *
2721  * NOTE:
2722  */
2723 TRAN_STATE
2725 {
2726 #if defined(CS_MODE)
2727  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
2728  int req_error, tran_state_int, should_conn_reset;
2729  char *ptr;
2731  char *reply;
2732 
2733  reply = OR_ALIGNED_BUF_START (a_reply);
2734 
2735  /* Queries will be aborted. */
2736  net_Deferred_end_queries_count = 0;
2737 
2738  req_error =
2740  if (!req_error)
2741  {
2742  ptr = or_unpack_int (reply, &tran_state_int);
2743  tran_state = (TRAN_STATE) tran_state_int;
2744  ptr = or_unpack_int (ptr, &should_conn_reset);
2745  if (should_conn_reset != 0 && log_does_allow_replication ())
2746  {
2747  /*
2748  * fail-back action
2749  * make the client to reconnect to the active server
2750  */
2752  er_log_debug (ARG_FILE_LINE, "tran_server_abort: DB_CONNECTION_STATUS_RESET\n");
2753  }
2754  }
2755 
2757 
2758  return tran_state;
2759 #else /* CS_MODE */
2760  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
2761 
2762  THREAD_ENTRY *thread_p = enter_server ();
2763 
2764  tran_state = xtran_server_abort (thread_p);
2765 
2766  exit_server (*thread_p);
2767 
2768  return tran_state;
2769 #endif /* !CS_MODE */
2770 }
2771 
2772 const char *
2774 {
2775  // You should also change the messages:
2776  // MSGCAT_UTIL_SET_TRANLIST.TRANLIST_MSG_QUERY_INFO_ENTRY, MSGCAT_UTIL_SET_TRANLIST.TRANLIST_MSG_FULL_INFO_ENTRY,
2777  // MSGCAT_UTIL_SET_TRANLIST.TRANLIST_MSG_SUMMARY_ENTRY and their headings and underscores,
2778  // when you add a state longer than the current longest, "(COMMITTING)".
2779 
2780  switch (state)
2781  {
2782  case TRAN_RECOVERY:
2783  return "(RECOVERY)";
2784  case TRAN_ACTIVE:
2785  return "(ACTIVE)";
2787  return "(COMMITTED)";
2789  return "(COMMITTING)";
2791  return "(COMMITTED1)";
2793  return "(COMMITTED3)";
2794  case TRAN_UNACTIVE_ABORTED:
2795  return "(ABORTED)";
2797  return "(KILLED)";
2799  return "(2PC1)";
2801  return "(2PC2)";
2803  return "(2PC3)";
2805  return "(2PC4)";
2807  return "(COMMITTED5)";
2809  return "(ABORTED3)";
2810  case TRAN_UNACTIVE_UNKNOWN:
2811  default:
2812  return "(UNKNOWN)";
2813  }
2814 
2815  return "(UNKNOWN)";
2816 }
2817 
2818 /*
2819  * tran_is_blocked -
2820  *
2821  * return:
2822  *
2823  * tran_index(in):
2824  *
2825  * NOTE:
2826  */
2827 bool
2828 tran_is_blocked (int tran_index)
2829 {
2830 #if defined(CS_MODE)
2831  bool blocked = false;
2832  int req_error;
2833  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
2834  char *request;
2835  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2836  char *reply;
2837  int temp;
2838 
2839  request = OR_ALIGNED_BUF_START (a_request);
2840  reply = OR_ALIGNED_BUF_START (a_reply);
2841 
2842  (void) or_pack_int (request, tran_index);
2843 
2844  req_error =
2845  net_client_request (NET_SERVER_TM_ISBLOCKED, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
2846  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
2847  if (!req_error)
2848  {
2849  (void) or_unpack_int (reply, &temp);
2850  blocked = (temp == 1) ? true : false;
2851  }
2852 
2853  return blocked;
2854 #else /* CS_MODE */
2855  bool blocked = false;
2856 
2857  THREAD_ENTRY *thread_p = enter_server ();
2858 
2859  blocked = xtran_is_blocked (thread_p, tran_index);
2860 
2861  exit_server (*thread_p);
2862 
2863  return blocked;
2864 #endif /* !CS_MODE */
2865 }
2866 
2867 /*
2868  * tran_server_has_updated -
2869  *
2870  * return:
2871  *
2872  * NOTE:
2873  */
2874 int
2876 {
2877 #if defined(CS_MODE)
2878  int has_updated = 0; /* TODO */
2879  int req_error;
2880  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2881  char *reply;
2882 
2883  reply = OR_ALIGNED_BUF_START (a_reply);
2884 
2885  req_error =
2887  0);
2888  if (!req_error)
2889  {
2890  or_unpack_int (reply, &has_updated);
2891  }
2892 
2893  return has_updated;
2894 #else /* CS_MODE */
2895  int has_updated = 0; /* TODO */
2896 
2897  THREAD_ENTRY *thread_p = enter_server ();
2898 
2899  has_updated = xtran_server_has_updated (thread_p);
2900 
2901  exit_server (*thread_p);
2902 
2903  return has_updated;
2904 #endif /* !CS_MODE */
2905 }
2906 
2907 /*
2908  * tran_server_is_active_and_has_updated -
2909  *
2910  * return:
2911  *
2912  * NOTE:
2913  */
2914 int
2916 {
2917 #if defined(CS_MODE)
2918  int isactive_and_has_updated = 0; /* TODO */
2919  int req_error;
2920  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2921  char *reply;
2922 
2923  reply = OR_ALIGNED_BUF_START (a_reply);
2924 
2925  req_error =
2927  NULL, 0, NULL, 0);
2928  if (!req_error)
2929  {
2930  or_unpack_int (reply, &isactive_and_has_updated);
2931  }
2932 
2933  return isactive_and_has_updated;
2934 #else /* CS_MODE */
2935  int isactive_and_has_updated = 0; /* TODO */
2936 
2937  if (!BO_IS_SERVER_RESTARTED ())
2938  {
2939  // server is killed already
2940  return 0;
2941  }
2942 
2943  THREAD_ENTRY *thread_p = enter_server ();
2944 
2945  isactive_and_has_updated = xtran_server_is_active_and_has_updated (thread_p);
2946 
2947  exit_server (*thread_p);
2948 
2949  return (isactive_and_has_updated);
2950 #endif /* !CS_MODE */
2951 }
2952 
2953 /*
2954  * tran_wait_server_active_trans -
2955  *
2956  * return:
2957  *
2958  * NOTE:
2959  */
2960 int
2962 {
2963 #if defined(CS_MODE)
2964  int status = 0;
2965  int req_error;
2966  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2967  char *reply;
2968 
2969  reply = OR_ALIGNED_BUF_START (a_reply);
2970 
2971  req_error =
2973  NULL, 0);
2974  if (!req_error)
2975  {
2976  or_unpack_int (reply, &status);
2977  }
2978 
2979  return status;
2980 #else /* CS_MODE */
2981  return 0;
2982 #endif /* !CS_MODE */
2983 }
2984 
2985 /*
2986  * tran_server_set_global_tran_info -
2987  *
2988  * return:
2989  *
2990  * gtrid(in):
2991  * info(in):
2992  * size(in):
2993  *
2994  * NOTE:
2995  */
2996 int
2997 tran_server_set_global_tran_info (int gtrid, void *info, int size)
2998 {
2999 #if defined(CS_MODE)
3000  int success = ER_FAILED;
3001  int req_error;
3002  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
3003  char *request;
3004  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3005  char *reply;
3006 
3007  request = OR_ALIGNED_BUF_START (a_request);
3008  reply = OR_ALIGNED_BUF_START (a_reply);
3009 
3010  or_pack_int (request, gtrid);
3011 
3012  req_error =
3014  OR_ALIGNED_BUF_SIZE (a_reply), (char *) info, size, NULL, 0);
3015  if (!req_error)
3016  {
3017  or_unpack_int (reply, &success);
3018  }
3019 
3020  return success;
3021 #else /* CS_MODE */
3022  int success;
3023 
3024  THREAD_ENTRY *thread_p = enter_server ();
3025 
3026  success = xtran_server_set_global_tran_info (thread_p, gtrid, info, size);
3027 
3028  exit_server (*thread_p);
3029 
3030  return success;
3031 #endif /* !CS_MODE */
3032 }
3033 
3034 /*
3035  * tran_server_get_global_tran_info -
3036  *
3037  * return:
3038  *
3039  * gtrid(in):
3040  * buffer(in):
3041  * size(in):
3042  *
3043  * NOTE:
3044  */
3045 int
3046 tran_server_get_global_tran_info (int gtrid, void *buffer, int size)
3047 {
3048 #if defined(CS_MODE)
3049  int success = ER_FAILED;
3050  int req_error;
3051  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_request;
3052  char *request;
3053  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
3054  char *reply, *ptr;
3055 
3056  request = OR_ALIGNED_BUF_START (a_request);
3057  reply = OR_ALIGNED_BUF_START (a_reply);
3058 
3059  ptr = or_pack_int (request, gtrid);
3060  ptr = or_pack_int (ptr, size);
3061  req_error =
3063  OR_ALIGNED_BUF_SIZE (a_reply), (char *) buffer, size, (char *) buffer, &size);
3064  if (!req_error)
3065  {
3066  ptr = or_unpack_int (reply, &size);
3067  ptr = or_unpack_int (ptr, &success);
3068  }
3069 
3070  return success;
3071 
3072 #else /* CS_MODE */
3073  int success;
3074 
3075  THREAD_ENTRY *thread_p = enter_server ();
3076 
3077  success = xtran_server_get_global_tran_info (thread_p, gtrid, buffer, size);
3078 
3079  exit_server (*thread_p);
3080 
3081  return success;
3082 #endif /* !CS_MODE */
3083 }
3084 
3085 /*
3086  * tran_server_2pc_start -
3087  *
3088  * return:
3089  *
3090  * NOTE:
3091  */
3092 int
3094 {
3095 #if defined(CS_MODE)
3096  int gtrid = NULL_TRANID;
3097  int req_error;
3098  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3099  char *reply;
3100 
3101  reply = OR_ALIGNED_BUF_START (a_reply);
3102 
3103  req_error =
3105  0);
3106  if (!req_error)
3107  {
3108  or_unpack_int (reply, &gtrid);
3109  }
3110 
3111  return gtrid;
3112 #else /* CS_MODE */
3113  int gtrid = NULL_TRANID;
3114 
3115  THREAD_ENTRY *thread_p = enter_server ();
3116 
3117  gtrid = xtran_server_2pc_start (thread_p);
3118 
3119  exit_server (*thread_p);
3120 
3121  return gtrid;
3122 #endif /* !CS_MODE */
3123 }
3124 
3125 /*
3126  * tran_server_2pc_prepare -
3127  *
3128  * return:
3129  *
3130  * NOTE:
3131  */
3132 TRAN_STATE
3134 {
3135 #if defined(CS_MODE)
3137  int req_error;
3138  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3139  char *reply;
3140 
3141  reply = OR_ALIGNED_BUF_START (a_reply);
3142 
3143  req_error =
3145  0);
3146  if (!req_error)
3147  {
3148  or_unpack_int (reply, (int *) &state);
3149  }
3150 
3151  return state;
3152 #else /* CS_MODE */
3154 
3155  THREAD_ENTRY *thread_p = enter_server ();
3156 
3157  state = xtran_server_2pc_prepare (thread_p);
3158 
3159  exit_server (*thread_p);
3160 
3161  return (state);
3162 #endif /* !CS_MODE */
3163 }
3164 
3165 /*
3166  * tran_server_2pc_recovery_prepared -
3167  *
3168  * return:
3169  *
3170  * gtrids(in):
3171  * size(in):
3172  *
3173  * NOTE:
3174  */
3175 int
3176 tran_server_2pc_recovery_prepared (int gtrids[], int size)
3177 {
3178 #if defined(CS_MODE)
3179  int count = -1, i;
3180  int req_error;
3181  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
3182  char *request;
3183  int reply_size;
3184  char *reply, *ptr;
3185 
3186  request = OR_ALIGNED_BUF_START (a_request);
3187  reply_size = OR_INT_SIZE + (OR_INT_SIZE * size);
3188  reply = (char *) malloc (reply_size);
3189  if (reply == NULL)
3190  {
3191  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) reply_size);
3192  return -1;
3193  }
3194 
3195  or_pack_int (request, size);
3196 
3198  reply, reply_size, NULL, 0, NULL, 0);
3199  if (!req_error)
3200  {
3201  ptr = or_unpack_int (reply, &count);
3202  for (i = 0; i < count && i < size; i++)
3203  {
3204  ptr = or_unpack_int (ptr, &gtrids[i]);
3205  }
3206  }
3207  free_and_init (reply);
3208 
3209  return count;
3210 #else /* CS_MODE */
3211  int count;
3212 
3213  THREAD_ENTRY *thread_p = enter_server ();
3214 
3215  count = xtran_server_2pc_recovery_prepared (thread_p, gtrids, size);
3216 
3217  exit_server (*thread_p);
3218 
3219  return count;
3220 #endif /* !CS_MODE */
3221 }
3222 
3223 /*
3224  * tran_server_2pc_attach_global_tran -
3225  *
3226  * return:
3227  *
3228  * gtrid(in):
3229  *
3230  * NOTE:
3231  */
3232 int
3234 {
3235 #if defined(CS_MODE)
3236  int tran_index = NULL_TRAN_INDEX;
3237  int req_error;
3238  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
3239  char *request;
3240  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3241  char *reply;
3242 
3243  request = OR_ALIGNED_BUF_START (a_request);
3244  reply = OR_ALIGNED_BUF_START (a_reply);
3245 
3246  or_pack_int (request, gtrid);
3247 
3248  req_error =
3250  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
3251  if (!req_error)
3252  {
3253  or_unpack_int (reply, &tran_index);
3254  }
3255 
3256  return tran_index;
3257 #else /* CS_MODE */
3258  int tran_index = NULL_TRAN_INDEX;
3259 
3260  THREAD_ENTRY *thread_p = enter_server ();
3261 
3262  tran_index = xtran_server_2pc_attach_global_tran (thread_p, gtrid);
3263 
3264  exit_server (*thread_p);
3265 
3266  return tran_index;
3267 #endif /* !CS_MODE */
3268 }
3269 
3270 /*
3271  * tran_server_2pc_prepare_global_tran -
3272  *
3273  * return:
3274  *
3275  * gtrid(in):
3276  *
3277  * NOTE:
3278  */
3279 TRAN_STATE
3281 {
3282 #if defined(CS_MODE)
3283  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
3284  int req_error, tran_state_int;
3285  char *ptr;
3286  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
3287  char *request;
3288  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3289  char *reply;
3290 
3291  request = OR_ALIGNED_BUF_START (a_request);
3292  reply = OR_ALIGNED_BUF_START (a_reply);
3293 
3294  or_pack_int (request, gtrid);
3295  req_error =
3297  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
3298  if (!req_error)
3299  {
3300  ptr = or_unpack_int (reply, &tran_state_int);
3301  tran_state = (TRAN_STATE) tran_state_int;
3302  }
3303 
3304  return tran_state;
3305 #else /* CS_MODE */
3306  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
3307 
3308  THREAD_ENTRY *thread_p = enter_server ();
3309 
3310  tran_state = xtran_server_2pc_prepare_global_tran (thread_p, gtrid);
3311 
3312  exit_server (*thread_p);
3313 
3314  return tran_state;
3315 #endif /* !CS_MODE */
3316 }
3317 
3318 #if defined (ENABLE_UNUSED_FUNCTION)
3319 /*
3320  * tran_server_start_topop -
3321  *
3322  * return:
3323  *
3324  * topop_lsa(in):
3325  *
3326  * NOTE:
3327  */
3328 int
3329 tran_server_start_topop (LOG_LSA * topop_lsa)
3330 {
3331 #if defined(CS_MODE)
3332  int success = ER_FAILED;
3333  int req_error;
3335  char *reply;
3336  char *ptr;
3337 
3338  reply = OR_ALIGNED_BUF_START (a_reply);
3339 
3340  req_error =
3342  0);
3343  if (!req_error)
3344  {
3345  ptr = or_unpack_int (reply, &success);
3346  ptr = or_unpack_log_lsa (ptr, topop_lsa);
3347  }
3348  return success;
3349 #else /* CS_MODE */
3350  int success = ER_FAILED;
3351 
3352  THREAD_ENTRY *thread_p = enter_server ();
3353 
3354  if (xtran_server_start_topop (thread_p, topop_lsa) != NO_ERROR)
3355  {
3356  success = ER_FAILED;
3357  }
3358  else
3359  {
3360  success = NO_ERROR;
3361  }
3362 
3363  exit_server (*thread_p);
3364 
3365  return success;
3366 #endif /* !CS_MODE */
3367 }
3368 
3369 /*
3370  * tran_server_end_topop -
3371  *
3372  * return:
3373  *
3374  * result(in):
3375  * topop_lsa(in):
3376  *
3377  * NOTE:
3378  */
3379 TRAN_STATE
3380 tran_server_end_topop (LOG_RESULT_TOPOP result, LOG_LSA * topop_lsa)
3381 {
3382 #if defined(CS_MODE)
3383  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
3384  int req_error, tran_state_int;
3385  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
3386  char *request;
3388  char *reply;
3389  char *ptr;
3390 
3391  request = OR_ALIGNED_BUF_START (a_request);
3392  reply = OR_ALIGNED_BUF_START (a_reply);
3393 
3394  ptr = or_pack_int (request, (int) result);
3395  req_error =
3397  0);
3398  if (!req_error)
3399  {
3400  ptr = or_unpack_int (reply, &tran_state_int);
3401  tran_state = (TRAN_STATE) tran_state_int;
3402  ptr = or_unpack_log_lsa (ptr, topop_lsa);
3403  }
3404  return tran_state;
3405 #else /* CS_MODE */
3406  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
3407 
3408  THREAD_ENTRY *thread_p = enter_server ();
3409 
3410  tran_state = xtran_server_end_topop (thread_p, result, topop_lsa);
3411 
3412  exit_server (*thread_p);
3413 
3414  return (tran_state);
3415 #endif /* !CS_MODE */
3416 }
3417 #endif
3418 
3419 /*
3420  * tran_server_savepoint -
3421  *
3422  * return:
3423  *
3424  * savept_name(in):
3425  * savept_lsa(in):
3426  *
3427  * NOTE:
3428  */
3429 int
3430 tran_server_savepoint (const char *savept_name, LOG_LSA * savept_lsa)
3431 {
3432 #if defined(CS_MODE)
3433  int success = ER_FAILED;
3434  int req_error, request_size, strlen;
3435  char *request, *reply;
3437  char *ptr;
3438 
3439  reply = OR_ALIGNED_BUF_START (a_reply);
3440 
3441  request_size = length_const_string (savept_name, &strlen);
3442  request = (char *) malloc (request_size);
3443  if (request == NULL)
3444  {
3445  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
3446  return ER_FAILED;
3447  }
3448 
3449  ptr = pack_const_string_with_length (request, savept_name, strlen);
3450  req_error = net_client_request (NET_SERVER_TM_SERVER_SAVEPOINT, request, request_size, reply,
3451  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
3452  if (!req_error)
3453  {
3454  ptr = or_unpack_int (reply, &success);
3455  ptr = or_unpack_log_lsa (ptr, savept_lsa);
3456  }
3457  free_and_init (request);
3458 
3459  return success;
3460 
3461 #else /* CS_MODE */
3462  int success = ER_FAILED;
3463 
3464  THREAD_ENTRY *thread_p = enter_server ();
3465 
3466  success = xtran_server_savepoint (thread_p, savept_name, savept_lsa);
3467 
3468  exit_server (*thread_p);
3469 
3470  return success;
3471 #endif /* !CS_MODE */
3472 }
3473 
3474 /*
3475  * tran_server_partial_abort -
3476  *
3477  * return:
3478  *
3479  * savept_name(in):
3480  * savept_lsa(in):
3481  *
3482  * NOTE:
3483  */
3484 TRAN_STATE
3485 tran_server_partial_abort (const char *savept_name, LOG_LSA * savept_lsa)
3486 {
3487 #if defined(CS_MODE)
3488  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
3489  int req_error, tran_state_int, request_size, strlen;
3490  char *request, *reply;
3492  char *ptr;
3493 
3494  reply = OR_ALIGNED_BUF_START (a_reply);
3495 
3496  request_size = length_const_string (savept_name, &strlen);
3497  request = (char *) malloc (request_size);
3498  if (request == NULL)
3499  {
3500  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
3501  return TRAN_UNACTIVE_UNKNOWN;
3502  }
3503 
3504  ptr = pack_const_string_with_length (request, savept_name, strlen);
3505  req_error = net_client_request (NET_SERVER_TM_SERVER_PARTIAL_ABORT, request, request_size, reply,
3506  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
3507  if (!req_error)
3508  {
3509  ptr = or_unpack_int (reply, &tran_state_int);
3510  tran_state = (TRAN_STATE) tran_state_int;
3511  ptr = or_unpack_log_lsa (ptr, savept_lsa);
3512  }
3513  free_and_init (request);
3514 
3515  return tran_state;
3516 #else /* CS_MODE */
3517  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
3518 
3519  THREAD_ENTRY *thread_p = enter_server ();
3520 
3521  tran_state = xtran_server_partial_abort (thread_p, savept_name, savept_lsa);
3522 
3523  exit_server (*thread_p);
3524 
3525  return tran_state;
3526 #endif /* !CS_MODE */
3527 }
3528 
3529 /*
3530  * acl_reload -
3531  *
3532  * return:
3533  *
3534  */
3535 int
3537 {
3538 #if defined(CS_MODE)
3540  int req_error;
3541  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3542  char *reply;
3543 
3544  reply = OR_ALIGNED_BUF_START (a_reply);
3545 
3546  req_error =
3548  if (!req_error)
3549  {
3550  or_unpack_errcode (reply, &error);
3551  }
3552 
3553  return error;
3554 #else
3555  return NO_ERROR;
3556 #endif /* !CS_MODE */
3557 }
3558 
3559 /*
3560  * acl_dump -
3561  *
3562  * return:
3563  *
3564  * outfp(in):
3565  */
3566 void
3567 acl_dump (FILE * outfp)
3568 {
3569 #if defined(CS_MODE)
3570  int req_error;
3571 
3572  if (outfp == NULL)
3573  {
3574  outfp = stdout;
3575  }
3576 
3577  req_error = net_client_request_recv_stream (NET_SERVER_ACL_DUMP, NULL, 0, NULL, 0, NULL, 0, outfp);
3578 #endif /* !CS_MODE */
3579 }
3580 
3581 /*
3582  * lock_dump -
3583  *
3584  * return:
3585  *
3586  * outfp(in):
3587  */
3588 void
3589 lock_dump (FILE * outfp)
3590 {
3591 #if defined(CS_MODE)
3592  int req_error;
3593 
3594  if (outfp == NULL)
3595  {
3596  outfp = stdout;
3597  }
3598 
3599  req_error = net_client_request_recv_stream (NET_SERVER_LK_DUMP, NULL, 0, NULL, 0, NULL, 0, outfp);
3600 #else /* CS_MODE */
3601 
3602  THREAD_ENTRY *thread_p = enter_server ();
3603 
3604  xlock_dump (thread_p, outfp);
3605 
3606  exit_server (*thread_p);
3607 #endif /* !CS_MODE */
3608 }
3609 
3610 /*
3611  * boot_initialize_server -
3612  *
3613  * return:
3614  *
3615  * print_version(in):
3616  * db_overwrite(in):
3617  * db_desired_pagesize(in):
3618  * db_name(in):
3619  * db_path(in):
3620  * vol_path(in):
3621  * db_comments(in):
3622  * db_npages(in):
3623  * file_addmore_vols(in):
3624  * db_server_host(in):
3625  * log_path(in):
3626  * log_npages(in):
3627  * rootclass_oid(in):
3628  * rootclass_hfid(in):
3629  * client_prog_name(in):
3630  * client_user_name(in):
3631  * client_host_name(in):
3632  * client_process_id(in):
3633  * client_lock_wait(in):
3634  * client_isolation(in):
3635  *
3636  * NOTE:
3637  */
3638 int
3639 boot_initialize_server (const BOOT_CLIENT_CREDENTIAL * client_credential, BOOT_DB_PATH_INFO * db_path_info,
3640  bool db_overwrite, const char *file_addmore_vols, DKNPAGES db_npages,
3641  PGLENGTH db_desired_pagesize, DKNPAGES log_npages, PGLENGTH db_desired_log_page_size,
3642  OID * rootclass_oid, HFID * rootclass_hfid, int client_lock_wait,
3643  TRAN_ISOLATION client_isolation)
3644 {
3645 #if defined(CS_MODE)
3646  /* Should not called in CS_MODE */
3647  assert (0);
3648  return NULL_TRAN_INDEX;
3649 #else /* CS_MODE */
3650  int tran_index = NULL_TRAN_INDEX;
3651 
3652  enter_server_no_thread_entry ();
3653 
3654  tran_index =
3655  xboot_initialize_server (client_credential, db_path_info, db_overwrite, file_addmore_vols, db_npages,
3656  db_desired_pagesize, log_npages, db_desired_log_page_size, rootclass_oid, rootclass_hfid,
3657  client_lock_wait, client_isolation);
3658 
3659  exit_server_no_thread_entry ();
3660 
3661  return (tran_index);
3662 #endif /* !CS_MODE */
3663 }
3664 
3665 /*
3666  * boot_register_client -
3667  *
3668  * return:
3669  *
3670  * client_credential(in)
3671  * client_lock_wait(in):
3672  * client_isolation(in):
3673  * tran_state(out):
3674  * server_credential(out):
3675  */
3676 int
3677 boot_register_client (BOOT_CLIENT_CREDENTIAL * client_credential, int client_lock_wait, TRAN_ISOLATION client_isolation,
3678  TRAN_STATE * tran_state, BOOT_SERVER_CREDENTIAL * server_credential)
3679 {
3680 #if defined(CS_MODE)
3681  int tran_index = NULL_TRAN_INDEX;
3682  int area_size, req_error, temp_int;
3683  char *reply, *area, *ptr;
3684  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3685 
3686  reply = OR_ALIGNED_BUF_START (a_reply);
3687 
3688  packing_packer packer;
3689  cubmem::extensible_block ext_blk;
3690  int clisol_toint = (int) client_isolation;
3691  packer.set_buffer_and_pack_all (ext_blk, *client_credential, client_lock_wait, clisol_toint);
3692 
3693  req_error = net_client_request2 (NET_SERVER_BO_REGISTER_CLIENT, ext_blk.get_ptr (), (int) packer.get_current_size (),
3694  reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
3695  if (!req_error)
3696  {
3697  or_unpack_int (reply, &area_size);
3698  if (area_size > 0)
3699  {
3700  int ha_state_to_int;
3701 
3702  ptr = or_unpack_int (area, &tran_index);
3703 
3704  ptr = or_unpack_int (ptr, &temp_int);
3705  *tran_state = (TRAN_STATE) temp_int;
3706 
3707  ptr = or_unpack_string (ptr, &server_credential->db_full_name);
3708  ptr = or_unpack_string (ptr, &server_credential->host_name);
3709  ptr = or_unpack_string (ptr, &server_credential->lob_path);
3710  ptr = or_unpack_int (ptr, &server_credential->process_id);
3711  ptr = or_unpack_oid (ptr, &server_credential->root_class_oid);
3712  ptr = or_unpack_hfid (ptr, &server_credential->root_class_hfid);
3713 
3714  ptr = or_unpack_int (ptr, &temp_int);
3715  server_credential->page_size = (PGLENGTH) temp_int;
3716 
3717  ptr = or_unpack_int (ptr, &temp_int);
3718  server_credential->log_page_size = (PGLENGTH) temp_int;
3719 
3720  ptr = or_unpack_float (ptr, &server_credential->disk_compatibility);
3721 
3722  ptr = or_unpack_int (ptr, &ha_state_to_int);
3723  server_credential->ha_server_state = (HA_SERVER_STATE) ha_state_to_int;
3724 
3725  ptr = or_unpack_int (ptr, &server_credential->db_charset);
3726  ptr = or_unpack_string (ptr, &server_credential->db_lang);
3727  }
3728  free_and_init (area);
3729  }
3730 
3731  return tran_index;
3732 #else /* CS_MODE */
3733  int tran_index = NULL_TRAN_INDEX;
3734 
3735  enter_server_no_thread_entry ();
3736 
3737  tran_index =
3738  xboot_register_client (NULL, client_credential, client_lock_wait, client_isolation, tran_state, server_credential);
3739  exit_server_no_thread_entry ();
3740 
3741  return tran_index;
3742 #endif /* !CS_MODE */
3743 }
3744 
3745 /*
3746  * boot_unregister_client -
3747  *
3748  * return:
3749  *
3750  * tran_index(in):
3751  *
3752  * NOTE:
3753  */
3754 int
3755 boot_unregister_client (int tran_index)
3756 {
3757 #if defined(CS_MODE)
3758  int error_code = ER_FAILED;
3759  int req_error;
3760  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
3761  char *request;
3762  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3763  char *reply;
3764 
3765  request = OR_ALIGNED_BUF_START (a_request);
3766  reply = OR_ALIGNED_BUF_START (a_reply);
3767 
3768  (void) or_pack_int (request, tran_index);
3769 
3770  req_error = net_client_request (NET_SERVER_BO_UNREGISTER_CLIENT, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
3771  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
3772  if (req_error == NO_ERROR)
3773  {
3774  or_unpack_int (reply, &error_code);
3775  }
3776  else
3777  {
3778  error_code = req_error;
3779  }
3780 
3781  return error_code;
3782 #else /* CS_MODE */
3783  int error_code = NO_ERROR;
3784 
3785  if (!BO_IS_SERVER_RESTARTED ())
3786  {
3787  // server is killed already
3788  return NO_ERROR;
3789  }
3790 
3791  THREAD_ENTRY *thread_p = enter_server ();
3792 
3793  error_code = xboot_unregister_client (thread_p, tran_index);
3794  if (tran_index == NULL_TRAN_INDEX)
3795  {
3796  assert (thread_p == NULL);
3797  exit_server_no_thread_entry ();
3798  }
3799  else
3800  {
3801  exit_server (*thread_p);
3802  }
3803 
3804  return error_code;
3805 #endif /* !CS_MODE */
3806 }
3807 
3808 /*
3809  * boot_backup -
3810  *
3811  * return:
3812  *
3813  * backup_path(in):
3814  * backup_level(in):
3815  * delete_unneeded_logarchives(in):
3816  * backup_verbose_file(in):
3817  * num_threads(in):
3818  * zip_method(in):
3819  * zip_level(in):
3820  * skip_activelog(in):
3821  * sleep_msecs(in):
3822  *
3823  * NOTE:
3824  */
3825 int
3826 boot_backup (const char *backup_path, FILEIO_BACKUP_LEVEL backup_level, bool delete_unneeded_logarchives,
3827  const char *backup_verbose_file, int num_threads, FILEIO_ZIP_METHOD zip_method, FILEIO_ZIP_LEVEL zip_level,
3828  int skip_activelog, int sleep_msecs, bool separate_keys)
3829 {
3830 #if defined(CS_MODE)
3831  int success = ER_FAILED;
3832  int request_size, strlen1, strlen2;
3833  char *request, *ptr;
3834  int req_error;
3835  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
3836  char *reply;
3837  char *rd1, *rd2;
3838  int d1, d2;
3839  int cb_type;
3840 
3841  reply = OR_ALIGNED_BUF_START (a_reply);
3842 
3843  request_size = (length_const_string (backup_path, &strlen1) + OR_INT_SIZE + OR_INT_SIZE
3844  + length_const_string (backup_verbose_file, &strlen2) + OR_INT_SIZE + OR_INT_SIZE + OR_INT_SIZE
3846 
3847  request = (char *) malloc (request_size);
3848  if (request == NULL)
3849  {
3850  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
3851  return ER_FAILED;
3852  }
3853 
3854  ptr = pack_const_string_with_length (request, backup_path, strlen1);
3855  ptr = or_pack_int (ptr, backup_level);
3856  ptr = or_pack_int (ptr, delete_unneeded_logarchives ? 1 : 0);
3857  ptr = pack_const_string_with_length (ptr, backup_verbose_file, strlen2);
3858  ptr = or_pack_int (ptr, num_threads);
3859  ptr = or_pack_int (ptr, zip_method);
3860  ptr = or_pack_int (ptr, zip_level);
3861  ptr = or_pack_int (ptr, skip_activelog);
3862  ptr = or_pack_int (ptr, sleep_msecs);
3863  ptr = or_pack_int (ptr, separate_keys);
3864  req_error =
3865  net_client_request_with_callback (NET_SERVER_BO_BACKUP, request, request_size, reply,
3866  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0, &rd1, &d1, &rd2, &d2, NULL,
3867  NULL);
3868  if (!req_error)
3869  {
3870  ptr = or_unpack_int (reply, &cb_type);
3871  or_unpack_int (ptr, &success);
3872  /* we just ignore the last part of the reply */
3873  }
3874  free_and_init (request);
3875 
3876  return success;
3877 #else /* CS_MODE */
3878  int success = false;
3879 
3880  THREAD_ENTRY *thread_p = enter_server ();
3881 
3882  success = xboot_backup (thread_p, backup_path, backup_level, delete_unneeded_logarchives, backup_verbose_file,
3883  num_threads, zip_method, zip_level, skip_activelog, sleep_msecs, separate_keys);
3884 
3885  exit_server (*thread_p);
3886 
3887  return success;
3888 #endif /* !CS_MODE */
3889 }
3890 
3891 /*
3892  * boot_add_volume_extension -
3893  *
3894  * return:
3895  *
3896  * ext_info(in):
3897  *
3898  * NOTE:
3899  */
3900 VOLID
3902 {
3903 #if defined(CS_MODE)
3904  int int_volid;
3905  VOLID volid = NULL_VOLID;
3906  int request_size, strlen1, strlen2, strlen3;
3907  char *request, *ptr;
3908  int req_error;
3909  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3910  char *reply;
3911 
3912  reply = OR_ALIGNED_BUF_START (a_reply);
3913 
3914  request_size = (length_const_string (ext_info->path, &strlen1)
3915  + length_const_string (ext_info->name, &strlen2)
3916  + length_const_string (ext_info->comments, &strlen3)
3918 
3919  request = (char *) malloc (request_size);
3920  if (request == NULL)
3921  {
3922  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
3923  return NULL_VOLID;
3924  }
3925 
3926  ptr = pack_const_string_with_length (request, ext_info->path, strlen1);
3927  ptr = pack_const_string_with_length (ptr, ext_info->name, strlen2);
3928  ptr = pack_const_string_with_length (ptr, ext_info->comments, strlen3);
3929  ptr = or_pack_int (ptr, (int) ext_info->max_npages);
3930  ptr = or_pack_int (ptr, (int) ext_info->max_writesize_in_sec);
3931  ptr = or_pack_int (ptr, (int) ext_info->purpose);
3932  ptr = or_pack_int (ptr, (int) ext_info->overwrite);
3933  req_error = net_client_request (NET_SERVER_BO_ADD_VOLEXT, request, request_size, reply,
3934  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
3935  if (!req_error)
3936  {
3937  or_unpack_int (reply, &int_volid);
3938  volid = int_volid;
3939  }
3940  free_and_init (request);
3941 
3942  return volid;
3943 #else /* CS_MODE */
3944  VOLID volid;
3945 
3946  THREAD_ENTRY *thread_p = enter_server ();
3947 
3948  volid = xboot_add_volume_extension (thread_p, ext_info);
3949 
3950  exit_server (*thread_p);
3951 
3952  return volid;
3953 #endif /* !CS_MODE */
3954 }
3955 
3956 /*
3957  * boot_check_db_consistency -
3958  *
3959  * return:
3960  *
3961  * check_flag(in):
3962  *
3963  * NOTE:
3964  */
3965 int
3966 boot_check_db_consistency (int check_flag, OID * oids, int num_oids, BTID * index_btid)
3967 {
3968 #if defined(CS_MODE)
3969  int success = ER_FAILED;
3970  int req_error;
3971  int cb_type;
3972  char *rd1, *rd2;
3973  int d1, d2;
3974  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
3975  char *reply;
3976  char *request, *ptr;
3977  size_t request_size;
3978  int i;
3979 
3980  request_size = OR_INT_SIZE; /* check_flag */
3981  request_size += OR_INT_SIZE; /* num_oid */
3982  request_size += (OR_OID_SIZE * num_oids);
3983  request_size += OR_BTID_ALIGNED_SIZE;
3984 
3985  request = (char *) malloc (request_size);
3986  if (request == NULL)
3987  {
3988  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
3989  return ER_FAILED;
3990  }
3991 
3992  ptr = or_pack_int (request, check_flag);
3993  ptr = or_pack_int (ptr, num_oids);
3994  for (i = 0; i < num_oids; i++)
3995  {
3996  ptr = or_pack_oid (ptr, &oids[i]);
3997  }
3998  ptr = or_pack_btid (ptr, index_btid);
3999 
4000  reply = OR_ALIGNED_BUF_START (a_reply);
4001  req_error = net_client_request_with_callback (NET_SERVER_BO_CHECK_DBCONSISTENCY, request, (int) request_size, reply,
4002  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0, &rd1, &d1, &rd2, &d2,
4003  NULL, NULL);
4004  free_and_init (request);
4005 
4006  if (!req_error)
4007  {
4008  ptr = or_unpack_int (reply, &cb_type);
4009  or_unpack_int (ptr, &success);
4010  }
4011 
4012  return success;
4013 #else /* CS_MODE */
4014  int success = ER_FAILED;
4015 
4016  THREAD_ENTRY *thread_p = enter_server ();
4017 
4018  success = xboot_check_db_consistency (thread_p, check_flag, oids, num_oids, index_btid);
4019 
4020  exit_server (*thread_p);
4021 
4022  return success;
4023 #endif /* !CS_MODE */
4024 }
4025 
4026 /*
4027  * boot_find_number_permanent_volumes -
4028  *
4029  * return:
4030  *
4031  * NOTE:
4032  */
4033 int
4035 {
4036 #if defined(CS_MODE)
4037  int nvols = -1;
4038  int req_error;
4039  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4040  char *reply;
4041 
4042  reply = OR_ALIGNED_BUF_START (a_reply);
4043 
4044  req_error =
4046  if (!req_error)
4047  {
4048  or_unpack_int (reply, &nvols);
4049  }
4050 
4051  return nvols;
4052 #else /* CS_MODE */
4053  int nvols = -1;
4054 
4055  THREAD_ENTRY *thread_p = enter_server ();
4056 
4057  nvols = xboot_find_number_permanent_volumes (thread_p);
4058 
4059  exit_server (*thread_p);
4060 
4061  return nvols;
4062 #endif /* !CS_MODE */
4063 }
4064 
4065 /*
4066  * boot_find_number_temp_volumes -
4067  *
4068  * return:
4069  *
4070  * NOTE:
4071  */
4072 int
4074 {
4075 #if defined(CS_MODE)
4076  int nvols = -1;
4077  int req_error;
4078  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4079  char *reply;
4080 
4081  reply = OR_ALIGNED_BUF_START (a_reply);
4082 
4083  req_error =
4085  if (!req_error)
4086  {
4087  or_unpack_int (reply, &nvols);
4088  }
4089 
4090  return nvols;
4091 #else /* CS_MODE */
4092  int nvols = -1;
4093 
4094  THREAD_ENTRY *thread_p = enter_server ();
4095 
4096  nvols = xboot_find_number_temp_volumes (thread_p);
4097 
4098  exit_server (*thread_p);
4099 
4100  return nvols;
4101 #endif /* !CS_MODE */
4102 }
4103 
4104 /*
4105  * boot_find_last_permanant -
4106  *
4107  * return:
4108  *
4109  * NOTE:
4110  */
4111 VOLID
4113 {
4114  VOLID volid = NULL_VOLID;
4115 #if defined(CS_MODE)
4116  int int_volid;
4117  int req_error;
4118  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4119  char *reply;
4120 
4121  reply = OR_ALIGNED_BUF_START (a_reply);
4122 
4123  req_error =
4125  if (!req_error)
4126  {
4127  or_unpack_int (reply, &int_volid);
4128  volid = (VOLID) int_volid;
4129  }
4130 
4131  return volid;
4132 #else /* CS_MODE */
4133  THREAD_ENTRY *thread_p = enter_server ();
4134 
4135  volid = xboot_find_last_permanent (thread_p);
4136 
4137  exit_server (*thread_p);
4138 
4139  return volid;
4140 #endif /* !CS_MODE */
4141 }
4142 
4143 /*
4144  * boot_find_last_temp -
4145  *
4146  * return:
4147  *
4148  * NOTE:
4149  */
4150 int
4152 {
4153 #if defined(CS_MODE)
4154  int nvols = -1;
4155  int req_error;
4156  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4157  char *reply;
4158 
4159  reply = OR_ALIGNED_BUF_START (a_reply);
4160 
4161  req_error =
4163  if (!req_error)
4164  {
4165  or_unpack_int (reply, &nvols);
4166  }
4167 
4168  return nvols;
4169 #else /* CS_MODE */
4170  int nvols = -1;
4171 
4172  THREAD_ENTRY *thread_p = enter_server ();
4173 
4174  nvols = xboot_find_last_temp (thread_p);
4175 
4176  exit_server (*thread_p);
4177 
4178  return nvols;
4179 #endif /* !CS_MODE */
4180 }
4181 
4182 /*
4183  * boot_delete -
4184  *
4185  * return:
4186  *
4187  * NOTE:
4188  */
4189 int
4190 boot_delete (const char *db_name, bool force_delete)
4191 {
4192 #if defined(CS_MODE)
4193  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_ONLY_IN_STANDALONE, 1, "delete database");
4194  return ER_FAILED;
4195 #else /* CS_MODE */
4196  int error_code;
4197 
4198  enter_server_no_thread_entry ();
4199 
4200  error_code = xboot_delete (db_name, force_delete, BOOT_SHUTDOWN_ALL_MODULES);
4201 
4202  exit_server_no_thread_entry ();
4203 
4204  return error_code;
4205 #endif /* !CS_MODE */
4206 }
4207 
4208 #if defined (SA_MODE)
4209 /*
4210  * boot_restart_from_backup -
4211  *
4212  * return:
4213  *
4214  * NOTE:
4215  */
4216 int
4217 boot_restart_from_backup (int print_restart, const char *db_name, bo_restart_arg * r_args)
4218 {
4219  int tran_index;
4220 
4221  enter_server_no_thread_entry ();
4222 
4223  tran_index = xboot_restart_from_backup (NULL, print_restart, db_name, r_args);
4224 
4225  exit_server_no_thread_entry ();
4226 
4227  return tran_index;
4228 }
4229 #endif /* SA_MODE */
4230 
4231 /*
4232  * boot_shutdown_server -
4233  *
4234  * return:
4235  *
4236  * NOTE:
4237  */
4238 bool
4240 {
4241 #if defined(CS_MODE)
4243  return false;
4244 #else /* CS_MODE */
4245  bool result;
4246 
4247  THREAD_ENTRY *thread_p = enter_server ();
4248 
4249  result = xboot_shutdown_server (thread_p, iserfinal);
4250  assert (thread_p == NULL);
4251 
4252  exit_server_no_thread_entry ();
4253 
4254  return result;
4255 #endif /* !CS_MODE */
4256 }
4257 
4258 /*
4259  * csession_find_or_create_session - check if session is still active
4260  * if not, create a new session
4261  *
4262  * return : error code or NO_ERROR
4263  * session_id (in/out) : the id of the session to end
4264  * row_count (out) : the value of row count for this session
4265  * server_session_key (in/out) :
4266  */
4267 int
4268 csession_find_or_create_session (SESSION_ID * session_id, int *row_count, char *server_session_key, const char *db_user,
4269  const char *host, const char *program_name)
4270 {
4271 #if defined (CS_MODE)
4272  int req_error;
4274  char *reply = NULL;
4275  char *request = NULL, *area = NULL;
4276  char *ptr;
4277  int request_size, area_size;
4278  int db_user_len, host_len, program_name_len;
4279  SESSION_PARAM *session_params = NULL;
4280  int error = NO_ERROR, update_parameter_values = 0;
4281 
4282  reply = OR_ALIGNED_BUF_START (a_reply);
4283  request_size = OR_INT_SIZE; /* session_id */
4285  request_size += sysprm_packed_session_parameters_length (cached_session_parameters, request_size);
4286  request_size += length_const_string (db_user, &db_user_len);
4287  request_size += length_const_string (host, &host_len);
4288  request_size += length_const_string (program_name, &program_name_len);
4289 
4290  reply = OR_ALIGNED_BUF_START (a_reply);
4291 
4292  request = (char *) malloc (request_size);
4293  if (request == NULL)
4294  {
4295  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
4296  return ER_FAILED;
4297  }
4298 
4299  ptr = or_pack_int (request, ((int) *session_id));
4300  ptr = or_pack_stream (ptr, server_session_key, SERVER_SESSION_KEY_SIZE);
4301  ptr = sysprm_pack_session_parameters (ptr, cached_session_parameters);
4302  ptr = pack_const_string_with_length (ptr, db_user, db_user_len);
4303  ptr = pack_const_string_with_length (ptr, host, host_len);
4304  ptr = pack_const_string_with_length (ptr, program_name, program_name_len);
4305 
4306  req_error =
4307  net_client_request2 (NET_SERVER_SES_CHECK_SESSION, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
4308  NULL, 0, &area, &area_size);
4309 
4310  if (req_error == NO_ERROR)
4311  {
4312  ptr = or_unpack_int (reply, &area_size);
4313  ptr = or_unpack_int (ptr, &error);
4314  if (error != NO_ERROR)
4315  {
4316  free_and_init (request);
4317  return error;
4318  }
4319 
4320  if (area_size > 0)
4321  {
4322  ptr = or_unpack_int (area, (int *) session_id);
4323  ptr = or_unpack_int (ptr, row_count);
4324  ptr = or_unpack_stream (ptr, server_session_key, SERVER_SESSION_KEY_SIZE);
4325  ptr = or_unpack_int (ptr, &update_parameter_values);
4326  if (update_parameter_values)
4327  {
4328  ptr = sysprm_unpack_session_parameters (ptr, &session_params);
4329  }
4330 
4331  free_and_init (area);
4332  }
4333  if (update_parameter_values)
4334  {
4335  /* session parameters were found in session state and must update parameter values */
4336  if (session_params == NULL)
4337  {
4338  assert (er_errid () != NO_ERROR);
4339  error = er_errid ();
4340  if (error == NO_ERROR)
4341  {
4343  error = ER_FAILED;
4344  }
4345  free_and_init (request);
4346  return error;
4347  }
4348  sysprm_update_client_session_parameters (session_params);
4349  }
4350  else
4351  {
4352  /* use the values stored in cached_session_parameters */
4353  sysprm_update_client_session_parameters (cached_session_parameters);
4354  }
4355  sysprm_free_session_parameters (&session_params);
4356  }
4357  free_and_init (request);
4358 
4359  return req_error;
4360 #else
4361  int result = NO_ERROR;
4362  SESSION_ID id;
4363 
4364  THREAD_ENTRY *thread_p = enter_server ();
4365 
4367  {
4368  result = xsession_create_new (thread_p, &id);
4369  }
4370  else
4371  {
4372  id = db_Session_id;
4373  if (xsession_check_session (thread_p, id) != NO_ERROR)
4374  {
4375  /* create new session */
4376  if (xsession_create_new (thread_p, &id) != NO_ERROR)
4377  {
4378  result = ER_FAILED;
4379  }
4380  }
4381  }
4382 
4383  db_Session_id = id;
4384  *session_id = db_Session_id;
4385 
4386  /* get row count */
4387  if (result != ER_FAILED)
4388  {
4389  xsession_get_row_count (thread_p, row_count);
4390  }
4391 
4392  exit_server (*thread_p);
4393 
4394  return result;
4395 #endif
4396 }
4397 
4398 /*
4399  * csession_end_session - end the session identified by session_id
4400  *
4401  * return : error code or NO_ERROR
4402  * session_id (in) : the id of the session to end
4403  */
4404 int
4406 {
4407 #if defined (CS_MODE)
4408  int req_error;
4409  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4410  char *reply;
4411  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
4412  char *request;
4413  char *ptr;
4414 
4415  reply = OR_ALIGNED_BUF_START (a_reply);
4416  request = OR_ALIGNED_BUF_START (a_request);
4417 
4418  ptr = or_pack_int (request, session_id);
4419 
4420  req_error =
4422  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
4423  if (req_error != NO_ERROR)
4424  {
4425  return ER_FAILED;
4426  }
4427 
4428  return req_error;
4429 #else
4430  int result = NO_ERROR;
4431 
4432  THREAD_ENTRY *thread_p = enter_server ();
4433 
4434  result = xsession_end_session (thread_p, session_id);
4435 
4436  exit_server (*thread_p);
4437 
4438  return result;
4439 #endif
4440 }
4441 
4442 /*
4443  * csession_set_row_count - set affected rows count for the current
4444  * session
4445  * return : error code or NO_ERROR
4446  * rows (in) : the count of affected rows
4447  * NOTE : the affected rows count is the number of rows affected by the last
4448  * INSERT, UPDATE or DELETE statement
4449  */
4450 int
4452 {
4453 #if defined (CS_MODE)
4454  int req_error;
4455  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4456  char *reply;
4457  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
4458  char *request;
4459  char *ptr;
4460 
4461  reply = OR_ALIGNED_BUF_START (a_reply);
4462  request = OR_ALIGNED_BUF_START (a_request);
4463 
4464  ptr = or_pack_int (request, rows);
4465 
4466  req_error =
4468  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
4469  if (req_error != NO_ERROR)
4470  {
4471  return ER_FAILED;
4472  }
4473 
4474  or_unpack_int (reply, &req_error);
4475  return req_error;
4476 #else
4477  int result = NO_ERROR;
4478 
4479  THREAD_ENTRY *thread_p = enter_server ();
4480 
4481  result = xsession_set_row_count (thread_p, rows);
4482 
4483  exit_server (*thread_p);
4484 
4485  return result;
4486 #endif
4487 }
4488 
4489 /*
4490  * csession_get_row_count - get affected rows count for the current
4491  * session
4492  * return : error code or NO_ERROR
4493  * rows (out): the count of affected rows
4494  * NOTE : the affected rows count is the number of rows affected by the last
4495  * INSERT, UPDATE or DELETE statement
4496  */
4497 int
4499 {
4500 #if defined (CS_MODE)
4501  int req_error;
4502  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4503  char *reply;
4504  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
4505  char *request;
4506 
4507  reply = OR_ALIGNED_BUF_START (a_reply);
4508  request = OR_ALIGNED_BUF_START (a_request);
4509 
4510  req_error =
4512  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
4513  if (req_error != NO_ERROR)
4514  {
4515  return ER_FAILED;
4516  }
4517  or_unpack_int (reply, &req_error);
4518  or_unpack_int (reply, rows);
4519 
4520  return NO_ERROR;
4521 #else
4522  int result = NO_ERROR;
4523 
4524  THREAD_ENTRY *thread_p = enter_server ();
4525 
4526  result = xsession_get_row_count (thread_p, rows);
4527 
4528  exit_server (*thread_p);
4529 
4530  return result;
4531 #endif
4532 }
4533 
4534 /*
4535  * csession_get_last_insert_id - get the value of the last update serial
4536  * return : error code or NO_ERROR
4537  * value (out) : the value of the last insert id
4538  * update_last_insert_id(in): whether update the last insert id
4539  */
4540 int
4541 csession_get_last_insert_id (DB_VALUE * value, bool update_last_insert_id)
4542 {
4543 #if defined (CS_MODE)
4544  int req_error;
4546  char *reply;
4547  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
4548  char *request;
4549  char *ptr = NULL;
4550  char *data_reply = NULL;
4551  int data_size = 0;
4552 
4553  db_make_null (value);
4554 
4555  reply = OR_ALIGNED_BUF_START (a_reply);
4556 
4557  request = OR_ALIGNED_BUF_START (a_request);
4558  ptr = or_pack_int (request, update_last_insert_id);
4559 
4560  req_error =
4562  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &data_reply, &data_size);
4563  if (req_error != NO_ERROR)
4564  {
4565  db_make_null (value);
4566  req_error = ER_FAILED;
4567  goto cleanup;
4568  }
4569 
4570  /* data_size */
4571  ptr = or_unpack_int (reply, &req_error);
4572  /* req_error */
4573  ptr = or_unpack_int (ptr, &req_error);
4574  if (req_error != NO_ERROR || data_size == 0)
4575  {
4576  req_error = (req_error != NO_ERROR) ? req_error : ER_FAILED;
4577  goto cleanup;
4578  }
4579 
4580  or_unpack_value (data_reply, value);
4581 
4582 cleanup:
4583  if (data_reply != NULL)
4584  {
4585  free_and_init (data_reply);
4586  }
4587 
4588  return req_error;
4589 #else
4590  int result = NO_ERROR;
4591  THREAD_ENTRY *thread_p = enter_server ();
4592 
4593  result = xsession_get_last_insert_id (thread_p, value, update_last_insert_id);
4594 
4595  exit_server (*thread_p);
4596 
4597  return result;
4598 #endif
4599 }
4600 
4601 /*
4602  * csession_reset_cur_insert_id - reset cur insert id as NULL
4603  * return : error code or NO_ERROR
4604  */
4605 int
4607 {
4608 #if defined (CS_MODE)
4609  int req_error;
4610  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4611  char *reply;
4612 
4613  reply = OR_ALIGNED_BUF_START (a_reply);
4614 
4615  req_error =
4617  NULL, 0);
4618  if (req_error != NO_ERROR)
4619  {
4620  return ER_FAILED;
4621  }
4622  or_unpack_int (reply, &req_error);
4623 
4624  return req_error;
4625 #else
4626  int result = NO_ERROR;
4627 
4628  THREAD_ENTRY *thread_p = enter_server ();
4629 
4630  result = xsession_reset_cur_insert_id (thread_p);
4631 
4632  exit_server (*thread_p);
4633 
4634  return result;
4635 #endif
4636 }
4637 
4638 /*
4639  * csession_create_prepared_statement () - create a prepared session statement
4640  * return : error code or NO_ERROR
4641  * name (in) : the name of the prepared statement
4642  * alias_print(in): the compiled statement string
4643  * stmt_info (in) : serialized prepared statement information
4644  * info_length(in): the size of the serialized buffer
4645  */
4646 int
4647 csession_create_prepared_statement (const char *name, const char *alias_print, char *stmt_info, int info_length)
4648 {
4649 #if defined (CS_MODE)
4650  int req_error;
4651  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4652  char *request = NULL;
4653  char *reply = NULL;
4654  char *ptr = NULL;
4655  int req_size = 0, name_len = 0, alias_print_len = 0;
4656  SHA1Hash alias_sha1 = SHA1_HASH_INITIALIZER;
4657 
4658  reply = OR_ALIGNED_BUF_START (a_reply);
4659 
4660  req_size = 0;
4661  /* packed size for name */
4662  req_size += length_const_string (name, &name_len);
4663  /* packed size for alias_print */
4664  req_size += length_const_string (alias_print, &alias_print_len);
4665  /* data_size */
4666  req_size += OR_INT_SIZE;
4667  if (alias_print != NULL)
4668  {
4669  /* sha1 */
4670  req_size += OR_SHA1_SIZE;
4671  }
4672 
4673  request = (char *) malloc (req_size);
4674  if (request == NULL)
4675  {
4677  req_error = ER_FAILED;
4678  goto cleanup;
4679  }
4680 
4681  /* name */
4682  ptr = pack_const_string_with_length (request, name, name_len);
4683  /* alias_print */
4684  ptr = pack_const_string_with_length (ptr, alias_print, alias_print_len);
4685  /* data size */
4686  ptr = or_pack_int (ptr, info_length);
4687 
4688  if (alias_print)
4689  {
4690  req_error = SHA1Compute ((const unsigned char *) alias_print, (unsigned) strlen (alias_print), &alias_sha1);
4691  if (req_error != NO_ERROR)
4692  {
4693  ASSERT_ERROR ();
4694  goto cleanup;
4695  }
4696  ptr = or_pack_sha1 (ptr, &alias_sha1);
4697  }
4698 
4699  req_error =
4701  OR_ALIGNED_BUF_SIZE (a_reply), stmt_info, info_length, NULL, 0);
4702  if (req_error != NO_ERROR)
4703  {
4704  goto cleanup;
4705  }
4706  ptr = or_unpack_int (reply, &req_error);
4707 
4708 cleanup:
4709  if (request != NULL)
4710  {
4711  free_and_init (request);
4712  }
4713  return req_error;
4714 #else
4715  int result = NO_ERROR;
4716  char *local_name = NULL;
4717  char *local_alias_print = NULL;
4718  char *local_stmt_info = NULL;
4719  size_t len = 0;
4720  SHA1Hash alias_sha1 = SHA1_HASH_INITIALIZER;
4721 
4722  THREAD_ENTRY *thread_p = enter_server ();
4723 
4724  /* The server keeps a packed version of the prepared statement information and we need to pack it here */
4725 
4726  /* copy name */
4727  if (name != NULL)
4728  {
4729  len = strlen (name);
4730  local_name = (char *) malloc (len + 1);
4731  if (local_name == NULL)
4732  {
4734  result = ER_FAILED;
4735  goto error;
4736  }
4737  memcpy (local_name, name, len);
4738  local_name[len] = 0;
4739  }
4740 
4741  /* copy alias print */
4742  if (alias_print != NULL)
4743  {
4744  len = strlen (alias_print);
4745  local_alias_print = (char *) malloc (len + 1);
4746  if (local_alias_print == NULL)
4747  {
4749  result = ER_FAILED;
4750  goto error;
4751  }
4752  memcpy (local_alias_print, alias_print, len);
4753  local_alias_print[len] = 0;
4754 
4755  result = SHA1Compute ((const unsigned char *) alias_print, (unsigned) strlen (alias_print), &alias_sha1);
4756  if (result != NO_ERROR)
4757  {
4758  ASSERT_ERROR ();
4759  goto error;
4760  }
4761  }
4762 
4763  /* copy stmt_info */
4764  if (stmt_info != NULL)
4765  {
4766  local_stmt_info = (char *) malloc (info_length);
4767  if (local_stmt_info == NULL)
4768  {
4769  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) info_length);
4770  result = ER_FAILED;
4771  goto error;
4772  }
4773  memcpy (local_stmt_info, stmt_info, info_length);
4774  }
4775 
4776  result =
4777  xsession_create_prepared_statement (thread_p, local_name, local_alias_print, &alias_sha1, local_stmt_info,
4778  info_length);
4779  if (result != NO_ERROR)
4780  {
4781  goto error;
4782  }
4783 
4784  exit_server (*thread_p);
4785 
4786  return result;
4787 
4788 error:
4789 
4790  if (local_name != NULL)
4791  {
4792  free_and_init (local_name);
4793  }
4794  if (local_alias_print != NULL)
4795  {
4796  free_and_init (local_alias_print);
4797  }
4798  if (local_stmt_info != NULL)
4799  {
4800  free_and_init (local_stmt_info);
4801  }
4802 
4803  exit_server (*thread_p);
4804 
4805  return result;
4806 #endif
4807 }
4808 
4809 /*
4810  * csession_get_prepared_statement () - get information about a prepared session statement
4811  * return : error code or no error
4812  * name (in) : the name of the prepared statement
4813  * xasl_id (out) : XASL id
4814  * stmt_info (out) : serialized prepared statement information
4815  * xasl_header_p (out) : if pointer is not null, request XASL node header along with XASL_ID.
4816  */
4817 int
4818 csession_get_prepared_statement (const char *name, XASL_ID * xasl_id, char **stmt_info,
4819  xasl_node_header * xasl_header_p)
4820 {
4821 #if defined (CS_MODE)
4822  int req_error = NO_ERROR;
4823  OR_ALIGNED_BUF (OR_INT_SIZE * 2 + OR_XASL_ID_SIZE) a_reply;
4824  char *reply = NULL;
4825  char *reply_data = NULL;
4826  char *request = NULL;
4827  char *ptr = NULL;
4828  int req_size = 0, len = 0;
4829  int reply_size = 0;
4830  int get_xasl_header = xasl_header_p != NULL;
4831 
4832  INIT_XASL_NODE_HEADER (xasl_header_p);
4833 
4834  req_size = (or_packed_string_length (name, &len) /* name */
4835  + OR_INT_SIZE /* get_xasl_header */ );
4836  request = (char *) malloc (req_size);
4837  if (request == NULL)
4838  {
4840  req_error = ER_OUT_OF_VIRTUAL_MEMORY;
4841  goto error;
4842  }
4843 
4844  ptr = or_pack_string_with_length (request, name, len);
4845  ptr = or_pack_int (ptr, get_xasl_header);
4846 
4847  req_error =
4849  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &reply_data, &reply_size);
4850  if (req_error != NO_ERROR)
4851  {
4852  goto error;
4853  }
4854 
4855  reply = OR_ALIGNED_BUF_START (a_reply);
4856  /* unpack reply_size */
4857  ptr = or_unpack_int (reply, &req_error);
4858  /* unpack error code */
4859  ptr = or_unpack_int (ptr, &req_error);
4860  if (req_error != NO_ERROR)
4861  {
4862  /* there was an error fetching session data */
4863  goto error;
4864  }
4865  OR_UNPACK_XASL_ID (ptr, xasl_id);
4866 
4867  ptr = or_unpack_string_alloc (reply_data, stmt_info);
4868  if (*stmt_info == NULL)
4869  {
4870  req_error = ER_GENERIC_ERROR;
4871  goto error;
4872  }
4873  if (get_xasl_header)
4874  {
4875  OR_UNPACK_XASL_NODE_HEADER (ptr, xasl_header_p);
4876  }
4877 
4878  if (request != NULL)
4879  {
4880  free_and_init (request);
4881  }
4882  if (reply_data != NULL)
4883  {
4884  free_and_init (reply_data);
4885  }
4886  return req_error;
4887 
4888 error:
4889  if (request != NULL)
4890  {
4891  free_and_init (request);
4892  }
4893  if (reply_data != NULL)
4894  {
4895  free_and_init (reply_data);
4896  }
4897 
4898  return req_error;
4899 #else
4900  int result = NO_ERROR;
4901  int stmt_info_len = 0;
4902 
4903  THREAD_ENTRY *thread_p = enter_server ();
4904 
4905  INIT_XASL_NODE_HEADER (xasl_header_p);
4906  result = xsession_get_prepared_statement (thread_p, name, stmt_info, &stmt_info_len, xasl_id, xasl_header_p);
4907 
4908  exit_server (*thread_p);
4909 
4910  return result;
4911 #endif
4912 }
4913 
4914 /*
4915  * csession_delete_prepared_statement () - delete a prepared session statement
4916  * return : error code or no error
4917  * name (in) : name of the prepared statement
4918  */
4919 int
4921 {
4922 #if defined (CS_MODE)
4923  int req_error;
4924  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4925  char *request = NULL;
4926  int name_len, req_len;
4927 
4928  req_len = length_const_string (name, &name_len);
4929 
4930  request = (char *) malloc (req_len);
4931  if (request == NULL)
4932  {
4934  return ER_FAILED;
4935  }
4936 
4937  pack_const_string_with_length (request, name, name_len);
4938 
4939  req_error =
4941  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
4942  if (request != NULL)
4943  {
4944  free_and_init (request);
4945  }
4946 
4947  if (req_error != NO_ERROR)
4948  {
4949  return ER_FAILED;
4950  }
4951 
4952  or_unpack_int (OR_ALIGNED_BUF_START (a_reply), &req_error);
4953 
4954  return req_error;
4955 #else
4956  int result = NO_ERROR;
4957 
4958  THREAD_ENTRY *thread_p = enter_server ();
4959 
4960  result = xsession_delete_prepared_statement (thread_p, name);
4961 
4962  exit_server (*thread_p);
4963 
4964  return result;
4965 #endif
4966 }
4967 
4968 /*
4969  * clogin_user () - login user
4970  * return : error code or NO_ERROR
4971  * username (in) : name of the user
4972  */
4973 int
4974 clogin_user (const char *username)
4975 {
4976 #if defined (CS_MODE)
4977  int req_error;
4978  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4979  char *request = NULL;
4980  int username_len, req_len;
4981 
4982  req_len = length_const_string (username, &username_len);
4983 
4984  request = (char *) malloc (req_len);
4985  if (request == NULL)
4986  {
4988  return ER_FAILED;
4989  }
4990 
4991  pack_const_string_with_length (request, username, username_len);
4992 
4993  req_error =
4995  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
4996  if (request != NULL)
4997  {
4998  free_and_init (request);
4999  }
5000 
5001  if (req_error != NO_ERROR)
5002  {
5003  return ER_FAILED;
5004  }
5005 
5006  or_unpack_int (OR_ALIGNED_BUF_START (a_reply), &req_error);
5007 
5008  return req_error;
5009 #else
5010  int result = NO_ERROR;
5011 
5012  THREAD_ENTRY *thread_p = enter_server ();
5013 
5014  result = xlogin_user (thread_p, username);
5015 
5016  exit_server (*thread_p);
5017 
5018  return result;
5019 #endif
5020 }
5021 
5022 /*
5023  * csession_set_session_variables () - set session variables
5024  * return : error code or NO_ERROR
5025  * variables (in) : variables
5026  * count (in) : count
5027  */
5028 int
5030 {
5031 #if defined (CS_MODE)
5032  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5033  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
5034  char *request = NULL, *data_request = NULL, *ptr = NULL;
5035  int req_size = 0, i = 0, err = NO_ERROR;
5036 
5037  request = OR_ALIGNED_BUF_START (a_request);
5038  or_pack_int (request, count);
5039 
5040  req_size = 0;
5041  for (i = 0; i < count; i++)
5042  {
5043  req_size += OR_VALUE_ALIGNED_SIZE (&variables[i]);
5044  }
5045 
5046  data_request = (char *) malloc (req_size);
5047  if (data_request == NULL)
5048  {
5050  err = ER_FAILED;
5051  goto cleanup;
5052  }
5053 
5054  ptr = data_request;
5055  for (i = 0; i < count; i++)
5056  {
5057  ptr = or_pack_db_value (ptr, &variables[i]);
5058  }
5059 
5060  err =
5062  OR_ALIGNED_BUF_SIZE (a_request), OR_ALIGNED_BUF_START (a_reply), OR_ALIGNED_BUF_SIZE (a_reply),
5063  data_request, req_size, NULL, 0);
5064  if (err != NO_ERROR)
5065  {
5066  goto cleanup;
5067  }
5068 
5069  or_unpack_int (OR_ALIGNED_BUF_START (a_reply), &err);
5070 
5071 cleanup:
5072  if (data_request != NULL)
5073  {
5074  free_and_init (data_request);
5075  }
5076 
5077  return err;
5078 #else
5079  int err = 0;
5080 
5081  THREAD_ENTRY *thread_p = enter_server ();
5082 
5083  err = xsession_set_session_variables (thread_p, variables, count);
5084 
5085  exit_server (*thread_p);
5086 
5087  return err;
5088 #endif
5089 }
5090 
5091 /*
5092  * csession_drop_session_variables () - drop session variables
5093  * return : error code or NO_ERROR
5094  * variables (in) : variables
5095  * count (in) : count
5096  */
5097 int
5099 {
5100 #if defined (CS_MODE)
5101  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5102  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
5103  char *request = NULL, *data_request = NULL, *ptr = NULL;
5104  int req_size = 0, i = 0, err = NO_ERROR;
5105 
5106  request = OR_ALIGNED_BUF_START (a_request);
5107  or_pack_int (request, count);
5108 
5109  req_size = 0;
5110  for (i = 0; i < count; i++)
5111  {
5112  req_size += OR_VALUE_ALIGNED_SIZE (&variables[i]);
5113  }
5114 
5115  data_request = (char *) malloc (req_size);
5116  if (data_request == NULL)
5117  {
5119  err = ER_FAILED;
5120  goto cleanup;
5121  }
5122 
5123  ptr = data_request;
5124  for (i = 0; i < count; i++)
5125  {
5126  ptr = or_pack_db_value (ptr, &variables[i]);
5127  }
5128 
5129  err =
5131  OR_ALIGNED_BUF_SIZE (a_request), OR_ALIGNED_BUF_START (a_reply), OR_ALIGNED_BUF_SIZE (a_reply),
5132  data_request, req_size, NULL, 0);
5133  if (err != NO_ERROR)
5134  {
5135  goto cleanup;
5136  }
5137 
5138  or_unpack_int (OR_ALIGNED_BUF_START (a_reply), &err);
5139 
5140 cleanup:
5141  if (data_request != NULL)
5142  {
5143  free_and_init (data_request);
5144  }
5145 
5146  return err;
5147 #else
5148  int err = 0;
5149 
5150  THREAD_ENTRY *thread_p = enter_server ();
5151 
5152  err = xsession_drop_session_variables (thread_p, variables, count);
5153 
5154  exit_server (*thread_p);
5155 
5156  return err;
5157 #endif
5158 }
5159 
5160 /*
5161  * csession_get_variable () - get the value of a session variable
5162  * return : error code or NO_ERROR
5163  * name (in) : the name of the session variable
5164  * value (out) : the value of the session variable
5165  */
5166 int
5168 {
5169 #if defined (CS_MODE)
5170  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
5171  char *request = NULL, *reply = NULL, *ptr = NULL;
5172  int req_size = 0, err = NO_ERROR, reply_size = 0;
5173 
5174  assert (value != NULL);
5175 
5176  req_size = OR_VALUE_ALIGNED_SIZE (name);
5177 
5178  request = (char *) malloc (req_size);
5179  if (request == NULL)
5180  {
5182  return ER_FAILED;
5183  }
5184 
5185  or_pack_db_value (request, name);
5186 
5187  err =
5189  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &reply, &reply_size);
5190  if (err != NO_ERROR)
5191  {
5192  goto cleanup;
5193  }
5194 
5195  /* a_reply contains reply_size code and error code */
5196  ptr = OR_ALIGNED_BUF_START (a_reply);
5197  ptr = or_unpack_int (ptr, &err);
5198  ptr = or_unpack_int (ptr, &err);
5199  if (err != NO_ERROR)
5200  {
5201  goto cleanup;
5202  }
5203 
5204  or_unpack_db_value (reply, value);
5205 
5206 cleanup:
5207  if (request != NULL)
5208  {
5209  free_and_init (request);
5210  }
5211  if (reply != NULL)
5212  {
5213  free_and_init (reply);
5214  }
5215 
5216  return err;
5217 #else
5218  int err = NO_ERROR;
5219  DB_VALUE *val_ref = NULL;
5220 
5221  THREAD_ENTRY *thread_p = enter_server ();
5222  /* we cannot use the allocation methods from the server context so we will just get a reference here */
5223  err = xsession_get_session_variable_no_copy (thread_p, name, &val_ref);
5224 
5225  exit_server (*thread_p);
5226 
5227  if (err == NO_ERROR)
5228  {
5229  assert (val_ref != NULL);
5230  /* create a clone of this value to be used in the client scope */
5231  pr_clone_value (val_ref, value);
5232  }
5233  else
5234  {
5235  db_make_null (value);
5236  }
5237  return err;
5238 #endif
5239 }
5240 
5241 /*
5242  * boot_soft_rename -
5243  *
5244  * return:
5245  *
5246  * NOTE:
5247  */
5248 int
5249 boot_soft_rename (const char *old_db_name, const char *new_db_name, const char *new_db_path, const char *new_log_path,
5250  const char *new_db_server_host, const char *new_volext_path, const char *fileof_vols_and_renamepaths,
5251  bool new_db_overwrite, bool extern_rename, bool force_delete)
5252 {
5253 #if defined(CS_MODE)
5254  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_ONLY_IN_STANDALONE, 1, "install database");
5255  return ER_FAILED;
5256 #else /* CS_MODE */
5257  int error_code;
5258 
5259  THREAD_ENTRY *thread_p = enter_server ();
5260 
5261  error_code =
5262  xboot_soft_rename (thread_p, old_db_name, new_db_name, new_db_path, new_log_path, new_db_server_host,
5263  new_volext_path, fileof_vols_and_renamepaths, new_db_overwrite, extern_rename, force_delete);
5264 
5265  exit_server (*thread_p);
5266 
5267  return error_code;
5268 #endif /* !CS_MODE */
5269 }
5270 
5271 /*
5272  * boot_copy () - copy the database to a new destination
5273  *
5274  * return : NO_ERROR if all OK, ER_ status otherwise
5275  *
5276  * fromdb_name(in): The database from where the copy is made.
5277  * newdb_name(in): Name of new database
5278  * newdb_path(in): Directory where the new database will reside
5279  * newlog_path(in): Directory where the log volumes of the new database will reside
5280  * new_lob_path(in): Directory where the lob volumes of the new database will reside
5281  * newdb_server_host(in): Server host where the new database reside
5282  * new_volext_path(in): A path is included if all volumes are placed in one place/directory. If NULL is given,
5283  * - If file "fileof_vols_and_wherepaths" is given, the path is found in this file.
5284  * - Each volume is copied to same place where the volume resides.
5285  * Note: This parameter should be NULL, if the above file is given.
5286  * fileof_vols_and_wherepaths(in): A file is given when the user decides to control the copy/rename of the volume by
5287  * individual bases. That is, user decides to spread the volumes over several locations and
5288  * or to label the volumes with specific names.
5289  * Each volume entry consists of: volid from_fullvolname to_fullvolname
5290  * newdb_overwrite(in): Whether to overwrite the new database if it already exist.
5291  */
5292 int
5293 boot_copy (const char *from_dbname, const char *new_db_name, const char *new_db_path, const char *new_log_path,
5294  const char *new_lob_path, const char *new_db_server_host,
5295  const char *new_volext_path, const char *fileof_vols_and_copypaths, bool new_db_overwrite)
5296 {
5297 #if defined(CS_MODE)
5299  return ER_FAILED;
5300 #else /* CS_MODE */
5301  int error_code;
5302 
5303  THREAD_ENTRY *thread_p = enter_server ();
5304 
5305  error_code =
5306  xboot_copy (thread_p, from_dbname, new_db_name, new_db_path, new_log_path, new_lob_path, new_db_server_host,
5307  new_volext_path, fileof_vols_and_copypaths, new_db_overwrite);
5308  assert (thread_p == NULL);
5309 
5310  exit_server_no_thread_entry ();
5311 
5312  return error_code;
5313 #endif /* !CS_MODE */
5314 }
5315 
5316 /*
5317  * boot_emergency_patch -
5318  *
5319  * return:
5320  *
5321  * NOTE:
5322  */
5323 int
5324 boot_emergency_patch (const char *db_name, bool recreate_log, DKNPAGES log_npages, const char *db_locale, FILE * out_fp)
5325 {
5326 #if defined(CS_MODE)
5327  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_ONLY_IN_STANDALONE, 1, "emergency patch");
5328  return ER_FAILED;
5329 #else /* CS_MODE */
5330  int error_code;
5331 
5332  enter_server_no_thread_entry ();
5333 
5334  error_code = xboot_emergency_patch (db_name, recreate_log, log_npages, db_locale, out_fp);
5335 
5336  exit_server_no_thread_entry ();
5337 
5338  return error_code;
5339 #endif /* !CS_MODE */
5340 }
5341 
5342 /*
5343  * boot_change_ha_mode - change server's HA state
5344  * return: new state
5345  */
5347 boot_change_ha_mode (HA_SERVER_STATE state, bool force, int timeout)
5348 {
5349 #if defined(CS_MODE)
5350  int req_error;
5351  int server_state;
5352  HA_SERVER_STATE cur_state = HA_SERVER_STATE_NA;
5353  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5354  char *reply;
5356  char *request;
5357  char *ptr;
5358 
5359  reply = OR_ALIGNED_BUF_START (a_reply);
5360  request = OR_ALIGNED_BUF_START (a_request);
5361 
5362  ptr = or_pack_int (request, (int) state);
5363  ptr = or_pack_int (ptr, (int) force);
5364  ptr = or_pack_int (ptr, (int) timeout);
5365 
5366  req_error =
5368  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
5369  if (!req_error)
5370  {
5371  or_unpack_int (reply, &server_state);
5372  cur_state = (HA_SERVER_STATE) server_state;
5373  }
5374 
5375  return cur_state;
5376 #else /* CS_MODE */
5377  /* Cannot run in standalone mode */
5379  return HA_SERVER_STATE_NA;
5380 #endif /* !CS_MODE */
5381 }
5382 
5383 /*
5384  * boot_notify_ha_log_applier_state - notify log applier's state to the server
5385  * return: NO_ERROR or ER_FAILED
5386  */
5387 int
5389 {
5390 #if defined(CS_MODE)
5391  int req_error, status = ER_FAILED;
5392  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5393  char *reply;
5394  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
5395  char *request;
5396  char *ptr;
5397 
5398  reply = OR_ALIGNED_BUF_START (a_reply);
5399  request = OR_ALIGNED_BUF_START (a_request);
5400 
5401  ptr = or_pack_int (request, (int) state);
5402 
5403  req_error =
5405  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
5406  if (!req_error)
5407  {
5408  or_unpack_int (reply, &status);
5409  }
5410 
5411  return status;
5412 #else /* CS_MODE */
5413  /* Cannot run in standalone mode */
5415  return ER_FAILED;
5416 #endif /* !CS_MODE */
5417 }
5418 
5419 /*
5420  * stats_get_statistics_from_server () -
5421  *
5422  * return: error code
5423  *
5424  * classoid(in):
5425  * timestamp(in):
5426  * length_ptr(in):
5427  * stats_buffer(in/out):
5428  *
5429  * NOTE:
5430  */
5431 int
5432 stats_get_statistics_from_server (OID * classoid, unsigned int timestamp, int *length_ptr, char **stats_buffer)
5433 {
5434 #if defined(CS_MODE)
5435  int req_error;
5436  char *area = NULL;
5437  char *ptr;
5438  OR_ALIGNED_BUF (OR_OID_SIZE + OR_INT_SIZE) a_request;
5439  char *request;
5440  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5441  char *reply;
5442 
5443  assert (stats_buffer != NULL);
5444  *stats_buffer = NULL;
5445 
5446  request = OR_ALIGNED_BUF_START (a_request);
5447  reply = OR_ALIGNED_BUF_START (a_reply);
5448 
5449  ptr = or_pack_oid (request, classoid);
5450  ptr = or_pack_int (ptr, (int) timestamp);
5451 
5452  req_error =
5454  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, length_ptr);
5455  if (!req_error)
5456  {
5457  or_unpack_int (reply, length_ptr);
5458  *stats_buffer = area;
5459  }
5460 
5461  return req_error;
5462 #else /* CS_MODE */
5463  THREAD_ENTRY *thread_p = enter_server ();
5464 
5465  *stats_buffer = xstats_get_statistics_from_server (thread_p, classoid, timestamp, length_ptr);
5466 
5467  exit_server (*thread_p);
5468 
5469  return NO_ERROR;
5470 #endif /* !CS_MODE */
5471 }
5472 
5473 /*
5474  * stats_update_statistics -
5475  *
5476  * return:
5477  *
5478  * classoid(in):
5479  * with_fullscan(in):
5480  *
5481  * NOTE:
5482  */
5483 int
5484 stats_update_statistics (OID * classoid, int with_fullscan)
5485 {
5486 #if defined(CS_MODE)
5488  int req_error;
5489  OR_ALIGNED_BUF (OR_OID_SIZE + OR_INT_SIZE) a_request;
5490  char *request;
5491  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5492  char *reply;
5493  char *ptr;
5494 
5495  request = OR_ALIGNED_BUF_START (a_request);
5496  reply = OR_ALIGNED_BUF_START (a_reply);
5497 
5498  ptr = or_pack_oid (request, classoid);
5499  ptr = or_pack_int (ptr, with_fullscan);
5500 
5501  req_error =
5503  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
5504  if (!req_error)
5505  {
5506  or_unpack_errcode (reply, &error);
5507  }
5508 
5509  return error;
5510 #else /* CS_MODE */
5511  int success;
5512 
5513  THREAD_ENTRY *thread_p = enter_server ();
5514 
5515  success = xstats_update_statistics (thread_p, classoid, (with_fullscan ? STATS_WITH_FULLSCAN : STATS_WITH_SAMPLING));
5516 
5517  exit_server (*thread_p);
5518 
5519  return success;
5520 #endif /* !CS_MODE */
5521 }
5522 
5523 /*
5524  * stats_update_all_statistics -
5525  *
5526  * return:
5527  * with_fullscan(in): true iff WITH FULLSCAN
5528  *
5529  * NOTE:
5530  */
5531 int
5532 stats_update_all_statistics (int with_fullscan)
5533 {
5534 #if defined(CS_MODE)
5536  int req_error;
5537  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
5538  char *request;
5539  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5540  char *reply;
5541  char *ptr;
5542 
5543  request = OR_ALIGNED_BUF_START (a_request);
5544  reply = OR_ALIGNED_BUF_START (a_reply);
5545 
5546  ptr = or_pack_int (request, with_fullscan);
5547 
5548  req_error =
5550  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
5551  if (!req_error)
5552  {
5553  or_unpack_errcode (reply, &error);
5554  }
5555 
5556  return error;
5557 #else /* CS_MODE */
5558  int success;
5559 
5560  THREAD_ENTRY *thread_p = enter_server ();
5561 
5562  success = xstats_update_all_statistics (thread_p, (with_fullscan ? STATS_WITH_FULLSCAN : STATS_WITH_SAMPLING));
5563 
5564  exit_server (*thread_p);
5565 
5566  return success;
5567 #endif /* !CS_MODE */
5568 }
5569 
5570 /*
5571  * btree_add_index () -
5572  *
5573  * return:
5574  *
5575  * btid(in):
5576  * key_type(in):
5577  * class_oid(in):
5578  * attr_id(in):
5579  * unique_pk(in):
5580  *
5581  * NOTE:
5582  */
5583 int
5584 btree_add_index (BTID * btid, TP_DOMAIN * key_type, OID * class_oid, int attr_id, int unique_pk)
5585 {
5586 #if defined(CS_MODE)
5587  int error = NO_ERROR;
5588  int req_error, request_size, domain_size;
5589  char *ptr;
5590  char *request;
5592  char *reply;
5593 
5594  reply = OR_ALIGNED_BUF_START (a_reply);
5595 
5596  domain_size = or_packed_domain_size (key_type, 0);
5597  request_size = OR_BTID_ALIGNED_SIZE + domain_size + OR_OID_SIZE + OR_INT_SIZE + OR_INT_SIZE;
5598 
5599  request = (char *) malloc (request_size);
5600  if (request == NULL)
5601  {
5602  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
5603  return ER_OUT_OF_VIRTUAL_MEMORY;
5604  }
5605 
5606  ptr = or_pack_btid (request, btid);
5607  ptr = or_pack_domain (ptr, key_type, 0, 0);
5608  ptr = or_pack_oid (ptr, class_oid);
5609  ptr = or_pack_int (ptr, attr_id);
5610  ptr = or_pack_int (ptr, unique_pk);
5611 
5612  req_error =
5613  net_client_request (NET_SERVER_BTREE_ADDINDEX, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
5614  NULL, 0, NULL, 0);
5615  if (!req_error)
5616  {
5617  ptr = or_unpack_int (reply, &error);
5618  ptr = or_unpack_btid (ptr, btid);
5619  if (error != NO_ERROR)
5620  {
5621  btid = NULL;
5622  }
5623  }
5624  else
5625  {
5626  error = req_error;
5627  }
5628 
5629  free_and_init (request);
5630 
5631  return error;
5632 #else /* CS_MODE */
5633  int error = NO_ERROR;
5634 
5635  THREAD_ENTRY *thread_p = enter_server ();
5636 
5637  btid = xbtree_add_index (thread_p, btid, key_type, class_oid, attr_id, unique_pk, 0, 0, 0);
5638  if (btid == NULL)
5639  {
5640  assert (er_errid () != NO_ERROR);
5641  error = er_errid ();
5642  }
5643 
5644  exit_server (*thread_p);
5645 
5646  return error;
5647 #endif /* !CS_MODE */
5648 }
5649 
5650 /*
5651  * btree_load_index -
5652  *
5653  * return:
5654  *
5655  * btid(in):
5656  * bt_name(in):
5657  * key_type(in):
5658  * class_oids(in):
5659  * n_classes(in):
5660  * n_attrs(in):
5661  * attr_ids(in):
5662  * hfids(in):
5663  * unique_pk(in):
5664  * fk_refcls_oid(in):
5665  * fk_refcls_pk_btid(in):
5666  * fk_name(in):
5667  *
5668  * NOTE:
5669  */
5670 int
5671 btree_load_index (BTID * btid, const char *bt_name, TP_DOMAIN * key_type, OID * class_oids, int n_classes, int n_attrs,
5672  int *attr_ids, int *attrs_prefix_length, HFID * hfids, int unique_pk, int not_null_flag,
5673  OID * fk_refcls_oid, BTID * fk_refcls_pk_btid, const char *fk_name, char *pred_stream,
5674  int pred_stream_size, char *expr_stream, int expr_stream_size, int func_col_id,
5675  int func_attr_index_start, SM_INDEX_STATUS index_status)
5676 {
5677 #if defined(CS_MODE)
5678  int error = NO_ERROR, req_error, request_size, domain_size;
5679  char *ptr;
5680  char *request;
5682  char *reply;
5683  int i, total_attrs, bt_strlen, fk_strlen;
5684  int index_info_size = 0;
5685  char *stream = NULL;
5686  int stream_size = 0;
5687  LOCK curr_cls_lock = SCH_M_LOCK;
5688 
5689  // online index should have created the empty b-tree already
5690  assert (index_status != SM_ONLINE_INDEX_BUILDING_IN_PROGRESS || !BTID_IS_NULL (btid));
5691 
5692  reply = OR_ALIGNED_BUF_START (a_reply);
5693 
5694  if (pred_stream && expr_stream)
5695  {
5696  return ER_FAILED;
5697  }
5698 
5699  index_info_size = (OR_INT_SIZE /* index info type */
5700  + (pred_stream ? OR_INT_SIZE : 0) + (expr_stream ? OR_INT_SIZE * 3 : 0));
5701 
5702  domain_size = or_packed_domain_size (key_type, 0);
5703  request_size = (OR_BTID_ALIGNED_SIZE /* BTID */
5704  + or_packed_string_length (bt_name, &bt_strlen) /* index name */
5705  + domain_size /* key_type */
5706  + (n_classes * OR_OID_SIZE) /* class_oids */
5707  + OR_INT_SIZE /* n_classes */
5708  + OR_INT_SIZE /* n_attrs */
5709  + (n_classes * n_attrs * OR_INT_SIZE) /* attr_ids */
5710  + ((n_classes == 1) ? (n_attrs * OR_INT_SIZE) : 0) /* attrs_prefix_length */
5711  + (n_classes * OR_HFID_SIZE) /* hfids */
5712  + OR_INT_SIZE /* unique_pk */
5713  + OR_INT_SIZE /* not_null_flag */
5714  + OR_OID_SIZE /* fk_refcls_oid */
5715  + OR_BTID_ALIGNED_SIZE /* fk_refcls_pk_btid */
5716  + or_packed_string_length (fk_name, &fk_strlen) /* fk_name */
5717  + index_info_size /* filter predicate or function index stream size */
5718  + OR_INT_SIZE /* Index status */
5719  + OR_INT_SIZE /* Thread count */ );
5720 
5721  request = (char *) malloc (request_size);
5722  if (request == NULL)
5723  {
5724  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
5725  return ER_OUT_OF_VIRTUAL_MEMORY;
5726  }
5727 
5728  ptr = or_pack_btid (request, btid);
5729  ptr = or_pack_string_with_length (ptr, bt_name, bt_strlen);
5730  ptr = or_pack_domain (ptr, key_type, 0, 0);
5731  ptr = or_pack_int (ptr, n_classes);
5732  ptr = or_pack_int (ptr, n_attrs);
5733 
5734  for (i = 0; i < n_classes; i++)
5735  {
5736  ptr = or_pack_oid (ptr, &class_oids[i]);
5737  }
5738 
5739  total_attrs = n_classes * n_attrs;
5740  for (i = 0; i < total_attrs; i++)
5741  {
5742  ptr = or_pack_int (ptr, attr_ids[i]);
5743  }
5744 
5745  if (n_classes == 1)
5746  {
5747  for (i = 0; i < n_attrs; i++)
5748  {
5749  if (attrs_prefix_length)
5750  {
5751  ptr = or_pack_int (ptr, attrs_prefix_length[i]);
5752  }
5753  else
5754  {
5755  ptr = or_pack_int (ptr, -1);
5756  }
5757  }
5758  }
5759 
5760  for (i = 0; i < n_classes; i++)
5761  {
5762  ptr = or_pack_hfid (ptr, &hfids[i]);
5763  }
5764 
5765  ptr = or_pack_int (ptr, unique_pk);
5766  ptr = or_pack_int (ptr, not_null_flag);
5767 
5768  ptr = or_pack_oid (ptr, fk_refcls_oid);
5769  ptr = or_pack_btid (ptr, fk_refcls_pk_btid);
5770  ptr = or_pack_string_with_length (ptr, fk_name, fk_strlen);
5771 
5772  if (pred_stream)
5773  {
5774  ptr = or_pack_int (ptr, 0);
5775  ptr = or_pack_int (ptr, pred_stream_size);
5776  stream = pred_stream;
5777  stream_size = pred_stream_size;
5778  }
5779  else if (expr_stream)
5780  {
5781  ptr = or_pack_int (ptr, 1);
5782  ptr = or_pack_int (ptr, expr_stream_size);
5783  ptr = or_pack_int (ptr, func_col_id);
5784  ptr = or_pack_int (ptr, func_attr_index_start);
5785  stream = expr_stream;
5786  stream_size = expr_stream_size;
5787  }
5788  else
5789  {
5790  ptr = or_pack_int (ptr, -1); /* stream=NULL, stream_size=0 */
5791  }
5792 
5793  ptr = or_pack_int (ptr, index_status); /* Index status. */
5794  ptr = or_pack_int (ptr, ib_get_thread_count ()); // Thread count needed for parallel building
5795 
5796  req_error =
5797  net_client_request (NET_SERVER_BTREE_LOADINDEX, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
5798  stream, stream_size, NULL, 0);
5799 
5800  if (req_error == NO_ERROR)
5801  {
5802  int t;
5803 
5804  ptr = or_unpack_int (reply, &error);
5805 
5806  ptr = or_unpack_int (ptr, &t);
5807  curr_cls_lock = (LOCK) t;
5808 
5809  if (index_status == SM_ONLINE_INDEX_BUILDING_IN_PROGRESS)
5810  {
5811  BTID local_btid;
5812  ptr = or_unpack_btid (ptr, &local_btid);
5813  if (error != NO_ERROR)
5814  {
5815  btid = NULL;
5816  }
5817  assert (!BTID_IS_NULL (&local_btid));
5818  }
5819  else
5820  {
5821  ptr = or_unpack_btid (ptr, btid);
5822  if (error != NO_ERROR)
5823  {
5824  btid = NULL;
5825  }
5826  }
5827  }
5828  else
5829  {
5830  btid = NULL;
5831  error = req_error;
5832  }
5833 
5834  if (index_status == SM_ONLINE_INDEX_BUILDING_IN_PROGRESS && curr_cls_lock != SCH_M_LOCK)
5835  {
5836  // hope it won't happen. server failed to restore the demoted lock.
5837  // It just help things don't go worse.
5838 
5839  MOP class_mop = ws_mop (&class_oids[0], sm_Root_class_mop);
5840  if (class_mop != NULL)
5841  {
5842  ws_set_lock (class_mop, curr_cls_lock);
5843  }
5844  }
5845 
5846  free_and_init (request);
5847 
5848  return error;
5849 #else /* CS_MODE */
5850  int error = NO_ERROR;
5851 
5852  THREAD_ENTRY *thread_p = enter_server ();
5853 
5854  if (index_status == SM_ONLINE_INDEX_BUILDING_IN_PROGRESS)
5855  {
5856  btid =
5857  xbtree_load_online_index (thread_p, btid, bt_name, key_type, class_oids, n_classes, n_attrs, attr_ids,
5858  attrs_prefix_length, hfids, unique_pk, not_null_flag, fk_refcls_oid,
5859  fk_refcls_pk_btid, fk_name, pred_stream, pred_stream_size, expr_stream,
5860  expr_stream_size, func_col_id, func_attr_index_start, 1);
5861  }
5862  else
5863  {
5864  btid =
5865  xbtree_load_index (thread_p, btid, bt_name, key_type, class_oids, n_classes, n_attrs, attr_ids,
5866  attrs_prefix_length, hfids, unique_pk, not_null_flag, fk_refcls_oid, fk_refcls_pk_btid,
5867  fk_name, pred_stream, pred_stream_size, expr_stream, expr_stream_size, func_col_id,
5868  func_attr_index_start);
5869  }
5870 
5871  if (btid == NULL)
5872  {
5873  assert (er_errid () != NO_ERROR);
5874  error = er_errid ();
5875  }
5876  else
5877  {
5878  error = NO_ERROR;
5879  }
5880 
5881  exit_server (*thread_p);
5882 
5883  return error;
5884 #endif /* !CS_MODE */
5885 }
5886 
5887 /*
5888  * btree_delete_index -
5889  *
5890  * return:
5891  *
5892  * btid(in):
5893  *
5894  * NOTE:
5895  */
5896 int
5898 {
5899 #if defined(CS_MODE)
5900  int req_error, status = NO_ERROR;
5902  char *request;
5903  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5904  char *reply;
5905 
5906  request = OR_ALIGNED_BUF_START (a_request);
5907  reply = OR_ALIGNED_BUF_START (a_reply);
5908 
5909  (void) or_pack_btid (request, btid);
5910 
5911  req_error =
5913  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
5914  if (!req_error)
5915  {
5916  or_unpack_int (reply, &status);
5917  }
5918  else
5919  {
5920  status = req_error;
5921  }
5922 
5923  return status;
5924 #else /* CS_MODE */
5925  int success = ER_FAILED;
5926 
5927  THREAD_ENTRY *thread_p = enter_server ();
5928 
5929  success = xbtree_delete_index (thread_p, btid);
5930 
5931  exit_server (*thread_p);
5932 
5933  return success;
5934 #endif /* !CS_MODE */
5935 }
5936 
5937 /*
5938  * locator_log_force_nologging -
5939  *
5940  * return:
5941  *
5942  * NOTE:
5943  */
5944 int
5946 {
5947 #if defined(CS_MODE)
5949  return ER_FAILED;
5950 #else /* CS_MODE */
5951  int success = ER_FAILED;
5952 
5953  THREAD_ENTRY *thread_p = enter_server ();
5954 
5955  success = log_set_no_logging ();
5956 
5957  exit_server (*thread_p);
5958 
5959  return success;
5960 #endif /* !CS_MODE */
5961 }
5962 
5963 /*
5964  * locator_remove_class_from_index -
5965  *
5966  * return:
5967  *
5968  * oid(in):
5969  * btid(in):
5970  * hfid(in):
5971  *
5972  * NOTE:
5973  */
5974 int
5976 {
5977 #if defined(CS_MODE)
5978  char *request, *reply, *ptr;
5979  int req_error, status = NO_ERROR;
5981  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5982 
5983  request = OR_ALIGNED_BUF_START (a_request);
5984  reply = OR_ALIGNED_BUF_START (a_reply);
5985 
5986  ptr = or_pack_oid (request, oid);
5987  ptr = or_pack_btid (ptr, btid);
5988  ptr = or_pack_hfid (ptr, hfid);
5989 
5990  req_error =
5992  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
5993  if (!req_error)
5994  {
5995  or_unpack_int (reply, &status);
5996  }
5997  else
5998  {
5999  status = req_error;
6000  }
6001 
6002  return status;
6003 #else /* CS_MODE */
6004  int success = ER_FAILED;
6005 
6006  THREAD_ENTRY *thread_p = enter_server ();
6007 
6008  success = xlocator_remove_class_from_index (thread_p, oid, btid, hfid);
6009 
6010  exit_server (*thread_p);
6011 
6012  return success;
6013 #endif /* !CS_MODE */
6014 }
6015 
6016 /*
6017  * btree_find_unique -
6018  *
6019  * return:
6020  *
6021  * btid(in):
6022  * key(in):
6023  * class_oid(in):
6024  * oid(in):
6025  *
6026  * NOTE:
6027  */
6029 btree_find_unique (BTID * btid, DB_VALUE * key, OID * class_oid, OID * oid)
6030 {
6031 #if defined(CS_MODE)
6033  int req_error, request_size, key_size;
6034  char *ptr;
6035  char *request;
6037  char *reply;
6038  enum net_server_request request_id;
6039 
6040  if (btid == NULL || key == NULL || class_oid == NULL || oid == NULL)
6041  {
6043  return BTREE_ERROR_OCCURRED;
6044  }
6045 
6046  reply = OR_ALIGNED_BUF_START (a_reply);
6047 
6048  key_size = OR_VALUE_ALIGNED_SIZE (key);
6049  request_size = key_size + OR_OID_SIZE + OR_BTID_ALIGNED_SIZE;
6050 
6051  request = (char *) malloc (request_size);
6052  if (request == NULL)
6053  {
6054  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
6055  return BTREE_ERROR_OCCURRED;
6056  }
6057 
6058  ptr = request;
6059  ptr = or_pack_value (ptr, key);
6060  request_id = NET_SERVER_BTREE_FIND_UNIQUE;
6061 
6062  ptr = or_pack_oid (ptr, class_oid);
6063  ptr = or_pack_btid (ptr, btid);
6064 
6065  /* reset request_size as real packed size */
6066  request_size = CAST_BUFLEN (ptr - request);
6067 
6068  req_error =
6069  net_client_request (request_id, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
6070  if (!req_error)
6071  {
6072  int istatus;
6073  ptr = or_unpack_int (reply, &istatus);
6074  ptr = or_unpack_oid (ptr, oid);
6075  status = (BTREE_SEARCH) istatus;
6076  }
6077  else
6078  {
6079  OID_SET_NULL (oid);
6080  }
6081 
6082  free_and_init (request);
6083  return status;
6084 
6085 #else /* CS_MODE */
6087 
6088  if (btid == NULL || key == NULL || class_oid == NULL || oid == NULL)
6089  {
6091  return BTREE_ERROR_OCCURRED;
6092  }
6093 
6094  THREAD_ENTRY *thread_p = enter_server ();
6095  status = xbtree_find_unique (thread_p, btid, S_SELECT_WITH_LOCK, key, class_oid, oid, false);
6096  exit_server (*thread_p);
6097  return status;
6098 
6099 #endif /* !CS_MODE */
6100 }
6101 
6102 /*
6103  * btree_find_multi_uniques () - search a list of indexes of a specified class for a list of values
6104  * return: index search result or BTREE_ERROR_OCCURRED
6105  * class_oid (in) : class OID
6106  * pruning_type (in) : pruning type
6107  * btids (in) : list of indexes to search
6108  * keys (in) : list of values to search for
6109  * count (in) : number of indexes
6110  * op_type (in) : operation type
6111  * oids (in/out) : found OIDs
6112  * oids_count (in/out) : number of OIDs found
6113  */
6115 btree_find_multi_uniques (OID * class_oid, int pruning_type, BTID * btids, DB_VALUE * keys, int count,
6116  SCAN_OPERATION_TYPE op_type, OID ** oids, int *oids_count)
6117 {
6118 #if defined (CS_MODE)
6119  int req_error, req_size, area_size, i;
6120  /* reply contains area size and return code */
6121  OR_ALIGNED_BUF (2 * OR_INT_SIZE) a_reply;
6122  char *request = NULL, *ptr = NULL;
6123  char *area = NULL;
6125 
6126  /* compute request size */
6127  req_size = (OR_INT_SIZE /* number of indexes to search */
6128  + OR_INT_SIZE /* needs pruning */
6129  + OR_OID_SIZE /* class OID */
6130  + OR_INT_SIZE /* operation type */
6131  + (count * OR_BTID_ALIGNED_SIZE) /* indexes */ );
6132 
6133  for (i = 0; i < count; i++)
6134  {
6135  req_size += OR_VALUE_ALIGNED_SIZE (&keys[i]);
6136  }
6137 
6138  request = (char *) malloc (req_size);
6139  if (request == NULL)
6140  {
6142  result = BTREE_ERROR_OCCURRED;
6143  goto cleanup;
6144  }
6145 
6146  /* pack oid */
6147  ptr = or_pack_oid (request, class_oid);
6148  /* needs pruning */
6149  ptr = or_pack_int (ptr, pruning_type);
6150  /* operation type */
6151  ptr = or_pack_int (ptr, op_type);
6152  /* number of indexes */
6153  ptr = or_pack_int (ptr, count);
6154  /* indexes */
6155  for (i = 0; i < count; i++)
6156  {
6157  ptr = or_pack_btid (ptr, &btids[i]);
6158  }
6159  /* values */
6160  for (i = 0; i < count; i++)
6161  {
6162  ptr = or_pack_value (ptr, &keys[i]);
6163  }
6164 
6165  req_error =
6167  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
6168  if (req_error != NO_ERROR)
6169  {
6170  result = BTREE_ERROR_OCCURRED;
6171  goto cleanup;
6172  }
6173 
6174  /* skip over area_size */
6175  ptr = or_unpack_int (OR_ALIGNED_BUF_START (a_reply), &area_size);
6176 
6177  /* unpack error code returned from server */
6178  ptr = or_unpack_int (ptr, &req_error);
6179  if (req_error != NO_ERROR)
6180  {
6181  result = BTREE_ERROR_OCCURRED;
6182  goto cleanup;
6183  }
6184 
6185  /* if no data was returned, no offending OID was found */
6186  if (area_size == 0)
6187  {
6188  *oids = NULL;
6189  result = BTREE_KEY_NOTFOUND;
6190  goto cleanup;
6191  }
6192 
6193  /* unpack number of returned OIDs */
6194  ptr = or_unpack_int (area, oids_count);
6195  if (*oids_count == 0)
6196  {
6197  assert (false);
6198  *oids = NULL;
6199  result = BTREE_KEY_NOTFOUND;
6200  goto cleanup;
6201  }
6202  else
6203  {
6204  assert (*oids_count > 0);
6205  result = BTREE_KEY_FOUND;
6206  }
6207 
6208  *oids = (OID *) malloc ((*oids_count) * sizeof (OID));
6209  if (*oids == NULL)
6210  {
6212  result = BTREE_ERROR_OCCURRED;
6213  goto cleanup;
6214  }
6215 
6216  for (i = 0; i < *oids_count; i++)
6217  {
6218  ptr = or_unpack_oid (ptr, &((*oids)[i]));
6219  }
6220 
6221 cleanup:
6222  if (request != NULL)
6223  {
6224  free_and_init (request);
6225  }
6226  if (area != NULL)
6227  {
6228  free_and_init (area);
6229  }
6230  if (result != BTREE_KEY_FOUND)
6231  {
6232  *oids_count = 0;
6233  *oids = NULL;
6234  }
6235  return result;
6236 
6237 #else
6239  OID *local_oids = NULL;
6240  int local_count = 0;
6241 
6242  THREAD_ENTRY *thread_p = enter_server ();
6243 
6244  result =
6245  xbtree_find_multi_uniques (thread_p, class_oid, pruning_type, btids, keys, count, op_type, &local_oids,
6246  &local_count);
6247  if (result == BTREE_ERROR_OCCURRED)
6248  {
6249  exit_server (*thread_p);
6250  return result;
6251  }
6252 
6253  /* need to copy memory from server context to local context */
6254  if (local_count > 0)
6255  {
6256  *oids = (OID *) malloc (local_count * sizeof (OID));
6257  if (*oids == NULL)
6258  {
6259  db_private_free (thread_p, local_oids);
6260  exit_server (*thread_p);
6261  return BTREE_ERROR_OCCURRED;
6262  }
6263  *oids_count = local_count;
6264  memcpy (*oids, local_oids, local_count * sizeof (OID));
6265  db_private_free (thread_p, local_oids);
6266  }
6267 
6268  exit_server (*thread_p);
6269 
6270  return result;
6271 #endif
6272 }
6273 
6274 /*
6275  * btree_class_test_unique -
6276  *
6277  * return:
6278  *
6279  * buf(in):
6280  * buf_size(in):
6281  *
6282  * NOTE:
6283  */
6284 int
6285 btree_class_test_unique (char *buf, int buf_size)
6286 {
6287 #if defined(CS_MODE)
6288  int req_error, status = NO_ERROR;
6289  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6290  char *reply;
6291 
6292  reply = OR_ALIGNED_BUF_START (a_reply);
6293 
6294  req_error =
6296  0, NULL, 0);
6297  if (!req_error)
6298  {
6299  or_unpack_int (reply, &status);
6300  }
6301  else
6302  {
6303  status = req_error;
6304  }
6305 
6306  return status;
6307 #else /* CS_MODE */
6308  int success = ER_FAILED;
6309 
6310  THREAD_ENTRY *thread_p = enter_server ();
6311 
6312  success = xbtree_class_test_unique (thread_p, buf, buf_size);
6313 
6314  exit_server (*thread_p);
6315 
6316  return success;
6317 #endif /* !CS_MODE */
6318 }
6319 
6320 /*
6321  * qfile_get_list_file_page -
6322  *
6323  * return:
6324  *
6325  * query_id(in):
6326  * volid(in):
6327  * pageid(in):
6328  * buffer(in):
6329  * buffer_size(in):
6330  *
6331  * NOTE:
6332  */
6333 int
6334 qfile_get_list_file_page (QUERY_ID query_id, VOLID volid, PAGEID pageid, char *buffer, int *buffer_size)
6335 {
6336 #if defined(CS_MODE)
6338  int req_error;
6339  char *ptr;
6341  char *request;
6342  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
6343  char *reply;
6344 
6345  request = OR_ALIGNED_BUF_START (a_request);
6346  reply = OR_ALIGNED_BUF_START (a_reply);
6347 
6348  ptr = or_pack_ptr (request, query_id);
6349  ptr = or_pack_int (ptr, (int) volid);
6350  ptr = or_pack_int (ptr, (int) pageid);
6351 
6352  req_error =
6354  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, buffer, buffer_size);
6355  if (!req_error)
6356  {
6357  ptr = or_unpack_int (&reply[OR_INT_SIZE], &error);
6358  }
6359 
6360  return error;
6361 #else /* CS_MODE */
6362  int success;
6363  int page_size;
6364 
6365  THREAD_ENTRY *thread_p = enter_server ();
6366 
6367  success = xqfile_get_list_file_page (thread_p, query_id, volid, pageid, buffer, &page_size);
6368 
6369  exit_server (*thread_p);
6370 
6371  return success;
6372 #endif /* !CS_MODE */
6373 }
6374 
6375 /*
6376  * qmgr_prepare_query - Send a SERVER_QM_PREPARE request to the server
6377  *
6378  * Send XASL stream and receive XASL file id (XASL_ID) as a result.
6379  * If xasl_buffer == NULL, the server will look up the XASL cache and then
6380  * return the cached XASL file id if found, otherwise return NULL.
6381  * This function is a counter part to sqmgr_prepare_query().
6382  *
6383  * return: Error Code.
6384  *
6385  * context(in): query string & plan
6386  * stream(in/out): xasl stream, size, xasl ID & xasl_header
6387  *
6388  * NOTE: If xasl_header_p is not null, also XASL node header will be requested
6389  */
6390 int
6392 {
6393 #if defined(CS_MODE)
6394  int error = NO_ERROR;
6395  int req_error, request_size = 0;
6396  int sql_hash_text_len, sql_plan_text_len, reply_buffer_size = 0;
6397  char *request = NULL, *reply = NULL, *ptr = NULL, *reply_buffer = NULL;
6399  int get_xasl_header = stream->xasl_header != NULL;
6400 
6402 
6403  reply = OR_ALIGNED_BUF_START (a_reply);
6404 
6405  /* sql hash text */
6406  request_size += length_const_string (context->sql_hash_text, &sql_hash_text_len);
6407 
6408  /* sql plan text */
6409  request_size += length_const_string (context->sql_plan_text, &sql_plan_text_len);
6410 
6411  /* sql user text */
6412  request_size += length_string_with_null_padding (context->sql_user_text_len);
6413 
6414  request_size += OR_INT_SIZE; /* size */
6415  request_size += OR_INT_SIZE; /* get_xasl_header */
6416  request_size += OR_INT_SIZE; /* whether to pin xasl cache entry */
6417  request_size += OR_INT_SIZE; /* whether to recompile the pinned xasl cache entry */
6418  request_size += OR_INT_SIZE; /* context->recompile_xasl */
6419  request_size += OR_SHA1_SIZE; /* sha1 */
6420 
6421  request = (char *) malloc (request_size);
6422  if (request == NULL)
6423  {
6424  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
6425  return ER_OUT_OF_VIRTUAL_MEMORY;
6426  }
6427 
6428  /* pack query alias string as a request data */
6429  ptr = pack_const_string_with_length (request, context->sql_hash_text, sql_hash_text_len);
6430  /* pack query plan as a request data */
6431  ptr = pack_const_string_with_length (ptr, context->sql_plan_text, sql_plan_text_len);
6432  /* pack query string as a request data */
6433  ptr = pack_string_with_null_padding (ptr, context->sql_user_text, context->sql_user_text_len);
6434 
6435  /* pack size of XASL stream */
6436  ptr = or_pack_int (ptr, stream->buffer_size);
6437  /* Pack get_xasl_header. */
6438  ptr = or_pack_int (ptr, get_xasl_header);
6439  /* Pack context. */
6440  ptr = or_pack_int (ptr, (int) context->is_xasl_pinned_reference);
6441  ptr = or_pack_int (ptr, (int) context->recompile_xasl_pinned);
6442  ptr = or_pack_int (ptr, (int) context->recompile_xasl);
6443  ptr = or_pack_sha1 (ptr, &context->sha1);
6444 
6445  /* send SERVER_QM_QUERY_PREPARE request with request data and XASL stream; receive XASL file id (XASL_ID) as a reply */
6446  req_error =
6447  net_client_request2 (NET_SERVER_QM_QUERY_PREPARE, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
6448  (char *) stream->buffer, stream->buffer_size, &reply_buffer, &reply_buffer_size);
6449  if (!req_error)
6450  {
6451  ptr = or_unpack_int (reply, &reply_buffer_size);
6452  ptr = or_unpack_int (ptr, &error);
6453  if (error == NO_ERROR)
6454  {
6455  /* NULL XASL_ID will be returned when cache not found */
6456  OR_UNPACK_XASL_ID (ptr, stream->xasl_id);
6457  context->recompile_xasl = false;
6458 
6459  if (reply_buffer != NULL && reply_buffer_size != 0)
6460  {
6461  ptr = reply_buffer;
6462  if (get_xasl_header)
6463  {
6464  OR_UNPACK_XASL_NODE_HEADER (ptr, stream->xasl_header);
6465  }
6466  if (ptr < reply_buffer + reply_buffer_size)
6467  {
6468  /* Doesn't really matter what it's packed... We need to force recompile; see sqmgr_prepare_query */
6469  assert ((ptr + OR_INT_SIZE) == (reply_buffer + reply_buffer_size));
6470  assert (!context->recompile_xasl);
6471  context->recompile_xasl = true;
6472  }
6473  }
6474  }
6475  else
6476  {
6477  ASSERT_ERROR ();
6478  }
6479  }
6480  else
6481  {
6482  error = req_error;
6483  }
6484 
6485  if (request != NULL)
6486  {
6487  free_and_init (request);
6488  }
6489 
6490  if (reply_buffer != NULL)
6491  {
6492  free_and_init (reply_buffer);
6493  }
6494 
6495  return error;
6496 #else /* CS_MODE */
6497  int error_code = NO_ERROR;
6498  XASL_STREAM server_stream;
6499 
6500  THREAD_ENTRY *thread_p = enter_server ();
6501 
6502  /* We cannot use the stream created on client context. XASL cache will save the stream in cache entry and it will
6503  * suppose the stream buffer was allocated using malloc.
6504  * Duplicate the stream for server context.
6505  */
6506  server_stream.xasl_id = stream->xasl_id;
6507  server_stream.xasl_header = stream->xasl_header;
6508  server_stream.buffer_size = stream->buffer_size;
6509  if (stream->buffer_size > 0)
6510  {
6511  server_stream.buffer = (char *) malloc (stream->buffer_size);
6512  if (server_stream.buffer == NULL)
6513  {
6514  exit_server (*thread_p);
6515 
6517  return ER_OUT_OF_VIRTUAL_MEMORY;
6518  }
6519  memcpy (server_stream.buffer, stream->buffer, stream->buffer_size);
6520  }
6521  else
6522  {
6523  /* No stream. This is just a lookup for existing entry. */
6524  server_stream.buffer = NULL;
6525  }
6526 
6527  INIT_XASL_NODE_HEADER (server_stream.xasl_header);
6528 
6529  /* call the server routine of query prepare */
6530  error_code = xqmgr_prepare_query (thread_p, context, &server_stream);
6531  if (server_stream.buffer != NULL)
6532  {
6533  free_and_init (server_stream.buffer);
6534  }
6535  if (error_code != NO_ERROR)
6536  {
6537  ASSERT_ERROR ();
6538  }
6539 
6540  exit_server (*thread_p);
6541 
6542  return error_code;
6543 
6544 #endif /* !CS_MODE */
6545 }
6546 
6547 /*
6548  * qmgr_execute_query - Send a SERVER_QM_EXECUTE request to the server
6549  *
6550  * Send XASL file id and parameter values if exist and receive list file id
6551  * that contains query result. If an error occurs, return NULL QFILE_LIST_ID.
6552  * This function is a counter part to sqmgr_execute_query().
6553  */
6554 /*
6555  * qmgr_execute_query -
6556  *
6557  * return:
6558  *
6559  * xasl_id(in):
6560  * query_idp(in):
6561  * dbval_cnt(in):
6562  * dbvals(in):
6563  * flag(in):
6564  * clt_cache_time(in):
6565  * srv_cache_time(in):
6566  * query_timeout(in):
6567  * end_of_queries(in):
6568  *
6569  * NOTE:
6570  */
6571 QFILE_LIST_ID *
6572 qmgr_execute_query (const XASL_ID * xasl_id, QUERY_ID * query_idp, int dbval_cnt, const DB_VALUE * dbvals,
6573  QUERY_FLAG flag, CACHE_TIME * clt_cache_time, CACHE_TIME * srv_cache_time, int query_timeout)
6574 {
6575 #if defined(CS_MODE)
6576  QFILE_LIST_ID *list_id = NULL;
6577  int req_error, senddata_size, replydata_size_listid, replydata_size_page, replydata_size_plan;
6578  char *request, *reply, *senddata = NULL;
6579  char *replydata_listid = NULL, *replydata_page = NULL, *replydata_plan = NULL, *ptr;
6583  int i, request_len;
6584  const DB_VALUE *dbval;
6585  CACHE_TIME local_srv_cache_time;
6586  int should_conn_reset, end_query_result, tran_state;
6587 
6588  request = OR_ALIGNED_BUF_START (a_request);
6589  reply = OR_ALIGNED_BUF_START (a_reply);
6590 
6591  /* make send data using if parameter values for host variables are given */
6592  senddata_size = 0;
6593  for (i = 0, dbval = dbvals; i < dbval_cnt; i++, dbval++)
6594  {
6595  senddata_size += OR_VALUE_ALIGNED_SIZE ((DB_VALUE *) dbval);
6596  }
6597  if (senddata_size != 0)
6598  {
6599  senddata = (char *) malloc (senddata_size);
6600  if (senddata == NULL)
6601  {
6602  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) senddata_size);
6603  return NULL;
6604  }
6605 
6606  ptr = senddata;
6607  for (i = 0, dbval = dbvals; i < dbval_cnt; i++, dbval++)
6608  {
6609  ptr = or_pack_db_value (ptr, (DB_VALUE *) dbval);
6610  }
6611 
6612  /* change senddata_size as real packing size */
6613  senddata_size = CAST_BUFLEN (ptr - senddata);
6614  if (senddata_size < EXECUTE_QUERY_MAX_ARGUMENT_DATA_SIZE)
6615  {
6617  }
6618  }
6619 
6620  /* pack XASL file id (XASL_ID), number of parameter values, size of the send data, and query execution mode flag as a
6621  * request data */
6622  ptr = request;
6623  OR_PACK_XASL_ID (ptr, xasl_id);
6624  ptr = or_pack_int (ptr, dbval_cnt);
6625  ptr = or_pack_int (ptr, senddata_size);
6626  ptr = or_pack_int (ptr, flag);
6627  OR_PACK_CACHE_TIME (ptr, clt_cache_time);
6628  ptr = or_pack_int (ptr, query_timeout);
6629 
6630  request_len = OR_XASL_ID_SIZE + OR_INT_SIZE * 4 + OR_CACHE_TIME_SIZE;
6631  if (IS_QUERY_EXECUTE_WITH_COMMIT (flag))
6632  {
6633  assert (net_Deferred_end_queries_count <= NET_DEFER_END_QUERIES_MAX);
6634  ptr = or_pack_int (ptr, net_Deferred_end_queries_count);
6635  for (i = 0; i < net_Deferred_end_queries_count; i++)
6636  {
6637  ptr = or_pack_ptr (ptr, net_Deferred_end_queries[i]);
6638  }
6639 
6640  request_len += OR_INT_SIZE + OR_PTR_SIZE * net_Deferred_end_queries_count;
6641  net_Deferred_end_queries_count = 0;
6642  }
6643 
6644  /* Add message in log in case of autocommit transactions. It helps to trace query execution. */
6646  {
6647  if (IS_QUERY_EXECUTE_WITH_COMMIT (flag))
6648  {
6649  er_log_debug (ARG_FILE_LINE, "qmgr_execute_query requested: EXECUTION_WITH_AUTOCOMMIT\n");
6650  }
6651  else
6652  {
6653  er_log_debug (ARG_FILE_LINE, "qmgr_execute_query requested: EXECUTION_WITHOUT_AUTOCOMMIT\n");
6654  }
6655  }
6656 
6658  {
6659  /* Execute without data buffers. The data has small size. Include the data in the argument buffer. */
6660  assert (senddata != NULL && 0 < senddata_size);
6661 
6662  memcpy (ptr, senddata, senddata_size);
6663  request_len += senddata_size;
6664 
6665  free_and_init (senddata);
6666  senddata_size = 0;
6667  }
6668  else
6669  {
6670  /* Execute with data buffer. The data has big size. */
6671  }
6672 
6673  req_error = net_client_request_with_callback (NET_SERVER_QM_QUERY_EXECUTE, request, request_len, reply,
6674  OR_ALIGNED_BUF_SIZE (a_reply), senddata, senddata_size, NULL, 0,
6675  &replydata_listid, &replydata_size_listid, &replydata_page,
6676  &replydata_size_page, &replydata_plan, &replydata_size_plan);
6677  if (replydata_plan != NULL)
6678  {
6679  db_set_execution_plan (replydata_plan, replydata_size_plan);
6680  free_and_init (replydata_plan);
6681  }
6682 
6683  if (senddata != NULL)
6684  {
6685  free_and_init (senddata);
6686  }
6687 
6688  if (!req_error)
6689  {
6690  /* first argument should be QUERY_END ptr = or_unpack_int(reply, &status); */
6691  /* second argument should be the same with replydata_size_listid ptr = or_unpack_int(ptr, &listid_length); */
6692  /* third argument should be the same with replydata_size_page ptr = or_unpack_int(ptr, &page_size); */
6693  /* third argument should be the same with replydata_size_plan ptr = or_unpack_int(ptr, &plan_size); */
6694  /* fourth argument should be query_id */
6695  ptr = or_unpack_ptr (reply + OR_INT_SIZE * 4, query_idp);
6696  OR_UNPACK_CACHE_TIME (ptr, &local_srv_cache_time);
6697  if (srv_cache_time)
6698  {
6699  memcpy (srv_cache_time, &local_srv_cache_time, sizeof (CACHE_TIME));
6700  }
6701 
6702  if (IS_QUERY_EXECUTE_WITH_COMMIT (flag))
6703  {
6704  ptr = or_unpack_int (ptr, &end_query_result);
6705  ptr = or_unpack_int (ptr, &tran_state);
6706  ptr = or_unpack_int (ptr, &should_conn_reset);
6707 
6709  || tran_state == TRAN_UNACTIVE_ABORTED || tran_state == TRAN_UNACTIVE_ABORTED_INFORMING_PARTICIPANTS)
6710  {
6712  }
6713 
6714  tran_set_latest_query_status (end_query_result, tran_state, should_conn_reset);
6715  }
6716 
6717  if (replydata_listid && replydata_size_listid)
6718  {
6719  /* unpack list file id of query result from the reply data */
6720  ptr = or_unpack_unbound_listid (replydata_listid, (void **) (&list_id));
6721  /* QFILE_LIST_ID shipped with last page */
6722  if (replydata_size_page)
6723  {
6724  list_id->last_pgptr = replydata_page;
6725  }
6726  else
6727  {
6728  list_id->last_pgptr = NULL;
6729  }
6730  free_and_init (replydata_listid);
6731  }
6732  }
6733 
6734  return list_id;
6735 #else /* CS_MODE */
6736  QFILE_LIST_ID *list_id = NULL;
6737  DB_VALUE *server_db_values = NULL;
6738  OID *oid;
6739  int i;
6740 
6741  THREAD_ENTRY *thread_p = enter_server ();
6742 
6743  /* reallocate dbvals to use server allocation */
6744  if (dbval_cnt > 0)
6745  {
6746  size_t s = dbval_cnt * sizeof (DB_VALUE);
6747 
6748  server_db_values = (DB_VALUE *) db_private_alloc (thread_p, s);
6749  if (server_db_values == NULL)
6750  {
6751  goto cleanup;
6752  }
6753  for (i = 0; i < dbval_cnt; i++)
6754  {
6755  db_make_null (&server_db_values[i]);
6756  }
6757  for (i = 0; i < dbval_cnt; i++)
6758  {
6759  switch (DB_VALUE_TYPE (&dbvals[i]))
6760  {
6761  case DB_TYPE_OBJECT:
6762  /* server cannot handle objects, convert to OID instead */
6763  oid = ws_identifier (db_get_object (&dbvals[i]));
6764  if (oid != NULL)
6765  {
6766  db_make_oid (&server_db_values[i], oid);
6767  }
6768  break;
6769 
6770  default:
6771  /* Clone value */
6772  if (db_value_clone ((DB_VALUE *) (&dbvals[i]), &server_db_values[i]) != NO_ERROR)
6773  {
6774  goto cleanup;
6775  }
6776  break;
6777  }
6778  }
6779  }
6780  else
6781  {
6782  /* No dbvals */
6783  server_db_values = NULL;
6784  }
6785 
6786  /* call the server routine of query execute */
6787  list_id =
6788  xqmgr_execute_query (thread_p, xasl_id, query_idp, dbval_cnt, server_db_values, &flag, clt_cache_time,
6789  srv_cache_time, query_timeout, NULL);
6790 
6791 cleanup:
6792  if (server_db_values != NULL)
6793  {
6794  for (i = 0; i < dbval_cnt; i++)
6795  {
6796  db_value_clear (&server_db_values[i]);
6797  }
6798  db_private_free (thread_p, server_db_values);
6799  }
6800 
6801  exit_server (*thread_p);
6802 
6803  return list_id;
6804 #endif /* !CS_MODE */
6805 }
6806 
6807 /*
6808  * qmgr_prepare_and_execute_query -
6809  *
6810  * return:
6811  *
6812  * xasl_stream(in):
6813  * xasl_stream_size(in):
6814  * query_id(in):
6815  * dbval_cnt(in):
6816  * dbval_ptr(in):
6817  * flag(in):
6818  * query_timeout(in):
6819  *
6820  * NOTE:
6821  */
6822 QFILE_LIST_ID *
6823 qmgr_prepare_and_execute_query (char *xasl_stream, int xasl_stream_size, QUERY_ID * query_idp, int dbval_cnt,
6824  DB_VALUE * dbval_ptr, QUERY_FLAG flag, int query_timeout)
6825 {
6826 #if defined(CS_MODE)
6827  QFILE_LIST_ID *regu_result = NULL;
6828  int req_error, senddata_size, replydata_size_listid, replydata_size_page;
6829  int i, size;
6830  char *ptr, *senddata, *replydata;
6831  DB_VALUE *dbval;
6832  OR_ALIGNED_BUF (OR_INT_SIZE * 4) a_request;
6833  char *request;
6835  char *reply;
6836  char *page_ptr;
6837  int page_size, dummy_plan_size;
6838 
6839  request = OR_ALIGNED_BUF_START (a_request);
6840  reply = OR_ALIGNED_BUF_START (a_reply);
6841 
6842  senddata = NULL;
6843  senddata_size = 0;
6844  for (i = 0, dbval = dbval_ptr; i < dbval_cnt; i++, dbval++)
6845  {
6846  senddata_size += OR_VALUE_ALIGNED_SIZE (dbval);
6847  }
6848 
6849  if (senddata_size != 0)
6850  {
6851  senddata = (char *) malloc (senddata_size);
6852  if (senddata == NULL)
6853  {
6854  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) senddata_size);
6855  return NULL;
6856  }
6857  }
6858 
6859  ptr = or_pack_int (request, dbval_cnt);
6860  ptr = or_pack_int (ptr, senddata_size);
6861  ptr = or_pack_int (ptr, flag);
6862  ptr = or_pack_int (ptr, query_timeout);
6863 
6864  ptr = senddata;
6865  for (i = 0, dbval = dbval_ptr; i < dbval_cnt; i++, dbval++)
6866  {
6867  ptr = or_pack_db_value (ptr, dbval);
6868  }
6869 
6870  /* change senddata_size as real packing size */
6871  senddata_size = CAST_BUFLEN (ptr - senddata);
6872 
6874  OR_ALIGNED_BUF_SIZE (a_request), reply, OR_ALIGNED_BUF_SIZE (a_reply),
6875  xasl_stream, xasl_stream_size, senddata, senddata_size, &replydata,
6876  &replydata_size_listid, &page_ptr, &replydata_size_page, NULL, NULL);
6877  if (!req_error)
6878  {
6879  /* should be the same as replydata_size */
6880  ptr = or_unpack_int (&reply[OR_INT_SIZE], &size);
6881  ptr = or_unpack_int (ptr, &page_size);
6882  ptr = or_unpack_int (ptr, &dummy_plan_size);
6883  ptr = or_unpack_ptr (ptr, query_idp);
6884 
6885  /* not interested in the return size in the reply buffer, should do some kind of range checking here */
6886  if (replydata != NULL && size)
6887  {
6888  ptr = or_unpack_unbound_listid (replydata, (void **) (&regu_result));
6889  regu_result->last_pgptr = NULL;
6890  if (page_size)
6891  {
6892  regu_result->last_pgptr = page_ptr;
6893  }
6894 
6895  free_and_init (replydata);
6896  }
6897  }
6898 
6899  if (senddata != NULL)
6900  {
6901  free_and_init (senddata);
6902  }
6903 
6904  return regu_result;
6905 #else /* CS_MODE */
6906  QFILE_LIST_ID *regu_result;
6907 
6908  THREAD_ENTRY *thread_p = enter_server ();
6909 
6910  regu_result =
6911  xqmgr_prepare_and_execute_query (thread_p, xasl_stream, xasl_stream_size, query_idp, dbval_cnt, dbval_ptr, &flag,
6912  query_timeout);
6913 
6914  exit_server (*thread_p);
6915 
6916  return regu_result;
6917 #endif /* !CS_MODE */
6918 }
6919 
6920 /*
6921  * qmgr_end_query -
6922  *
6923  * return:
6924  *
6925  * query_id(in):
6926  *
6927  * NOTE:
6928  */
6929 int
6930 qmgr_end_query (QUERY_ID query_id)
6931 {
6932 #if defined(CS_MODE)
6933  int status = ER_FAILED;
6934  int req_error = NO_ERROR;
6935  int i = 0;
6936  OR_ALIGNED_BUF (OR_INT_SIZE /* number of query ids */
6937  + OR_PTR_SIZE * NET_DEFER_END_QUERIES_MAX /* query ids */
6938  + MAX_ALIGNMENT /* alignment */
6939  )a_request;
6940  char *request = NULL, *ptr = NULL;
6941  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6942  char *reply = NULL;
6943 
6944  net_Deferred_end_queries[net_Deferred_end_queries_count++] = query_id;
6945  if (net_Deferred_end_queries_count < NET_DEFER_END_QUERIES_MAX)
6946  {
6947  /* Do not create a request for now. Defer it until NET_DEFER_END_QUERIES_MAX requests are collected or until
6948  * commit/abort. */
6949  return NO_ERROR;
6950  }
6951  assert (net_Deferred_end_queries_count == NET_DEFER_END_QUERIES_MAX);
6952  net_Deferred_end_queries_count = 0;
6953 
6954  request = OR_ALIGNED_BUF_START (a_request);
6955  reply = OR_ALIGNED_BUF_START (a_reply);
6956 
6957  ptr = or_pack_int (request, NET_DEFER_END_QUERIES_MAX);
6958  for (i = 0; i < NET_DEFER_END_QUERIES_MAX; i++)
6959  {
6960  ptr = or_pack_ptr (ptr, net_Deferred_end_queries[i]);
6961  }
6962  assert (CAST_BUFLEN (ptr - request) <= (int) OR_ALIGNED_BUF_SIZE (a_request));
6963 
6964  req_error =
6965  net_client_request (NET_SERVER_QM_QUERY_END, request, CAST_BUFLEN (ptr - request), reply,
6966  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
6967  if (req_error == NO_ERROR)
6968  {
6969  or_unpack_int (reply, &status);
6970  }
6971  else
6972  {
6973  status = req_error;
6974  }
6975 
6976  return status;
6977 #else /* CS_MODE */
6978  int success = ER_FAILED;
6979 
6980  THREAD_ENTRY *thread_p = enter_server ();
6981 
6982  success = xqmgr_end_query (thread_p, query_id);
6983 
6984  exit_server (*thread_p);
6985 
6986  return success;
6987 #endif /* !CS_MODE */
6988 }
6989 
6990 /*
6991  * qm_query_drop_all_plan - Send a SERVER_QM_DROP_ALL_PLAN request to the server
6992  *
6993  * Request the server to clear all XASL cache entires out. When the client
6994  * want to delete all cached query plans, this function will be used.
6995  * This function is a counter part to sqmgr_drop_all_query_plans().
6996  */
6997 /*
6998  * qmgr_drop_all_query_plans -
6999  *
7000  * return:
7001  *
7002  * NOTE:
7003  */
7004 int
7006 {
7007 #if defined(CS_MODE)
7008  int status = ER_FAILED;
7009  int req_error, request_size;
7010  char *request, *reply;
7011  OR_ALIGNED_BUF (OR_XASL_ID_SIZE) a_request;
7012  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7013 
7014  request = OR_ALIGNED_BUF_START (a_request);
7015  request_size = OR_INT_SIZE;
7016  reply = OR_ALIGNED_BUF_START (a_reply);
7017 
7018  or_pack_int (request, 0); /* dummy parameter */
7019 
7020  /* send SERVER_QM_QUERY_DROP_ALL_PLANS request with request data; receive status code (int) as a reply */
7021  req_error =
7022  net_client_request (NET_SERVER_QM_QUERY_DROP_ALL_PLANS, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
7023  NULL, 0, NULL, 0);
7024  if (!req_error)
7025  {
7026  /* first argument should be status code (int) */
7027  (void) or_unpack_int (reply, &status);
7028  }
7029 
7030  return status;
7031 #else /* CS_MODE */
7032  int status;
7033 
7034  THREAD_ENTRY *thread_p = enter_server ();
7035 
7036  /* call the server routine of query drop plan */
7037  status = xqmgr_drop_all_query_plans (thread_p);
7038 
7039  exit_server (*thread_p);
7040 
7041  return status;
7042 #endif /* !CS_MODE */
7043 }
7044 
7045 /*
7046  * qmgr_dump_query_plans -
7047  *
7048  * return:
7049  *
7050  * outfp(in):
7051  *
7052  * NOTE:
7053  */
7054 void
7056 {
7057 #if defined(CS_MODE)
7058  int req_error;
7059 
7060  if (outfp == NULL)
7061  {
7062  outfp = stdout;
7063  }
7064 
7066 #else /* CS_MODE */
7067 
7068  THREAD_ENTRY *thread_p = enter_server ();
7069 
7070  xqmgr_dump_query_plans (thread_p, outfp);
7071 
7072  exit_server (*thread_p);
7073 #endif /* !CS_MODE */
7074 }
7075 
7076 /*
7077  * qmgr_dump_query_cache -
7078  *
7079  * return:
7080  *
7081  * outfp(in):
7082  *
7083  * NOTE:
7084  */
7085 void
7087 {
7088 #if defined(CS_MODE)
7089  int req_error;
7090 
7091  if (outfp == NULL)
7092  {
7093  outfp = stdout;
7094  }
7095 
7097 #else /* CS_MODE */
7098 
7099  THREAD_ENTRY *thread_p = enter_server ();
7100 
7101  xqmgr_dump_query_cache (thread_p, outfp);
7102 
7103  exit_server (*thread_p);
7104 #endif /* !CS_MODE */
7105 }
7106 
7107 #if defined(ENABLE_UNUSED_FUNCTION)
7108 /*
7109  * qp_get_sys_timestamp -
7110  *
7111  * return:
7112  *
7113  * value(in):
7114  *
7115  * NOTE:
7116  */
7117 int
7118 qp_get_sys_timestamp (DB_VALUE * value)
7119 {
7120 #if defined(CS_MODE)
7121  int req_error;
7122  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
7123  char *request;
7124  OR_ALIGNED_BUF (OR_UTIME_SIZE) a_reply;
7125  char *reply;
7126  DB_TIMESTAMP sysutime;
7127 
7128  request = OR_ALIGNED_BUF_START (a_request);
7129  reply = OR_ALIGNED_BUF_START (a_reply);
7130 
7131  req_error =
7133  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
7134  if (!req_error)
7135  {
7136  (void) or_unpack_utime (reply, &sysutime);
7137  db_make_timestamp (value, sysutime);
7138  }
7139 
7140  return req_error;
7141 #else /* CS_MODE */
7142 
7143  THREAD_ENTRY *thread_p = enter_server ();
7144 
7145  db_sys_timestamp (value);
7146 
7147  exit_server (*thread_p);
7148 
7149  return NO_ERROR;
7150 #endif /* !CS_MODE */
7151 }
7152 #endif /* ENABLE_UNUSED_FUNCTION */
7153 
7154 /*
7155  * serial_get_current_value -
7156  *
7157  * return:
7158  *
7159  * value(in):
7160  * oid(in):
7161  *
7162  * NOTE:
7163  */
7164 int
7165 serial_get_current_value (DB_VALUE * value, OID * oid_p, int cached_num)
7166 {
7167 #if defined(CS_MODE)
7168  int req_error, error = ER_NET_CLIENT_DATA_RECEIVE;
7169  char *request, *area = NULL;
7170  int area_size;
7171  OR_ALIGNED_BUF (OR_OID_SIZE + OR_INT_SIZE) a_request;
7173  char *reply, *ptr;
7174 
7175  request = OR_ALIGNED_BUF_START (a_request);
7176  reply = OR_ALIGNED_BUF_START (a_reply);
7177 
7178  ptr = or_pack_oid (request, oid_p);
7179  ptr = or_pack_int (ptr, cached_num);
7180 
7181  req_error =
7183  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
7184  if (!req_error && area != NULL)
7185  {
7186  ptr = or_unpack_int (reply, &area_size);
7187  ptr = or_unpack_int (ptr, &error);
7188  (void) or_unpack_value (area, value);
7189  free_and_init (area);
7190  }
7191 
7192  return error;
7193 #else /* CS_MODE */
7194  int error = NO_ERROR;
7195 
7196  THREAD_ENTRY *thread_p = enter_server ();
7197 
7198  error = xserial_get_current_value (thread_p, value, oid_p, cached_num);
7199 
7200  exit_server (*thread_p);
7201 
7202  return error;
7203 #endif /* !CS_MODE */
7204 }
7205 
7206 /*
7207  * serial_get_next_value -
7208  *
7209  * return:
7210  *
7211  * value(in):
7212  * oid(in):
7213  *
7214  * NOTE:
7215  */
7216 int
7217 serial_get_next_value (DB_VALUE * value, OID * oid_p, int cached_num, int num_alloc, int is_auto_increment)
7218 {
7219 #if defined(CS_MODE)
7220  int req_error, error = ER_NET_CLIENT_DATA_RECEIVE;
7221  char *request, *area = NULL;
7222  int area_size;
7223  OR_ALIGNED_BUF (OR_OID_SIZE + (OR_INT_SIZE * 3)) a_request;
7225  char *reply, *ptr;
7226 
7227  request = OR_ALIGNED_BUF_START (a_request);
7228  reply = OR_ALIGNED_BUF_START (a_reply);
7229 
7230  ptr = or_pack_oid (request, oid_p);
7231  ptr = or_pack_int (ptr, cached_num);
7232  ptr = or_pack_int (ptr, num_alloc);
7233  ptr = or_pack_int (ptr, is_auto_increment);
7234 
7235  req_error =
7237  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
7238  if (!req_error && area != NULL)
7239  {
7240  ptr = or_unpack_int (reply, &area_size);
7241  ptr = or_unpack_int (ptr, &error);
7242  (void) or_unpack_value (area, value);
7243  free_and_init (area);
7244  }
7245 
7246  return error;
7247 #else /* CS_MODE */
7248  int error;
7249 
7250  THREAD_ENTRY *thread_p = enter_server ();
7251 
7252  /*
7253  * If a client wants to generate AUTO_INCREMENT value during client-side
7254  * insertion, a server should update LAST_INSERT_ID on a session.
7255  */
7256  error = xserial_get_next_value (thread_p, value, oid_p, cached_num, num_alloc, is_auto_increment, true);
7257 
7258  exit_server (*thread_p);
7259 
7260  return error;
7261 #endif /* !CS_MODE */
7262 }
7263 
7264 /*
7265  * serial_decache -
7266  *
7267  * return: NO_ERROR or error status
7268  *
7269  * oid(in):
7270  *
7271  * NOTE:
7272  */
7273 int
7275 {
7276 #if defined(CS_MODE)
7277  int req_error;
7278  OR_ALIGNED_BUF (OR_OID_SIZE) a_request;
7279  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply; /* need dummy reply message */
7280  char *request;
7281  char *reply;
7282  int status;
7283 
7284  request = OR_ALIGNED_BUF_START (a_request);
7285  reply = OR_ALIGNED_BUF_START (a_reply);
7286 
7287  or_pack_oid (request, oid);
7288 
7289  req_error =
7291  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
7292  if (!req_error)
7293  {
7294  or_unpack_int (reply, &status);
7295  }
7296 
7297  return req_error;
7298 #else /* CS_MODE */
7299  THREAD_ENTRY *thread_p = enter_server ();
7300 
7301  xserial_decache (thread_p, oid);
7302 
7303  exit_server (*thread_p);
7304 
7305  return NO_ERROR;
7306 #endif /* !CS_MODE */
7307 }
7308 
7309 /*
7310  * perfmon_server_start_stats -
7311  *
7312  * return:
7313  *
7314  * NOTE:
7315  */
7316 int
7318 {
7319 #if defined(CS_MODE)
7320  int status = ER_FAILED;
7321  int req_error;
7322  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7323  char *reply;
7324 
7325  reply = OR_ALIGNED_BUF_START (a_reply);
7326 
7327  req_error =
7329  NULL, 0);
7330  if (!req_error)
7331  {
7332  or_unpack_int (reply, &status);
7333  }
7334 
7335  return (status);
7336 #else /* CS_MODE */
7337  THREAD_ENTRY *thread_p = enter_server ();
7338 
7339  perfmon_start_watch (thread_p);
7340 
7341  exit_server (*thread_p);
7342 
7343  return NO_ERROR;
7344 #endif /* !CS_MODE */
7345 }
7346 
7347 /*
7348  * perfmon_server_stop_stats -
7349  *
7350  * return:
7351  *
7352  * NOTE:
7353  */
7354 int
7356 {
7357 #if defined(CS_MODE)
7358  int req_error;
7359  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply; /* need dummy reply message */
7360  char *reply;
7361 
7362  reply = OR_ALIGNED_BUF_START (a_reply);
7363 
7364  req_error =
7366  0);
7367  if (!req_error)
7368  {
7369  return ER_FAILED;
7370  }
7371  return req_error;
7372 #else /* CS_MODE */
7373 
7374  THREAD_ENTRY *thread_p = enter_server ();
7375 
7376  perfmon_stop_watch (thread_p);
7377 
7378  exit_server (*thread_p);
7379  return NO_ERROR;
7380 #endif /* !CS_MODE */
7381 }
7382 
7383 /*
7384  * perfmon_server_copy_stats -
7385  *
7386  * return:
7387  *
7388  * to_stats(in):
7389  *
7390  * NOTE:
7391  */
7392 int
7393 perfmon_server_copy_stats (UINT64 * to_stats)
7394 {
7395 #if defined(CS_MODE)
7396  int req_error = NO_ERROR;
7397  char *reply;
7398  int nr_statistic_values;
7399 
7400  nr_statistic_values = perfmon_get_number_of_statistic_values ();
7401  reply = (char *) malloc (nr_statistic_values * OR_INT64_SIZE);
7402 
7403  if (reply == NULL)
7404  {
7406  (size_t) nr_statistic_values * OR_INT64_SIZE);
7407  return ER_OUT_OF_VIRTUAL_MEMORY;
7408  }
7409 
7410  req_error =
7411  net_client_request (NET_SERVER_MNT_SERVER_COPY_STATS, NULL, 0, reply, nr_statistic_values * OR_INT64_SIZE,
7412  NULL, 0, NULL, 0);
7413  if (!req_error)
7414  {
7415  perfmon_unpack_stats (reply, to_stats);
7416  }
7417  else
7418  {
7419  perfmon_Iscollecting_stats = false;
7420  }
7421 
7422  free_and_init (reply);
7423  return req_error;
7424 
7425 #else /* CS_MODE */
7426 
7427  THREAD_ENTRY *thread_p = enter_server ();
7428 
7429  xperfmon_server_copy_stats (thread_p, to_stats);
7430 
7431  exit_server (*thread_p);
7432  return NO_ERROR;
7433 #endif /* !CS_MODE */
7434 }
7435 
7436 /*
7437  * perfmon_server_copy_global_stats -
7438  *
7439  * return:
7440  *
7441  * to_stats(in):
7442  *
7443  * NOTE:
7444  */
7445 int
7447 {
7448 #if defined(CS_MODE)
7449  int req_error = NO_ERROR;
7450  char *reply = NULL;
7451  int nr_statistic_values;
7452 
7453  nr_statistic_values = perfmon_get_number_of_statistic_values ();
7454  reply = (char *) malloc (nr_statistic_values * OR_INT64_SIZE);
7455  if (reply == NULL)
7456  {
7458  (size_t) nr_statistic_values * OR_INT64_SIZE);
7459  return ER_OUT_OF_VIRTUAL_MEMORY;
7460  }
7461 
7463  nr_statistic_values * OR_INT64_SIZE, NULL, 0, NULL, 0);
7464  if (!req_error)
7465  {
7466  perfmon_unpack_stats (reply, to_stats);
7467  }
7468  else
7469  {
7470  perfmon_Iscollecting_stats = false;
7471  }
7472 
7473  free_and_init (reply);
7474  return req_error;
7475 #else /* CS_MODE */
7476 
7477  THREAD_ENTRY *thread_p = enter_server ();
7478 
7480 
7481  exit_server (*thread_p);
7482  return NO_ERROR;
7483 #endif /* !CS_MODE */
7484 }
7485 
7486 /*
7487  * catalog_check_rep_dir -
7488  *
7489  * return:
7490  *
7491  * class_id(in):
7492  * rep_dir_p(out):
7493  *
7494  * NOTE:
7495  */
7496 int
7498 {
7499 #if defined(CS_MODE)
7500  int req_error, status;
7501  OR_ALIGNED_BUF (OR_OID_SIZE) a_request;
7502  char *request;
7504  char *reply;
7505  char *ptr;
7506 
7507  request = OR_ALIGNED_BUF_START (a_request);
7508  reply = OR_ALIGNED_BUF_START (a_reply);
7509 
7510  ptr = or_pack_oid (request, class_id);
7511 
7512  req_error =
7514  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
7515 
7516  if (req_error)
7517  {
7518  status = ER_FAILED;
7519  }
7520  else
7521  {
7522  ptr = or_unpack_int (reply, &status);
7523  ptr = or_unpack_oid (ptr, rep_dir_p);
7524  }
7525 
7526  return status;
7527 #else /* CS_MODE */
7528  int success = ER_FAILED;
7529 
7530  THREAD_ENTRY *thread_p = enter_server ();
7531 
7532  success = xcatalog_check_rep_dir (thread_p, class_id, rep_dir_p);
7533 
7534  exit_server (*thread_p);
7535 
7536  return success;
7537 #endif /* !CS_MODE */
7538 }
7539 
7540 /*
7541  * thread_kill_tran_index -
7542  *
7543  * return:
7544  *
7545  * kill_tran_index(in):
7546  * kill_user(in):
7547  * kill_host(in):
7548  * kill_pid(in):
7549  *
7550  * NOTE:
7551  */
7552 int
7553 thread_kill_tran_index (int kill_tran_index, char *kill_user, char *kill_host, int kill_pid)
7554 {
7555 #if defined(CS_MODE)
7556  int success = ER_FAILED;
7557  int request_size, strlen1, strlen2;
7558  char *request;
7559  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7560  char *reply, *ptr;
7561  int req_error;
7562 
7563  reply = OR_ALIGNED_BUF_START (a_reply);
7564 
7565  request_size = (OR_INT_SIZE + OR_INT_SIZE + length_const_string (kill_user, &strlen1)
7566  + length_const_string (kill_host, &strlen2));
7567 
7568  request = (char *) malloc (request_size);
7569  if (request == NULL)
7570  {
7571  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
7572  return ER_FAILED;
7573  }
7574 
7575  ptr = or_pack_int (request, kill_tran_index);
7576  ptr = pack_const_string_with_length (ptr, kill_user, strlen1);
7577  ptr = pack_const_string_with_length (ptr, kill_host, strlen2);
7578  ptr = or_pack_int (ptr, kill_pid);
7579 
7580  req_error = net_client_request (NET_SERVER_CSS_KILL_TRANSACTION, request, request_size, reply,
7581  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
7582  if (!req_error)
7583  {
7584  or_unpack_int (reply, &success);
7585  }
7586 
7587  free_and_init (request);
7588 
7589  return success;
7590 #else /* CS_MODE */
7591  er_log_debug (ARG_FILE_LINE, "css_kill_client: THIS IS ONLY a C/S function");
7592  return ER_FAILED;
7593 #endif /* !CS_MODE */
7594 }
7595 
7596 /*
7597  * thread_kill_or_interrupt_tran -
7598  *
7599  * return:
7600  *
7601  * tran_index_list(in):
7602  * num_tran_index(in):
7603  * is_dba_group_member(in):
7604  * interrupt_only(in):
7605  * num_killed(out):
7606  *
7607  * NOTE:
7608  */
7609 int
7610 thread_kill_or_interrupt_tran (int *tran_index_list, int num_tran_index, bool is_dba_group_member, bool interrupt_only,
7611  int *num_killed)
7612 {
7613 #if defined(CS_MODE)
7614  int success = ER_FAILED;
7615  int request_size;
7616  char *request;
7618  char *reply, *ptr;
7619  int req_error;
7620  int i;
7621 
7622  reply = OR_ALIGNED_BUF_START (a_reply);
7623 
7624  request_size = OR_INT_SIZE * (2 + num_tran_index); /* num_tran_index + tran_index_list + interrupt_only */
7625  request_size += OR_INT_SIZE; /* is_dba_group_member */
7626 
7627  request = (char *) malloc (request_size);
7628  if (request == NULL)
7629  {
7630  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
7631  return ER_FAILED;
7632  }
7633 
7634  ptr = or_pack_int (request, (int) is_dba_group_member);
7635  ptr = or_pack_int (ptr, num_tran_index);
7636 
7637  for (i = 0; i < num_tran_index; i++)
7638  {
7639  ptr = or_pack_int (ptr, tran_index_list[i]);
7640  }
7641 
7642  ptr = or_pack_int (ptr, (interrupt_only) ? 1 : 0);
7643 
7644  req_error =
7646  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
7647 
7648  if (!req_error)
7649  {
7650  ptr = or_unpack_int (reply, &success);
7651  ptr = or_unpack_int (ptr, num_killed);
7652  }
7653 
7654  free_and_init (request);
7655 
7656  return success;
7657 #else /* CS_MODE */
7658  er_log_debug (ARG_FILE_LINE, "thread_kill_or_interrupt_tran: THIS IS ONLY a C/S function");
7659  return ER_FAILED;
7660 #endif /* !CS_MODE */
7661 }
7662 
7663 /*
7664  * thread_dump_cs_stat -
7665  *
7666  * return:
7667  *
7668  * outfp(in):
7669  */
7670 void
7671 thread_dump_cs_stat (FILE * outfp)
7672 {
7673 #if defined(CS_MODE)
7674  int req_error;
7675 
7676  if (outfp == NULL)
7677  {
7678  outfp = stdout;
7679  }
7680 
7681  req_error = net_client_request_recv_stream (NET_SERVER_CSS_DUMP_CS_STAT, NULL, 0, NULL, 0, NULL, 0, outfp);
7682 #else /* CS_MODE */
7683  er_log_debug (ARG_FILE_LINE, "thread_dump_cs_stat: THIS IS ONLY a C/S function");
7684  return;
7685 #endif /* !CS_MODE */
7686 }
7687 
7688 /*
7689  * logtb_get_pack_tran_table -
7690  *
7691  * return:
7692  *
7693  * buffer_p(in):
7694  * size_p(in):
7695  * include_query_exec_info(in):
7696  *
7697  * NOTE:
7698  */
7699 int
7700 logtb_get_pack_tran_table (char **buffer_p, int *size_p, bool include_query_exec_info)
7701 {
7702 #if defined(CS_MODE)
7703  int error = NO_ERROR;
7704  int req_error;
7705  int ival;
7706  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
7707  char *request = OR_ALIGNED_BUF_START (a_request);
7709  char *reply = OR_ALIGNED_BUF_START (a_reply);
7710  char *ptr;
7711 
7712  /* --query-exec-info */
7713  or_pack_int (request, ((include_query_exec_info) ? 1 : 0));
7714 
7715  req_error =
7717  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, buffer_p, size_p);
7718  if (req_error)
7719  {
7720  assert (er_errid () != NO_ERROR);
7721  error = er_errid ();
7722  }
7723  else
7724  {
7725  /* first word is buffer size, second is error code */
7726  ptr = reply;
7727  ptr = or_unpack_int (ptr, &ival);
7728  ptr = or_unpack_int (ptr, &ival);
7729  error = (int) ival;
7730  }
7731 
7732  return error;
7733 #else /* CS_MODE */
7734  int error;
7735 
7736  THREAD_ENTRY *thread_p = enter_server ();
7737 
7738  error = xlogtb_get_pack_tran_table (thread_p, buffer_p, size_p, 0);
7739 
7740  exit_server (*thread_p);
7741 
7742  return error;
7743 #endif /* !CS_MODE */
7744 }
7745 
7746 /*
7747  * logtb_free_trans_info - Free transaction table information
7748  * return: none
7749  * info(in): TRANS_INFO to be freed
7750  */
7751 void
7753 {
7754  int i;
7755 
7756  if (info == NULL)
7757  {
7758  return;
7759  }
7760 
7761  for (i = 0; i < info->num_trans; i++)
7762  {
7763  if (info->tran[i].db_user != NULL)
7764  {
7766  }
7767  if (info->tran[i].program_name != NULL)
7768  {
7770  }
7771  if (info->tran[i].login_name != NULL)
7772  {
7774  }
7775  if (info->tran[i].host_name != NULL)
7776  {
7778  }
7779 
7780  if (info->include_query_exec_info)
7781  {
7782  if (info->tran[i].query_exec_info.query_stmt)
7783  {
7785  }
7787  {
7789  }
7790  if (info->tran[i].query_exec_info.sql_id)
7791  {
7793  }
7794  }
7795  else
7796  {
7799  }
7800  }
7801  free_and_init (info);
7802 }
7803 
7804 /*
7805  * logtb_get_trans_info - Get transaction table information which identifies
7806  * active transactions
7807  * include_query_exec_info(in) :
7808  * return: TRANS_INFO array or NULL
7809  */
7810 TRANS_INFO *
7811 logtb_get_trans_info (bool include_query_exec_info)
7812 {
7813  TRANS_INFO *info = NULL;
7814  char *buffer, *ptr;
7815  int num_trans, bufsize, i;
7816  int error;
7817 
7818  error = logtb_get_pack_tran_table (&buffer, &bufsize, include_query_exec_info);
7819  if (error != NO_ERROR || buffer == NULL)
7820  {
7821  return NULL;
7822  }
7823 
7824  ptr = buffer;
7825  ptr = or_unpack_int (ptr, &num_trans);
7826 
7827  if (num_trans == 0)
7828  {
7829  /* can't happen, there must be at least one transaction */
7831  goto error;
7832  }
7833 
7834  i = sizeof (TRANS_INFO) + ((num_trans - 1) * sizeof (ONE_TRAN_INFO));
7835  info = (TRANS_INFO *) malloc (i);
7836  if (info == NULL)
7837  {
7839  goto error;
7840  }
7841  memset (info, '\0', i);
7842 
7843  info->num_trans = num_trans;
7844  info->include_query_exec_info = include_query_exec_info;
7845  for (i = 0; i < num_trans; i++)
7846  {
7847  int unpack_int_value;
7848  ptr = or_unpack_int (ptr, &info->tran[i].tran_index);
7849  ptr = or_unpack_int (ptr, &unpack_int_value);
7850  info->tran[i].state = (TRAN_STATE) unpack_int_value;
7851  ptr = or_unpack_int (ptr, &info->tran[i].process_id);
7852  ptr = or_unpack_string (ptr, &info->tran[i].db_user);
7853  ptr = or_unpack_string (ptr, &info->tran[i].program_name);
7854  ptr = or_unpack_string (ptr, &info->tran[i].login_name);
7855  ptr = or_unpack_string (ptr, &info->tran[i].host_name);
7856  if (ptr == NULL)
7857  {
7858  assert (false);
7859  goto error;
7860  }
7861 
7862  if (include_query_exec_info)
7863  {
7864  ptr = or_unpack_float (ptr, &info->tran[i].query_exec_info.query_time);
7865  ptr = or_unpack_float (ptr, &info->tran[i].query_exec_info.tran_time);
7867  ptr = or_unpack_string (ptr, &info->tran[i].query_exec_info.query_stmt);
7868  ptr = or_unpack_string (ptr, &info->tran[i].query_exec_info.sql_id);
7869  if (ptr == NULL)
7870  {
7871  assert (false);
7872  goto error;
7873  }
7874  OR_UNPACK_XASL_ID (ptr, &info->tran[i].query_exec_info.xasl_id);
7875  }
7876  }
7877 
7878  if (((int) (ptr - buffer)) != bufsize)
7879  {
7880  /* unpacking didn't match size, garbage */
7882  goto error;
7883  }
7884 
7885  free_and_init (buffer);
7886 
7887  return info;
7888 
7889 error:
7890  if (buffer != NULL)
7891  {
7892  free_and_init (buffer);
7893  }
7894 
7895  if (info != NULL)
7896  {
7897  logtb_free_trans_info (info);
7898  }
7899 
7900  return NULL;
7901 }
7902 
7903 /*
7904  * logtb_dump_trantable -
7905  *
7906  * return:
7907  *
7908  * outfp(in):
7909  */
7910 void
7911 logtb_dump_trantable (FILE * outfp)
7912 {
7913 #if defined(CS_MODE)
7914  int req_error;
7915 
7916  if (outfp == NULL)
7917  {
7918  outfp = stdout;
7919  }
7920 
7921  req_error = net_client_request_recv_stream (NET_SERVER_LOG_DUMP_TRANTB, NULL, 0, NULL, 0, NULL, 0, outfp);
7922 #else /* CS_MODE */
7923 
7924  THREAD_ENTRY *thread_p = enter_server ();
7925 
7926  xlogtb_dump_trantable (thread_p, outfp);
7927 
7928  exit_server (*thread_p);
7929 #endif /* !CS_MODE */
7930 }
7931 
7932 /*
7933  * heap_get_class_num_objects_pages -
7934  *
7935  * return:
7936  *
7937  * hfid(in):
7938  * approximation(in):
7939  * nobjs(in):
7940  * npages(in):
7941  *
7942  * NOTE:
7943  */
7944 int
7945 heap_get_class_num_objects_pages (HFID * hfid, int approximation, int *nobjs, int *npages)
7946 {
7947 #if defined(CS_MODE)
7948  int req_error, status = ER_FAILED, num_objs, num_pages;
7949  OR_ALIGNED_BUF (OR_HFID_SIZE + OR_INT_SIZE) a_request;
7950  char *request;
7951  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
7952  char *reply;
7953  char *ptr;
7954 
7955  request = OR_ALIGNED_BUF_START (a_request);
7956  reply = OR_ALIGNED_BUF_START (a_reply);
7957 
7958  ptr = or_pack_hfid (request, hfid);
7959  ptr = or_pack_int (ptr, approximation);
7960 
7961  req_error =
7963  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
7964  if (!req_error)
7965  {
7966  ptr = or_unpack_int (reply, &status);
7967  ptr = or_unpack_int (ptr, &num_objs);
7968  ptr = or_unpack_int (ptr, &num_pages);
7969  *nobjs = (int) num_objs;
7970  *npages = (int) num_pages;
7971  }
7972 
7973  return status;
7974 #else /* CS_MODE */
7975  int success = ER_FAILED;
7976 
7977  THREAD_ENTRY *thread_p = enter_server ();
7978 
7979  success = xheap_get_class_num_objects_pages (thread_p, hfid, approximation, nobjs, npages);
7980 
7981  exit_server (*thread_p);
7982 
7983  return success;
7984 #endif /* !CS_MODE */
7985 }
7986 
7987 /*
7988  * btree_get_statistics -
7989  *
7990  * return:
7991  *
7992  * btid(in):
7993  * stat_info(in):
7994  *
7995  * NOTE:
7996  */
7997 int
7999 {
8000 #if defined(CS_MODE)
8001  int req_error, status = ER_FAILED;
8003  char *request;
8004  OR_ALIGNED_BUF (OR_INT_SIZE * 5) a_reply;
8005  char *reply;
8006  char *ptr;
8007 
8008  request = OR_ALIGNED_BUF_START (a_request);
8009  reply = OR_ALIGNED_BUF_START (a_reply);
8010 
8011  ptr = or_pack_btid (request, btid);
8012 
8013  req_error =
8015  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
8016  if (!req_error)
8017  {
8018  ptr = or_unpack_int (reply, &status);
8019  ptr = or_unpack_int (ptr, &stat_info->leafs);
8020  ptr = or_unpack_int (ptr, &stat_info->pages);
8021  ptr = or_unpack_int (ptr, &stat_info->height);
8022  ptr = or_unpack_int (ptr, &stat_info->keys);
8023 
8024  assert_release (stat_info->leafs > 0);
8025  assert_release (stat_info->pages > 0);
8026  assert_release (stat_info->height > 0);
8027  assert_release (stat_info->keys >= 0);
8028  }
8029 
8030  return status;
8031 #else /* CS_MODE */
8032  int success = ER_FAILED;
8033 
8034  THREAD_ENTRY *thread_p = enter_server ();
8035 
8036  assert_release (!BTID_IS_NULL (btid));
8037  assert_release (stat_info->keys == 0);
8038  assert_release (stat_info->pkeys_size == 0);
8039  assert_release (stat_info->pkeys == NULL);
8040 
8041  BTID_COPY (&stat_info->btid, btid);
8042  if (stat_info->pkeys_size != 0)
8043  {
8044  stat_info->pkeys_size = 0; /* do not request pkeys info */
8045  }
8046 
8047  success = btree_get_stats (thread_p, stat_info, STATS_WITH_SAMPLING);
8048 
8049  assert_release (stat_info->leafs > 0);
8050  assert_release (stat_info->pages > 0);
8051  assert_release (stat_info->height > 0);
8052  assert_release (stat_info->keys >= 0);
8053 
8054  exit_server (*thread_p);
8055 
8056  return success;
8057 #endif /* !CS_MODE */
8058 }
8059 
8060 /*
8061  * btree_get_index_key_type () - Get index key type.
8062  *
8063  * return : Error code.
8064  * btid (in) : Index b-tree identifier.
8065  * key_type_p (out) : Index key type.
8066  */
8067 int
8069 {
8070 #if defined(CS_MODE)
8071  int error;
8073  char *request;
8074  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
8075  char *reply = NULL;
8076  char *ptr = NULL;
8077  char *reply_data = NULL;
8078  int reply_data_size = 0;
8079  int dummy;
8080 
8081  request = OR_ALIGNED_BUF_START (a_request);
8082  reply = OR_ALIGNED_BUF_START (a_reply);
8083 
8084  /* Send BTID to server */
8085  ptr = or_pack_btid (request, &btid);
8086 
8087  error =
8089  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &reply_data, &reply_data_size);
8090  if (error != NO_ERROR)
8091  {
8092  return error;
8093  }
8094  ptr = or_unpack_int (reply, &reply_data_size);
8095  ptr = or_unpack_int (ptr, &error);
8096  if (error != NO_ERROR)
8097  {
8098  return error;
8099  }
8100  if (reply_data != NULL)
8101  {
8102  /* Obtain key type from server */
8103  (void) or_unpack_domain (reply_data, key_type_p, &dummy);
8104  }
8105  free_and_init (reply_data);
8106 
8107  return error;
8108 #else /* CS_MODE */
8109  int error = NO_ERROR;
8110 
8111  THREAD_ENTRY *thread_p = enter_server ();
8112 
8113  assert_release (!BTID_IS_NULL (&btid));
8114  assert_release (key_type_p != NULL);
8115 
8116  error = xbtree_get_key_type (thread_p, btid, key_type_p);
8117 
8118  exit_server (*thread_p);
8119 
8120  return error;
8121 #endif /* !CS_MODE */
8122 }
8123 
8124 /*
8125  * db_local_transaction_id -
8126  *
8127  * return:
8128  *
8129  * result_trid(in):
8130  *
8131  * NOTE:
8132  */
8133 int
8135 {
8136 #if defined(CS_MODE)
8137  int req_error, trid = 0;
8138  int success = ER_FAILED;
8140  char *reply, *ptr;
8141 
8142  reply = OR_ALIGNED_BUF_START (a_reply);
8143 
8144  req_error =
8146  NULL, 0);
8147  if (!req_error)
8148  {
8149  ptr = or_unpack_int (reply, &success);
8150  ptr = or_unpack_int (ptr, &trid);
8151  }
8152 
8153  db_make_int (result_trid, trid);
8154  return success;
8155 #else /* CS_MODE */
8156  int success;
8157 
8158  THREAD_ENTRY *thread_p = enter_server ();
8159 
8160  success = xtran_get_local_transaction_id (thread_p, result_trid);
8161 
8162  exit_server (*thread_p);
8163 
8164  return success;
8165 #endif /* !CS_MODE */
8166 }
8167 
8168 /*
8169  * qp_get_server_info -
8170  *
8171  * return:
8172  *
8173  * server_info(in):
8174  *
8175  * NOTE:
8176  */
8177 int
8178 qp_get_server_info (PARSER_CONTEXT * parser, int server_info_bits)
8179 {
8180 #if defined(CS_MODE)
8181  int status = ER_FAILED;
8182  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
8183  char *request;
8185  char *reply;
8186  char *ptr, *area = NULL;
8187  int val_size;
8188 
8189  request = OR_ALIGNED_BUF_START (a_request);
8190  reply = OR_ALIGNED_BUF_START (a_reply);
8191 
8192  ptr = or_pack_int (request, server_info_bits);
8193 
8194  status =
8196  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &val_size);
8197  if (status != NO_ERROR)
8198  {
8199  goto error_exit;
8200  }
8201 
8202  if (area != NULL)
8203  {
8204  ptr = or_unpack_int (reply, &val_size);
8205  ptr = or_unpack_int (ptr, &status);
8206 
8207  if (status != NO_ERROR)
8208  {
8209  goto error_exit;
8210  }
8211 
8212  ptr = area;
8213  if (server_info_bits & SI_SYS_DATETIME)
8214  {
8215  ptr = or_unpack_value (ptr, &(parser->sys_datetime));
8216  ptr = or_unpack_value (ptr, &(parser->sys_epochtime));
8217  }
8218  if (server_info_bits & SI_LOCAL_TRANSACTION_ID)
8219  {
8220  ptr = or_unpack_value (ptr, &parser->local_transaction_id);
8221  }
8222  }
8223 
8224 error_exit:
8225  if (area != NULL)
8226  {
8227  free_and_init (area);
8228  }
8229 
8230  return status;
8231 #else /* CS_MODE */
8232  int success = NO_ERROR;
8233 
8234  THREAD_ENTRY *thread_p = enter_server ();
8235 
8236  if (server_info_bits & SI_SYS_DATETIME)
8237  {
8238  success = db_sys_date_and_epoch_time (&(parser->sys_datetime), &(parser->sys_epochtime));
8239  if (success != NO_ERROR)
8240  {
8241  goto error_exit;
8242  }
8243  }
8244 
8245  if (server_info_bits & SI_LOCAL_TRANSACTION_ID)
8246  {
8247  success = db_local_transaction_id (&parser->local_transaction_id);
8248  }
8249 
8250 error_exit:
8251  exit_server (*thread_p);
8252  return success;
8253 #endif /* !CS_MODE */
8254 }
8255 
8256 /*
8257  * sysprm_change_server_parameters () - Sends a list of assignments to server in order to change system parameter
8258  * values.
8259  *
8260  * return : SYSPRM_ERR code.
8261  * assignments (in) : list of assignments.
8262  */
8263 SYSPRM_ERR
8265 {
8266 #if defined(CS_MODE)
8268  int request_size = 0, req_error = NO_ERROR;
8269  char *request = NULL, *reply = NULL;
8270  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8271 
8272  reply = OR_ALIGNED_BUF_START (a_reply);
8273 
8274  request_size = sysprm_packed_assign_values_length (assignments, 0);
8275  request = (char *) malloc (request_size);
8276  if (request == NULL)
8277  {
8278  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
8279  return PRM_ERR_NO_MEM_FOR_PRM;
8280  }
8281 
8282  (void) sysprm_pack_assign_values (request, assignments);
8283  req_error =
8284  net_client_request (NET_SERVER_PRM_SET_PARAMETERS, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
8285  NULL, 0, NULL, 0);
8286  if (req_error == NO_ERROR)
8287  {
8288  int unpack_value;
8289  or_unpack_int (reply, &unpack_value);
8290  rc = (SYSPRM_ERR) unpack_value;
8291  }
8292  else
8293  {
8294  rc = PRM_ERR_COMM_ERR;
8295  }
8296 
8297  free_and_init (request);
8298 
8299  return rc;
8300 #else /* CS_MODE */
8301  THREAD_ENTRY *thread_p = enter_server ();
8302  xsysprm_change_server_parameters (assignments);
8303  exit_server (*thread_p);
8304 
8305  return PRM_ERR_NO_ERROR;
8306 #endif /* !CS_MODE */
8307 }
8308 
8309 /*
8310  * sysprm_obtain_server_parameters () - Obtain values for system parameters from server.
8311  *
8312  * return : SYSPRM_ERR code.
8313  * prm_values_ptr (in/out) : list of parameter values.
8314  */
8315 SYSPRM_ERR
8317 {
8318 #if defined(CS_MODE)
8320  int req_error = NO_ERROR, request_size = 0, receive_size = 0;
8321  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
8322  char *reply = NULL, *request_data = NULL, *receive_data = NULL;
8323  char *ptr = NULL;
8324  SYSPRM_ASSIGN_VALUE *updated_prm_values = NULL;
8325 
8326  assert (prm_values_ptr != NULL && *prm_values_ptr != NULL);
8327 
8328  reply = OR_ALIGNED_BUF_START (a_reply);
8329 
8330  request_size = sysprm_packed_assign_values_length (*prm_values_ptr, 0);
8331  request_data = (char *) malloc (request_size);
8332  if (request_data == NULL)
8333  {
8334  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
8335  return PRM_ERR_NO_MEM_FOR_PRM;
8336  }
8337 
8338  (void) sysprm_pack_assign_values (request_data, *prm_values_ptr);
8339  req_error =
8340  net_client_request2 (NET_SERVER_PRM_GET_PARAMETERS, request_data, request_size, reply,
8341  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &receive_data, &receive_size);
8342  if (req_error != NO_ERROR)
8343  {
8344  rc = PRM_ERR_COMM_ERR;
8345  }
8346  else
8347  {
8348  int unpack_value;
8349  ptr = or_unpack_int (reply, &receive_size);
8350  ptr = or_unpack_int (ptr, &unpack_value);
8351  rc = (SYSPRM_ERR) unpack_value;
8352  if (rc != PRM_ERR_NO_ERROR || receive_data == NULL)
8353  {
8354  goto cleanup;
8355  }
8356 
8357  (void) sysprm_unpack_assign_values (receive_data, &updated_prm_values);
8358 
8359  /* free old values */
8360  sysprm_free_assign_values (prm_values_ptr);
8361  /* update values */
8362  *prm_values_ptr = updated_prm_values;
8363  }
8364 
8365 cleanup:
8366  if (request_data != NULL)
8367  {
8368  free_and_init (request_data);
8369  }
8370 
8371  if (receive_data != NULL)
8372  {
8373  free_and_init (receive_data);
8374  }
8375 
8376  return rc;
8377 #else /* CS_MODE */
8378  THREAD_ENTRY *thread_p = enter_server ();
8379  xsysprm_obtain_server_parameters (*prm_values_ptr);
8380  exit_server (*thread_p);
8381 
8382  return PRM_ERR_NO_ERROR;
8383 #endif /* !CS_MODE */
8384 }
8385 
8386 /*
8387  * sysprm_get_force_server_parameters () - Get from server values for system parameters marked with
8388  * PRM_FORCE_SERVER flag.
8389  *
8390  * return : error code
8391  * change_values (out) : list of parameter values.
8392  */
8393 int
8395 {
8396 #if defined (CS_MODE)
8397  int req_error;
8398  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
8399  int area_size, error;
8400  char *reply = NULL, *area = NULL, *ptr = NULL;
8401 
8402  assert (change_values != NULL);
8403  *change_values = NULL;
8404 
8405  reply = OR_ALIGNED_BUF_START (a_reply);
8406 
8407  req_error =
8409  &area, &area_size);
8410  if (req_error != NO_ERROR)
8411  {
8412  error = req_error;
8413  goto error;
8414  }
8415 
8416  ptr = or_unpack_int (reply, &area_size);
8417  ptr = or_unpack_int (ptr, &error);
8418  if (error != NO_ERROR)
8419  {
8420  goto error;
8421  }
8422 
8423  if (area != NULL)
8424  {
8425  (void) sysprm_unpack_assign_values (area, change_values);
8426  free_and_init (area);
8427  }
8428 
8429  return NO_ERROR;
8430 
8431 error:
8432  if (area != NULL)
8433  {
8434  free_and_init (area);
8435  }
8436 
8437  return error;
8438 #else /* CS_MODE */
8439  assert (change_values != NULL);
8440  *change_values = NULL;
8441  return NO_ERROR;
8442 #endif /* !CS_MODE */
8443 }
8444 
8445 /*
8446  * sysprm_dump_server_parameters -
8447  *
8448  * return:
8449  */
8450 void
8452 {
8453 #if defined(CS_MODE)
8454  int req_error;
8455 
8456  if (outfp == NULL)
8457  {
8458  outfp = stdout;
8459  }
8460 
8462 #else /* CS_MODE */
8463  THREAD_ENTRY *thread_p = enter_server ();
8464 
8466 
8467  exit_server (*thread_p);
8468 #endif /* !CS_MODE */
8469 }
8470 
8471 /*
8472  * heap_has_instance -
8473  *
8474  * return:
8475  *
8476  * hfid(in):
8477  * class_oid(in):
8478  * has_visible_instance(in): true if we need to check for a visible record
8479  *
8480  * NOTE:
8481  */
8482 int
8483 heap_has_instance (HFID * hfid, OID * class_oid, int has_visible_instance)
8484 {
8485 #if defined(CS_MODE)
8486  int req_error, status = ER_FAILED;
8488  char *request;
8489  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8490  char *reply;
8491  char *ptr;
8492 
8493  request = OR_ALIGNED_BUF_START (a_request);
8494  reply = OR_ALIGNED_BUF_START (a_reply);
8495 
8496  ptr = or_pack_hfid (request, hfid);
8497  ptr = or_pack_oid (ptr, class_oid);
8498  ptr = or_pack_int (ptr, has_visible_instance);
8499 
8500  req_error =
8502  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
8503  if (!req_error)
8504  {
8505  ptr = or_unpack_int (reply, &status);
8506  }
8507 
8508  return status;
8509 #else /* CS_MODE */
8510  int r = ER_FAILED;
8511 
8512  THREAD_ENTRY *thread_p = enter_server ();
8513  r = xheap_has_instance (thread_p, hfid, class_oid, has_visible_instance);
8514  exit_server (*thread_p);
8515 
8516  return r;
8517 #endif /* !CS_MODE */
8518 }
8519 
8520 /*
8521  * jsp_get_server_port -
8522  *
8523  * return:
8524  *
8525  * NOTE:
8526  */
8527 int
8529 {
8530 #if defined(CS_MODE)
8531  int req_error;
8532  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
8533  char *request;
8534  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8535  char *reply;
8536  int port = -1;
8537 
8538  request = OR_ALIGNED_BUF_START (a_request);
8539  reply = OR_ALIGNED_BUF_START (a_reply);
8540 
8541  req_error =
8543  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
8544  if (!req_error)
8545  {
8546  or_unpack_int (reply, &port);
8547  }
8548 
8549  return port;
8550 #else /* CS_MODE */
8551  int port;
8552  THREAD_ENTRY *thread_p = enter_server ();
8553  port = jsp_server_port ();
8554  exit_server (*thread_p);
8555  return port;
8556 #endif /* !CS_MODE */
8557 }
8558 
8559 /*
8560  * repl_log_get_append_lsa -
8561  *
8562  * return:
8563  *
8564  * lsa(in):
8565  *
8566  * NOTE:
8567  */
8568 int
8570 {
8571 #if defined(CS_MODE)
8572  int req_error, success = ER_FAILED;
8573  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
8574  char *request;
8576  char *reply;
8577 
8578  request = OR_ALIGNED_BUF_START (a_request);
8579  reply = OR_ALIGNED_BUF_START (a_reply);
8580  req_error =
8582  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
8583  if (!req_error)
8584  {
8585  or_unpack_log_lsa (reply, lsa);
8586  success = NO_ERROR;
8587  }
8588 
8589  return success;
8590 #else /* CS_MODE */
8591  LOG_LSA *tmp_lsa = NULL;
8592  int r = ER_FAILED;
8593 
8594  THREAD_ENTRY *thread_p = enter_server ();
8595  tmp_lsa = xrepl_log_get_append_lsa ();
8596  if (lsa && tmp_lsa)
8597  {
8598  LSA_COPY (lsa, tmp_lsa);
8599  r = NO_ERROR;
8600  }
8601  else
8602  {
8603  r = ER_FAILED;
8604  }
8605  exit_server (*thread_p);
8606 
8607  return r;
8608 #endif /* !CS_MODE */
8609 }
8610 
8611 /*
8612  * repl_set_info -
8613  *
8614  * return:
8615  *
8616  * repl_info(in):
8617  *
8618  * NOTE:
8619  */
8620 int
8622 {
8623 #if defined(CS_MODE)
8624  int req_error, success = ER_FAILED;
8625  int request_size = 0, strlen1, strlen2, strlen3, strlen4;
8626  char *request = NULL, *ptr;
8627  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8628  char *reply;
8629  REPL_INFO_SBR *repl_schema;
8630 
8631  reply = OR_ALIGNED_BUF_START (a_reply);
8632 
8633  switch (repl_info->repl_info_type)
8634  {
8635  case REPL_INFO_TYPE_SBR:
8636  repl_schema = (REPL_INFO_SBR *) repl_info->info;
8637  request_size = (OR_INT_SIZE /* REPL_INFO.REPL_INFO_TYPE */
8638  + OR_INT_SIZE /* REPL_INFO_SCHEMA.statement_type */
8639  + length_const_string (repl_schema->name, &strlen1)
8640  + length_const_string (repl_schema->stmt_text, &strlen2)
8641  + length_const_string (repl_schema->db_user, &strlen3)
8642  + length_const_string (repl_schema->sys_prm_context, &strlen4));
8643 
8644  request = (char *) malloc (request_size);
8645  if (request == NULL)
8646  {
8647  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
8648  return ER_FAILED;
8649  }
8650 
8651  ptr = or_pack_int (request, REPL_INFO_TYPE_SBR);
8652  ptr = or_pack_int (ptr, repl_schema->statement_type);
8653  ptr = pack_const_string_with_length (ptr, repl_schema->name, strlen1);
8654  ptr = pack_const_string_with_length (ptr, repl_schema->stmt_text, strlen2);
8655  ptr = pack_const_string_with_length (ptr, repl_schema->db_user, strlen3);
8656  ptr = pack_const_string_with_length (ptr, repl_schema->sys_prm_context, strlen4);
8657  req_error =
8658  net_client_request (NET_SERVER_REPL_INFO, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL,
8659  0, NULL, 0);
8660  if (!req_error)
8661  {
8662  or_unpack_int (reply, &success);
8663  }
8664 
8665  free_and_init (request);
8666  break;
8667 
8668  default:
8669  break;
8670  }
8671 
8672  return success;
8673 #else /* CS_MODE */
8674  int r = ER_FAILED;
8675 
8676  THREAD_ENTRY *thread_p = enter_server ();
8677  r = xrepl_set_info (thread_p, repl_info);
8678  exit_server (*thread_p);
8679  return r;
8680 #endif /* !CS_MODE */
8681 }
8682 
8683 /*
8684  * locator_check_fk_validity -
8685  *
8686  * return:
8687  *
8688  * cls_oid(in):
8689  * hfid(in):
8690  * key_type(in):
8691  * n_attrs(in):
8692  * attr_ids(in):
8693  * pk_cls_oid(in):
8694  * pk_btid(in):
8695  * fk_name(in):
8696  *
8697  * NOTE:
8698  */
8699 int
8700 locator_check_fk_validity (OID * cls_oid, HFID * hfid, TP_DOMAIN * key_type, int n_attrs, int *attr_ids,
8701  OID * pk_cls_oid, BTID * pk_btid, char *fk_name)
8702 {
8703 #if defined(CS_MODE)
8704  int error, req_error, request_size, domain_size;
8705  char *ptr;
8706  char *request;
8707  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8708  char *reply;
8709  int i, strlen;
8710 
8711  error = NO_ERROR;
8712  reply = OR_ALIGNED_BUF_START (a_reply);
8713 
8714  domain_size = or_packed_domain_size (key_type, 0);
8715  request_size = (OR_OID_SIZE + OR_HFID_SIZE + domain_size + OR_INT_SIZE + (n_attrs * OR_INT_SIZE)
8716  + OR_OID_SIZE + OR_BTID_ALIGNED_SIZE + or_packed_string_length (fk_name, &strlen));
8717 
8718  request = (char *) malloc (request_size);
8719  if (request == NULL)
8720  {
8721  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
8722  return ER_OUT_OF_VIRTUAL_MEMORY;
8723  }
8724 
8725  ptr = or_pack_oid (request, cls_oid);
8726  ptr = or_pack_hfid (ptr, hfid);
8727  ptr = or_pack_domain (ptr, key_type, 0, 0);
8728  ptr = or_pack_int (ptr, n_attrs);
8729  for (i = 0; i < n_attrs; i++)
8730  {
8731  ptr = or_pack_int (ptr, attr_ids[i]);
8732  }
8733  ptr = or_pack_oid (ptr, pk_cls_oid);
8734  ptr = or_pack_btid (ptr, pk_btid);
8735  ptr = or_pack_string_with_length (ptr, fk_name, strlen);
8736 
8737  req_error = net_client_request (NET_SERVER_LC_CHECK_FK_VALIDITY, request, request_size, reply,
8738  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
8739  if (!req_error)
8740  {
8741  ptr = or_unpack_int (reply, &error);
8742  }
8743  else
8744  {
8745  error = req_error;
8746  }
8747 
8748  free_and_init (request);
8749 
8750  return error;
8751 #else /* CS_MODE */
8752  int error = NO_ERROR;
8753 
8754  THREAD_ENTRY *thread_p = enter_server ();
8755 
8756  error =
8757  xlocator_check_fk_validity (thread_p, cls_oid, hfid, key_type, n_attrs, attr_ids, pk_cls_oid, pk_btid, fk_name);
8758 
8759  exit_server (*thread_p);
8760  return error;
8761 #endif /* !CS_MODE */
8762 }
8763 
8764 /*
8765  * logwr_get_log_pages -
8766  *
8767  * return:
8768  *
8769  * rc_ptr(in/out): request context
8770  *
8771  * NOTE:
8772  */
8773 int
8775 {
8776 #if defined(CS_MODE)
8777  OR_ALIGNED_BUF (OR_INT64_SIZE + OR_INT_SIZE * 2) a_request;
8778  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
8779  char *request, *reply;
8780  char *replydata1, *replydata2;
8781  int replydata_size1, replydata_size2;
8782  char *ptr;
8783  LOG_PAGEID first_pageid_torecv;
8784  LOGWR_MODE mode, save_mode;
8785  int req_error, error = NO_ERROR;
8786 
8787  /* Do it as async mode at the first request to the server. And, if several pages are left to get, keep it as async
8788  * mode */
8789 
8790  assert (logwr_Gl.last_recv_pageid <= logwr_Gl.hdr.eof_lsa.pageid);
8791  if (logwr_Gl.last_recv_pageid == logwr_Gl.hdr.eof_lsa.pageid)
8792  {
8793  /* In case of synchronous request */
8794  first_pageid_torecv = logwr_Gl.last_recv_pageid;
8795 
8796  mode = (logwr_Gl.last_recv_pageid == NULL_PAGEID) ? LOGWR_MODE_ASYNC : logwr_Gl.mode;
8797  }
8798  else
8799  {
8800  /* In the middle of sending the pages which are already flushed */
8801  if (logwr_Gl.last_recv_pageid == NULL_PAGEID)
8802  {
8803  /* To check database equality at first, get the header page */
8804  first_pageid_torecv = LOGPB_HEADER_PAGE_ID;
8805  }
8806  else
8807  {
8808  /* When it overtakes the state of the server, it set ha_file_state is sync'ed. And, the flush action is not
8809  * sync'ed with the server. So, it requests the last page again to get the missing log records. */
8810  if (logwr_Gl.hdr.ha_file_status == LOG_HA_FILESTAT_SYNCHRONIZED)
8811  {
8812  first_pageid_torecv = logwr_Gl.last_recv_pageid;
8813  }
8814  else
8815  {
8816  first_pageid_torecv = logwr_Gl.last_recv_pageid + 1;
8817  }
8818  }
8819  /* In case of archiving, not replication delay */
8820  if (first_pageid_torecv == logwr_Gl.ori_nxarv_pageid)
8821  {
8822  mode = logwr_Gl.mode;
8823  }
8824  else
8825  {
8826  mode = LOGWR_MODE_ASYNC;
8827  }
8828  }
8829 
8830  er_log_debug (ARG_FILE_LINE, "logwr_get_log_pages, fpageid(%lld), mode(%s)", first_pageid_torecv,
8831  mode == LOGWR_MODE_SYNC ? "sync" : (mode == LOGWR_MODE_ASYNC ? "async" : "semisync"));
8832 
8833  save_mode = logwr_Gl.mode;
8834  logwr_Gl.mode = mode;
8835 
8836  request = OR_ALIGNED_BUF_START (a_request);
8837  reply = OR_ALIGNED_BUF_START (a_reply);
8838 
8839  if (first_pageid_torecv == NULL_PAGEID && logwr_Gl.start_pageid >= NULL_PAGEID)
8840  {
8841  ptr = or_pack_int64 (request, logwr_Gl.start_pageid);
8843  }
8844  else
8845  {
8846  ptr = or_pack_int64 (request, first_pageid_torecv);
8847  }
8848 
8849  ptr = or_pack_int (ptr, mode);
8850  ptr = or_pack_int (ptr, ctx_ptr->last_error);
8851 
8852  req_error =
8854  OR_ALIGNED_BUF_SIZE (a_request), reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL,
8855  0, NULL, 0, &replydata1, &replydata_size1, &replydata2, &replydata_size2);
8856 
8857  logwr_Gl.mode = save_mode;
8858 
8859  if (req_error != NO_ERROR)
8860  {
8861  error = req_error;
8862  if (error == ER_NET_SERVER_CRASHED)
8863  {
8864  if (logwr_Gl.mode == LOGWR_MODE_SEMISYNC)
8865  {
8866  logwr_Gl.force_flush = true;
8867  logwr_write_log_pages ();
8868  }
8869  /* Write the server is dead at the log header */
8870  logwr_Gl.hdr.ha_server_state = HA_SERVER_STATE_DEAD;
8871  logwr_flush_header_page ();
8872  ctx_ptr->shutdown = true;
8873  }
8874  else if (error == ER_HA_LW_FAILED_GET_LOG_PAGE)
8875  {
8876  if (logwr_Gl.mode == LOGWR_MODE_SEMISYNC)
8877  {
8878  logwr_Gl.force_flush = true;
8879  logwr_write_log_pages ();
8880  }
8881 
8882  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error, 1, first_pageid_torecv);
8883 
8884  ctx_ptr->shutdown = true;
8885  }
8886  }
8887 
8888  if (logwr_Gl.start_pageid >= NULL_PAGEID && logwr_Gl.hdr.eof_lsa.pageid == logwr_Gl.hdr.append_lsa.pageid
8889  && logwr_Gl.hdr.ha_file_status == LOG_HA_FILESTAT_SYNCHRONIZED)
8890  {
8891  ctx_ptr->shutdown = true;
8892  error = NO_ERROR;
8893  }
8894 
8895  return error;
8896 
8897 #else /* CS_MODE */
8898  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_NOT_IN_STANDALONE, 1, "copylog database");
8899  return ER_NOT_IN_STANDALONE;
8900 #endif /* !CS_MODE */
8901 }
8902 
8903 bool
8905 {
8907 }
8908 
8909 int
8910 histo_start (bool for_all_trans)
8911 {
8912 #if defined (CS_MODE)
8913  return net_histo_start (for_all_trans);
8914 #else /* CS_MODE */
8915  return perfmon_start_stats (for_all_trans);
8916 #endif /* !CS_MODE */
8917 }
8918 
8919 int
8921 {
8922 #if defined (CS_MODE)
8923  return net_histo_stop ();
8924 #else /* CS_MODE */
8925  return perfmon_stop_stats ();
8926 #endif /* !CS_MODE */
8927 }
8928 
8929 int
8930 histo_print (FILE * stream)
8931 {
8932  int err = NO_ERROR;
8933 
8934 #if defined (CS_MODE)
8935  err = net_histo_print (stream);
8936 #else /* CS_MODE */
8937  err = perfmon_print_stats (stream);
8938 #endif /* !CS_MODE */
8939 
8940  return err;
8941 }
8942 
8943 int
8944 histo_print_global_stats (FILE * stream, bool cumulative, const char *substr)
8945 {
8946  int err = NO_ERROR;
8947 
8948 #if defined (CS_MODE)
8949  err = net_histo_print_global_stats (stream, cumulative, substr);
8950 #else /* CS_MODE */
8951  err = perfmon_print_global_stats (stream, cumulative, substr);
8952 #endif /* !CS_MODE */
8953 
8954  return err;
8955 }
8956 
8957 void
8959 {
8960 #if defined (CS_MODE)
8961  net_histo_clear ();
8962 #else /* CS_MODE */
8963  perfmon_reset_stats ();
8964 #endif /* !CS_MODE */
8965 }
8966 
8967 /*
8968  * boot_compact_classes () - compact specified classes
8969  *
8970  * return : NO_ERROR if all OK, ER_ status otherwise
8971  *
8972  * class_oids(in): the class oids list to process
8973  * n_classes(in): the length of class_oids
8974  * space_to_process(in): the maximum space to process
8975  * instance_lock_timeout(in): the lock timeout for instances
8976  * class_lock_timeout(in): the lock timeout for classes
8977  * delete_old_repr(in): true if old class representations must be deleted
8978  * last_processed_class_oid(in,out): last processed class oid
8979  * last_processed_oid(in,out): last processed oid
8980  * total_objects(in,out): count processed objects for each class
8981  * failed_objects(in,out): count failed objects for each class
8982  * modified_objects(in,out): count modified objects for each class
8983  * big_objects(in,out): count big objects for each class
8984  * initial_last_repr_id(in,out): the list of last class representation
8985  *
8986  * Note:
8987  */
8988 int
8989 boot_compact_classes (OID ** class_oids, int num_classes, int space_to_process, int instance_lock_timeout,
8990  int class_lock_timeout, bool delete_old_repr, OID * last_processed_class_oid,
8991  OID * last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects,
8992  int *big_objects, int *ids_repr)
8993 {
8994 #if defined(CS_MODE)
8995  int success = ER_FAILED, request_size, req_error, i, reply_size;
8996  char *reply = NULL, *request = NULL, *ptr = NULL;
8997 
8998  if (class_oids == NULL || num_classes < 0 || space_to_process < 0 || last_processed_class_oid == NULL
8999  || last_processed_oid == NULL || total_objects == NULL || failed_objects == NULL || modified_objects == NULL
9000  || big_objects == NULL || ids_repr == NULL)
9001  {
9003  }
9004 
9005  request_size = OR_OID_SIZE * (num_classes + 2) + OR_INT_SIZE * (5 * num_classes + 5);
9006 
9007  request = (char *) malloc (request_size);
9008  if (request == NULL)
9009  {
9010  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9011  return ER_OUT_OF_VIRTUAL_MEMORY;
9012  }
9013 
9014  reply_size = OR_OID_SIZE * 2 + OR_INT_SIZE * (5 * num_classes + 1);
9015  reply = (char *) malloc (reply_size);
9016  if (reply == NULL)
9017  {
9018  free_and_init (request);
9019  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) reply_size);
9020  return ER_OUT_OF_VIRTUAL_MEMORY;
9021  }
9022 
9023  ptr = or_pack_int (request, num_classes);
9024  for (i = 0; i < num_classes; i++)
9025  {
9026  ptr = or_pack_oid (ptr, class_oids[i]);
9027  }
9028 
9029  ptr = or_pack_int (ptr, space_to_process);
9030  ptr = or_pack_int (ptr, instance_lock_timeout);
9031  ptr = or_pack_int (ptr, class_lock_timeout);
9032  ptr = or_pack_int (ptr, (int) delete_old_repr);
9033  ptr = or_pack_oid (ptr, last_processed_class_oid);
9034  ptr = or_pack_oid (ptr, last_processed_oid);
9035 
9036  for (i = 0; i < num_classes; i++)
9037  {
9038  ptr = or_pack_int (ptr, total_objects[i]);
9039  }
9040 
9041  for (i = 0; i < num_classes; i++)
9042  {
9043  ptr = or_pack_int (ptr, failed_objects[i]);
9044  }
9045 
9046  for (i = 0; i < num_classes; i++)
9047  {
9048  ptr = or_pack_int (ptr, modified_objects[i]);
9049  }
9050 
9051  for (i = 0; i < num_classes; i++)
9052  {
9053  ptr = or_pack_int (ptr, big_objects[i]);
9054  }
9055 
9056  for (i = 0; i < num_classes; i++)
9057  {
9058  ptr = or_pack_int (ptr, ids_repr[i]);
9059  }
9060 
9061  req_error = net_client_request (NET_SERVER_BO_COMPACT_DB, request, request_size, reply, reply_size, NULL, 0, NULL, 0);
9062  if (!req_error)
9063  {
9064  ptr = or_unpack_int (reply, &success);
9065  ptr = or_unpack_oid (ptr, last_processed_class_oid);
9066  ptr = or_unpack_oid (ptr, last_processed_oid);
9067 
9068  for (i = 0; i < num_classes; i++)
9069  {
9070  ptr = or_unpack_int (ptr, total_objects + i);
9071  }
9072 
9073  for (i = 0; i < num_classes; i++)
9074  {
9075  ptr = or_unpack_int (ptr, failed_objects + i);
9076  }
9077 
9078  for (i = 0; i < num_classes; i++)
9079  {
9080  ptr = or_unpack_int (ptr, modified_objects + i);
9081  }
9082 
9083  for (i = 0; i < num_classes; i++)
9084  {
9085  ptr = or_unpack_int (ptr, big_objects + i);
9086  }
9087 
9088  for (i = 0; i < num_classes; i++)
9089  {
9090  ptr = or_unpack_int (ptr, ids_repr + i);
9091  }
9092  }
9093 
9094  free_and_init (request);
9095  free_and_init (reply);
9096 
9097  return success;
9098 #else /* CS_MODE */
9099  return ER_FAILED;
9100 #endif /* !CS_MODE */
9101 }
9102 
9103 /*
9104  * boot_heap_compact () - compact heap file of gived class
9105  *
9106  * return : NO_ERROR if all OK, ER_ status otherwise
9107  *
9108  * class_oid(in): the class oid of heap to compact
9109  *
9110  * Note:
9111  */
9112 int
9113 boot_heap_compact (OID * class_oid)
9114 {
9115 #if defined(CS_MODE)
9116  int success = ER_FAILED, request_size, req_error, reply_size;
9117 
9118  OR_ALIGNED_BUF (OR_OID_SIZE) a_request;
9119  char *request;
9120  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9121  char *reply;
9122 
9123  if (class_oid == NULL)
9124  {
9126  }
9127 
9128  request = OR_ALIGNED_BUF_START (a_request);
9129  reply = OR_ALIGNED_BUF_START (a_reply);
9130 
9131  request_size = OR_OID_SIZE;
9132  reply_size = OR_INT_SIZE;
9133 
9134  or_pack_oid (request, class_oid);
9135 
9136  req_error =
9137  net_client_request (NET_SERVER_BO_HEAP_COMPACT, request, request_size, reply, reply_size, NULL, 0, NULL, 0);
9138  if (!req_error)
9139  {
9140  (void) or_unpack_int (reply, &success);
9141  }
9142 
9143  return success;
9144 #else /* CS_MODE */
9145  return ER_FAILED;
9146 #endif /* !CS_MODE */
9147 }
9148 
9149 /*
9150  * compact_db_start () - start database compaction
9151  *
9152  * return : error code
9153  *
9154  */
9155 int
9157 {
9158 #if defined(CS_MODE)
9159  int success = ER_FAILED, req_error, reply_size;
9160  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9161  char *reply;
9162 
9163  reply_size = OR_INT_SIZE;
9164  reply = OR_ALIGNED_BUF_START (a_reply);
9165 
9166  req_error = net_client_request (NET_SERVER_BO_COMPACT_DB_START, NULL, 0, reply, reply_size, NULL, 0, NULL, 0);
9167  if (!req_error)
9168  {
9169  (void) or_unpack_int (reply, &success);
9170  }
9171 
9172  return success;
9173 #else /* CS_MODE */
9174  return ER_FAILED;
9175 #endif /* !CS_MODE */
9176 }
9177 
9178 /*
9179  * compact_db_stop () - stop database compaction
9180  *
9181  * return :error code
9182  *
9183  */
9184 int
9186 {
9187 #if defined(CS_MODE)
9188  int success = ER_FAILED, req_error, reply_size;
9189  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9190  char *reply;
9191 
9192  reply_size = OR_INT_SIZE;
9193  reply = OR_ALIGNED_BUF_START (a_reply);
9194 
9195  req_error = net_client_request (NET_SERVER_BO_COMPACT_DB_STOP, NULL, 0, reply, reply_size, NULL, 0, NULL, 0);
9196  if (!req_error)
9197  {
9198  (void) or_unpack_int (reply, &success);
9199  }
9200 
9201  return success;
9202 #else /* CS_MODE */
9203  return ER_FAILED;
9204 #endif /* !CS_MODE */
9205 }
9206 
9207 /*
9208  * es_posix_create_file () - create an external file in a posix storage
9209  *
9210  * return :error code
9211  *
9212  */
9213 int
9214 es_posix_create_file (char *new_path)
9215 {
9216 #if defined(CS_MODE)
9218  int req_error, path_size;
9219  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
9220  char *reply, *ptr;
9221 
9222  reply = OR_ALIGNED_BUF_START (a_reply);
9223 
9224  req_error =
9226  new_path, &path_size);
9227  if (!req_error)
9228  {
9229  ptr = or_unpack_int (reply, &path_size);
9230  ptr = or_unpack_int (ptr, &error);
9231  }
9232 
9233  return error;
9234 #else /* CS_MODE */
9235  return ER_FAILED;
9236 #endif /* !CS_MODE */
9237 }
9238 
9239 /*
9240  * es_posix_write_file () - write data in an esternal file
9241  *
9242  * return :error code
9243  * path(in):
9244  * buf(in):
9245  * count(in):
9246  * offset(in):
9247  */
9248 ssize_t
9249 es_posix_write_file (const char *path, const void *buf, size_t count, off_t offset)
9250 {
9251 #if defined(CS_MODE)
9252  INT64 ret = ER_NET_CLIENT_DATA_RECEIVE;
9253  int req_error, request_size, strlen;
9254  char *request, *reply;
9255  OR_ALIGNED_BUF (OR_INT64_SIZE) a_reply;
9256  char *ptr;
9257 
9258  reply = OR_ALIGNED_BUF_START (a_reply);
9259 
9260  request_size = DB_ALIGN (length_const_string (path, &strlen), MAX_ALIGNMENT) + OR_INT64_SIZE + OR_INT64_SIZE;
9261  request = (char *) malloc (request_size);
9262  if (request == NULL)
9263  {
9264  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9265  return ER_OUT_OF_VIRTUAL_MEMORY;
9266  }
9267 
9268  ptr = pack_const_string_with_length (request, path, strlen);
9269  ptr = or_pack_int64 (ptr, (INT64) offset);
9270  ptr = or_pack_int64 (ptr, (INT64) count);
9271 
9272  req_error = net_client_request (NET_SERVER_ES_WRITE_FILE, request, request_size, reply,
9273  OR_ALIGNED_BUF_SIZE (a_reply), (char *) buf, (int) count, NULL, 0);
9274  if (!req_error)
9275  {
9276  ptr = or_unpack_int64 (reply, &ret);
9277  }
9278  free_and_init (request);
9279 
9280  return ret;
9281 #else /* CS_MODE */
9282  return ER_FAILED;
9283 #endif /* !CS_MODE */
9284 }
9285 
9286 /*
9287  * es_posix_read_file () - read data from an esternal file
9288  *
9289  * return :error code
9290  * path(in):
9291  * buf(out):
9292  * count(in):
9293  * offset(in):
9294  */
9295 ssize_t
9296 es_posix_read_file (const char *path, void *buf, size_t count, off_t offset)
9297 {
9298 #if defined(CS_MODE)
9299  INT64 ret = ER_NET_CLIENT_DATA_RECEIVE;
9300  int req_error, request_size, strlen;
9301  char *request, *reply;
9302  OR_ALIGNED_BUF (OR_INT64_SIZE) a_reply;
9303  char *ptr;
9304 
9305  reply = OR_ALIGNED_BUF_START (a_reply);
9306 
9307  request_size = DB_ALIGN (length_const_string (path, &strlen), MAX_ALIGNMENT) + OR_INT64_SIZE + OR_INT64_SIZE;
9308  request = (char *) malloc (request_size);
9309  if (request == NULL)
9310  {
9311  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9312  return ER_OUT_OF_VIRTUAL_MEMORY;
9313  }
9314 
9315  ptr = pack_const_string_with_length (request, path, strlen);
9316  ptr = or_pack_int64 (ptr, (INT64) offset);
9317  ptr = or_pack_int64 (ptr, (INT64) count);
9318 
9319  req_error = net_client_request (NET_SERVER_ES_READ_FILE, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
9320  NULL, 0, (char *) buf, (int) count);
9321  if (!req_error)
9322  {
9323  ptr = or_unpack_int64 (reply, &ret);
9324  }
9325 
9326  free_and_init (request);
9327 
9328  return ret;
9329 #else /* CS_MODE */
9330  return ER_FAILED;
9331 #endif
9332 }
9333 
9334 /*
9335  * es_posix_delete_file () - delete an external file
9336  *
9337  * return :error code
9338  * path(in):
9339  */
9340 int
9341 es_posix_delete_file (const char *path)
9342 {
9343 #if defined(CS_MODE)
9345  int req_error, request_size, strlen;
9346  char *request, *reply;
9347  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9348  char *ptr;
9349 
9350  reply = OR_ALIGNED_BUF_START (a_reply);
9351 
9352  request_size = length_const_string (path, &strlen);
9353  request = (char *) malloc (request_size);
9354  if (request == NULL)
9355  {
9356  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9357  return ER_OUT_OF_VIRTUAL_MEMORY;
9358  }
9359 
9360  ptr = pack_const_string_with_length (request, path, strlen);
9361 
9362  req_error = net_client_request (NET_SERVER_ES_DELETE_FILE, request, request_size, reply,
9363  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
9364  if (!req_error)
9365  {
9366  ptr = or_unpack_int (reply, &error);
9367  }
9368 
9369  free_and_init (request);
9370 
9371  return error;
9372 #else /* CS_MODE */
9373  return ER_FAILED;
9374 #endif
9375 }
9376 
9377 /*
9378  * es_posix_copy_file () - copy an external file
9379  *
9380  * return :error code
9381  * src_path(in):
9382  * metaname(in):
9383  * new_path(out):
9384  */
9385 int
9386 es_posix_copy_file (const char *src_path, const char *metaname, char *new_path)
9387 {
9388 #if defined(CS_MODE)
9390  int req_error, request_size, path_size, srclen, metalen;
9391  char *request, *reply;
9392  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
9393  char *ptr;
9394 
9395  reply = OR_ALIGNED_BUF_START (a_reply);
9396 
9397  request_size = length_const_string (src_path, &srclen) + length_const_string (metaname, &metalen);
9398  request = (char *) malloc (request_size);
9399  if (request == NULL)
9400  {
9401  error = ER_OUT_OF_VIRTUAL_MEMORY;
9402  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error, 1, (size_t) request_size);
9403  return error;
9404  }
9405 
9406  ptr = pack_const_string_with_length (request, src_path, srclen);
9407  ptr = pack_const_string_with_length (ptr, metaname, metalen);
9408 
9409  req_error =
9410  net_client_request2_no_malloc (NET_SERVER_ES_COPY_FILE, request, request_size, reply,
9411  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, new_path, &path_size);
9412  if (!req_error)
9413  {
9414  ptr = or_unpack_int (reply, &path_size);
9415  ptr = or_unpack_int (ptr, &error);
9416  }
9417 
9418  free_and_init (request);
9419 
9420  return error;
9421 #else /* CS_MODE */
9422  return ER_FAILED;
9423 #endif
9424 }
9425 
9426 /*
9427  * es_posix_rename_file () - rename an external file
9428  *
9429  * return :error code
9430  * src_path(in):
9431  * metaname(in):
9432  * new_path(out):
9433  */
9434 int
9435 es_posix_rename_file (const char *src_path, const char *metaname, char *new_path)
9436 {
9437 #if defined(CS_MODE)
9439  int req_error, request_size, path_size, srclen, metalen;
9440  char *request, *reply;
9441  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
9442  char *ptr;
9443 
9444  reply = OR_ALIGNED_BUF_START (a_reply);
9445 
9446  request_size = length_const_string (src_path, &srclen) + length_const_string (metaname, &metalen);
9447  request = (char *) malloc (request_size);
9448  if (request == NULL)
9449  {
9450  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9451  return ER_OUT_OF_VIRTUAL_MEMORY;
9452  }
9453 
9454  ptr = pack_const_string_with_length (request, src_path, srclen);
9455  ptr = pack_const_string_with_length (ptr, metaname, metalen);
9456 
9457  req_error =
9458  net_client_request2_no_malloc (NET_SERVER_ES_RENAME_FILE, request, request_size, reply,
9459  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, new_path, &path_size);
9460  if (!req_error)
9461  {
9462  ptr = or_unpack_int (reply, &path_size);
9463  ptr = or_unpack_int (ptr, &error);
9464  }
9465 
9466  free_and_init (request);
9467 
9468  return error;
9469 #else /* CS_MODE */
9470  return ER_FAILED;
9471 #endif
9472 }
9473 
9474 /*
9475  * es_posix_get_file_size () - get the size of an esternal file
9476  *
9477  * return : file size or -1 on error
9478  * path(in):
9479  */
9480 off_t
9481 es_posix_get_file_size (const char *path)
9482 {
9483 #if defined(CS_MODE)
9484  INT64 tmp_int64;
9485  off_t file_size = -1;
9486  int req_error, request_size, strlen;
9487  char *request, *reply;
9488  OR_ALIGNED_BUF (OR_INT64_SIZE) a_reply;
9489  char *ptr;
9490 
9491  reply = OR_ALIGNED_BUF_START (a_reply);
9492 
9493  request_size = length_const_string (path, &strlen);
9494  request = (char *) malloc (request_size);
9495  if (request == NULL)
9496  {
9497  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9498  return ER_OUT_OF_VIRTUAL_MEMORY;
9499  }
9500 
9501  ptr = pack_const_string_with_length (request, path, strlen);
9502 
9503  req_error = net_client_request (NET_SERVER_ES_GET_FILE_SIZE, request, request_size, reply,
9504  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
9505  if (!req_error)
9506  {
9507  ptr = or_unpack_int64 (reply, &tmp_int64);
9508  file_size = (off_t) tmp_int64;
9509  }
9510 
9511  free_and_init (request);
9512 
9513  return file_size;
9514 #else /* CS_MODE */
9515  return -1;
9516 #endif
9517 }
9518 
9519 /*
9520  * cvacuum () - Client side function for vacuuming.
9521  *
9522  * return : Error code.
9523  */
9524 int
9525 cvacuum (void)
9526 {
9527 #if defined(CS_MODE)
9528  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9529  char *reply = NULL;
9530  int err = NO_ERROR;
9531 
9532  /* Reply should include error code */
9533  reply = OR_ALIGNED_BUF_START (a_reply);
9534 
9535  /* Send request to server */
9536  err = net_client_request (NET_SERVER_VACUUM, NULL, 0, reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
9537 
9538  if (err == NO_ERROR)
9539  {
9540  (void) or_unpack_int (reply, &err);
9541  }
9542 
9543  return err;
9544 #else /* !CS_MODE */
9545  int err;
9546 
9547  THREAD_ENTRY *thread_p = enter_server ();
9548 
9549  /* Call server function for vacuuming */
9550  err = xvacuum (thread_p);
9551 
9552  exit_server (*thread_p);
9553 
9554  return err;
9555 #endif /* CS_MODE */
9556 }
9557 
9558 /*
9559  * vacuum_dump -
9560  *
9561  * return:
9562  *
9563  * outfp(in):
9564  */
9565 void
9566 vacuum_dump (FILE * outfp)
9567 {
9568 #if defined(CS_MODE)
9569  int req_error;
9570 
9571  if (outfp == NULL)
9572  {
9573  outfp = stdout;
9574  }
9575 
9576  req_error = net_client_request_recv_stream (NET_SERVER_VACUUM_DUMP, NULL, 0, NULL, 0, NULL, 0, outfp);
9577 #else /* CS_MODE */
9578 
9579  THREAD_ENTRY *thread_p = enter_server ();
9580 
9581  xvacuum_dump (thread_p, outfp);
9582 
9583  exit_server (*thread_p);
9584 #endif /* !CS_MODE */
9585 }
9586 
9587 /*
9588  * log_get_mvcc_snapshot () - Get MVCC snapshot on server.
9589  *
9590  * return : Error code.
9591  */
9592 int
9594 {
9595 #if defined(CS_MODE)
9596  char *reply;
9597  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9598  int err = NO_ERROR;
9599 
9600  reply = OR_ALIGNED_BUF_START (a_reply);
9601  err =
9603  if (err != NO_ERROR)
9604  {
9605  or_unpack_int (reply, &err);
9606  }
9607 
9608  return err;
9609 #else /* !CS_MODE */
9610  int err;
9611 
9612  THREAD_ENTRY *thread_p = enter_server ();
9613 
9614  err = xlogtb_get_mvcc_snapshot (thread_p);
9615 
9616  exit_server (*thread_p);
9617 
9618  return err;
9619 #endif /* CS_MODE */
9620 }
9621 
9622 /*
9623  * locator_upgrade_instances_domain () - performs an upgrade of domain for
9624  * instances of a class
9625  * return : NO_ERROR if all OK, error status otherwise
9626  * class_oid(in) : class whose instances must be upgraded
9627  * attribute_id(in) : id attribute which must be upgraded
9628  *
9629  * Note: Used on ALTER CHANGE (with type change syntax) context
9630  */
9631 int
9632 locator_upgrade_instances_domain (OID * class_oid, int attribute_id)
9633 {
9634 #if defined(CS_MODE)
9635  int success = ER_FAILED, req_error;
9636  OR_ALIGNED_BUF (OR_OID_SIZE + OR_INT_SIZE) a_request;
9637  char *request, *reply, *ptr;
9638  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9639 
9640  request = OR_ALIGNED_BUF_START (a_request);
9641  reply = OR_ALIGNED_BUF_START (a_reply);
9642 
9643  if (class_oid == NULL || OID_ISNULL (class_oid) || attribute_id < 0)
9644  {
9646  }
9647 
9648  ptr = request;
9649  ptr = or_pack_oid (ptr, class_oid);
9650  ptr = or_pack_int (ptr, attribute_id);
9651 
9652  req_error =
9654  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
9655  if (!req_error)
9656  {
9657  ptr = or_unpack_int (reply, &success);
9658  }
9659 
9660  return success;
9661 #else /* CS_MODE */
9662  int error = NO_ERROR;
9663 
9664  THREAD_ENTRY *thread_p = enter_server ();
9665 
9666  error = xlocator_upgrade_instances_domain (thread_p, class_oid, attribute_id);
9667 
9668  exit_server (*thread_p);
9669  return error;
9670 #endif /* !CS_MODE */
9671 }
9672 
9673 /*
9674  * boot_get_server_locales () - get information about server locales
9675  *
9676  * return : error code or no error
9677  */
9678 int
9679 boot_get_server_locales (LANG_COLL_COMPAT ** server_collations, LANG_LOCALE_COMPAT ** server_locales,
9680  int *server_coll_cnt, int *server_locales_cnt)
9681 {
9682 #if defined(CS_MODE)
9683  int req_error;
9684  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
9685  char *reply = NULL;
9686  char *reply_data = NULL;
9687  char *ptr = NULL;
9688  int reply_size = 0, temp_int, i, dummy;
9689  char *temp_str;
9690  size_t size;
9691 
9692  assert (server_collations != NULL);
9693  assert (server_locales != NULL);
9694  assert (server_coll_cnt != NULL);
9695  assert (server_locales_cnt != NULL);
9696 
9697  *server_collations = NULL;
9698  *server_locales = NULL;
9699  *server_coll_cnt = 0;
9700  *server_locales_cnt = 0;
9701 
9702  req_error =
9704  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &reply_data, &reply_size);
9705  if (req_error != NO_ERROR)
9706  {
9707  goto error;
9708  }
9709 
9710  reply = OR_ALIGNED_BUF_START (a_reply);
9711  /* unpack data size */
9712  ptr = or_unpack_int (reply, &dummy);
9713  /* unpack error code */
9714  ptr = or_unpack_int (ptr, &req_error);
9715  if (req_error != NO_ERROR)
9716  {
9717  goto error;
9718  }
9719 
9720  assert (req_error == NO_ERROR);
9721  assert (reply_data != NULL);
9722 
9723  ptr = or_unpack_int (reply_data, server_coll_cnt);
9724  ptr = or_unpack_int (ptr, server_locales_cnt);
9725 
9726  size = (*server_coll_cnt * sizeof (LANG_COLL_COMPAT));
9727  *server_collations = (LANG_COLL_COMPAT *) malloc (size);
9728  if (*server_collations == NULL)
9729  {
9731  req_error = ER_FAILED;
9732  goto error;
9733  }
9734 
9735  size = (*server_locales_cnt * sizeof (LANG_LOCALE_COMPAT));
9736  *server_locales = (LANG_LOCALE_COMPAT *) malloc (size);
9737  if (*server_locales == NULL)
9738  {
9740  req_error = ER_FAILED;
9741  goto error;
9742  }
9743 
9744  for (i = 0; i < *server_coll_cnt; i++)
9745  {
9746  LANG_COLL_COMPAT *ref_coll = &((*server_collations)[i]);
9747 
9748  ptr = or_unpack_int (ptr, &(ref_coll->coll_id));
9749 
9750  ptr = or_unpack_string_nocopy (ptr, &(temp_str));
9751  strncpy (ref_coll->coll_name, temp_str, sizeof (ref_coll->coll_name) - 1);
9752  ref_coll->coll_name[sizeof (ref_coll->coll_name) - 1] = '\0';
9753 
9754  ptr = or_unpack_int (ptr, &(temp_int));
9755  ref_coll->codeset = (INTL_CODESET) temp_int;
9756 
9757  ptr = or_unpack_string_nocopy (ptr, &(temp_str));
9758  strncpy (ref_coll->checksum, temp_str, sizeof (ref_coll->checksum) - 1);
9759  ref_coll->checksum[sizeof (ref_coll->checksum) - 1] = '\0';
9760  }
9761 
9762  for (i = 0; i < *server_locales_cnt; i++)
9763  {
9764  LANG_LOCALE_COMPAT *ref_loc = &((*server_locales)[i]);
9765 
9766  ptr = or_unpack_string_nocopy (ptr, &(temp_str));
9767  strncpy (ref_loc->lang_name, temp_str, sizeof (ref_loc->lang_name) - 1);
9768  ref_loc->lang_name[sizeof (ref_loc->lang_name) - 1] = '\0';
9769 
9770  ptr = or_unpack_int (ptr, &(temp_int));
9771  ref_loc->codeset = (INTL_CODESET) temp_int;
9772 
9773  ptr = or_unpack_string_nocopy (ptr, &(temp_str));
9774  strncpy (ref_loc->checksum, temp_str, sizeof (ref_loc->checksum) - 1);
9775  ref_loc->checksum[sizeof (ref_loc->checksum) - 1] = '\0';
9776  }
9777 
9778  if (reply_data != NULL)
9779  {
9780  free_and_init (reply_data);
9781  }
9782  return req_error;
9783 
9784 error:
9785  if (reply_data != NULL)
9786  {
9787  free_and_init (reply_data);
9788  }
9789 
9790  return req_error;
9791 #else
9792  return -1;
9793 #endif
9794 }
9795 
9796 /*
9797  * tran_lock_rep_read () - Lock the object that is common to all RR transactions
9798  * return : NO_ERROR if all OK, error status otherwise
9799  * lock_rr_tran(in) : type of lock
9800  *
9801  * Note: This is used in ALTER TABLE ... ADD COLUMN ... NOT NULL scenarios
9802  */
9803 int
9804 tran_lock_rep_read (LOCK lock_rr_tran)
9805 {
9806 #if defined(CS_MODE)
9807  int req_error;
9808  OR_ALIGNED_BUF (OR_INT_SIZE) a_request;
9809  char *request, *reply, *ptr;
9810  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9811 
9812  request = OR_ALIGNED_BUF_START (a_request);
9813  reply = OR_ALIGNED_BUF_START (a_reply);
9814 
9815  ptr = request;
9816  ptr = or_pack_int (ptr, (int) lock_rr_tran);
9817 
9818  req_error =
9819  net_client_request (NET_SERVER_LOCK_RR, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
9820  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
9821  if (!req_error)
9822  {
9823  ptr = or_unpack_int (reply, &req_error);
9824  }
9825 
9826  if (req_error == NO_ERROR)
9827  {
9828  tm_Tran_rep_read_lock = lock_rr_tran;
9829  }
9830  return req_error;
9831 #else /* CS_MODE */
9832  return NO_ERROR; /* No need to lock */
9833 #endif /* !CS_MODE */
9834 }
9835 
9836 /*
9837  * boot_get_server_timezone_checksum () - get the timezone checksum from the
9838  * server
9839  *
9840  * return : error code or no error
9841  */
9842 int
9843 boot_get_server_timezone_checksum (char *timezone_checksum)
9844 {
9845 #if defined(CS_MODE)
9846  int req_error;
9847  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
9848  char *reply = NULL;
9849  char *reply_data = NULL;
9850  char *ptr = NULL;
9851  int reply_size = 0, dummy;
9852  char *temp_str;
9853 
9854  req_error =
9856  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &reply_data, &reply_size);
9857  if (req_error != NO_ERROR)
9858  {
9859  goto error;
9860  }
9861 
9862  reply = OR_ALIGNED_BUF_START (a_reply);
9863  /* unpack data size */
9864  ptr = or_unpack_int (reply, &dummy);
9865  /* unpack error code */
9866  ptr = or_unpack_int (ptr, &req_error);
9867  if (req_error != NO_ERROR)
9868  {
9869  goto error;
9870  }
9871 
9872  assert (reply_data != NULL);
9873 
9874  ptr = or_unpack_string_nocopy (reply_data, &(temp_str));
9875  strncpy (timezone_checksum, temp_str, TZ_CHECKSUM_SIZE);
9876  timezone_checksum[TZ_CHECKSUM_SIZE] = '\0';
9877 
9878  if (reply_data != NULL)
9879  {
9880  free_and_init (reply_data);
9881  }
9882  return req_error;
9883 
9884 error:
9885  if (reply_data != NULL)
9886  {
9887  free_and_init (reply_data);
9888  }
9889 
9890  return req_error;
9891 #else
9892  return -1;
9893 #endif
9894 }
9895 
9896 int
9898 {
9899 #if defined(CS_MODE)
9900  int req_error, success = ER_FAILED;
9901  int request_size = 0, strlen1, strlen2, strlen3, strlen4;
9902  char *request = NULL, *ptr;
9903  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9904  char *reply;
9905  REPL_INFO_SBR *repl_stmt;
9906 
9907  reply = OR_ALIGNED_BUF_START (a_reply);
9908 
9909  switch (repl_info->repl_info_type)
9910  {
9911  case REPL_INFO_TYPE_SBR:
9912  repl_stmt = (REPL_INFO_SBR *) repl_info->info;
9913  request_size = (OR_OID_SIZE /* class oid */
9914  + OR_INT_SIZE /* REPL_INFO.REPL_INFO_TYPE */
9915  + OR_INT_SIZE /* REPL_INFO_SCHEMA.statement_type */
9916  + length_const_string (repl_stmt->name, &strlen1)
9917  + length_const_string (repl_stmt->stmt_text, &strlen2)
9918  + length_const_string (repl_stmt->db_user, &strlen3)
9919  + length_const_string (repl_stmt->sys_prm_context, &strlen4));
9920 
9921  request = (char *) malloc (request_size);
9922  if (request == NULL)
9923  {
9924  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9925  return ER_FAILED;
9926  }
9927 
9928  ptr = or_pack_oid (request, class_oidp);
9929  ptr = or_pack_int (ptr, REPL_INFO_TYPE_SBR);
9930  ptr = or_pack_int (ptr, repl_stmt->statement_type);
9931  ptr = pack_const_string_with_length (ptr, repl_stmt->name, strlen1);
9932  ptr = pack_const_string_with_length (ptr, repl_stmt->stmt_text, strlen2);
9933  ptr = pack_const_string_with_length (ptr, repl_stmt->db_user, strlen3);
9934  ptr = pack_const_string_with_length (ptr, repl_stmt->sys_prm_context, strlen4);
9935  req_error =
9936  net_client_request (NET_SERVER_CHKSUM_REPL, request, request_size, reply, OR_ALIGNED_BUF_SIZE (a_reply),
9937  NULL, 0, NULL, 0);
9938  if (!req_error)
9939  {
9940  or_unpack_int (reply, &success);
9941  }
9942 
9943  free_and_init (request);
9944  break;
9945 
9946  default:
9947  break;
9948  }
9949 
9950  return success;
9951 #else /* CS_MODE */
9952  int r = ER_FAILED;
9953 
9954  THREAD_ENTRY *thread_p = enter_server ();
9955 
9956  r = xchksum_insert_repl_log_and_demote_table_lock (thread_p, repl_info, class_oidp);
9957 
9958  exit_server (*thread_p);
9959 
9960  return r;
9961 #endif /* !CS_MODE */
9962 }
9963 
9964 /*
9965  * log_does_active_user_exist () - Cbeck the specified user is an
9966  * active user or not
9967  * return: error code
9968  * user_name(in) :
9969  * existed (out) : true mean user is an active user
9970  */
9971 int
9972 log_does_active_user_exist (const char *user_name, bool * existed)
9973 {
9974 #if defined(CS_MODE)
9975  int error;
9976  int xexisted;
9977  int req_error, request_size, strlen;
9978  char *request;
9979  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9980  char *reply;
9981 
9982  *existed = false;
9983 
9984  reply = OR_ALIGNED_BUF_START (a_reply);
9985 
9986  request_size = length_const_string (user_name, &strlen);
9987  request = (char *) malloc (request_size);
9988  if (request == NULL)
9989  {
9990  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
9991  return ER_OUT_OF_VIRTUAL_MEMORY;
9992  }
9993 
9994  (void) pack_const_string_with_length (request, user_name, strlen);
9995 
9996  req_error = net_client_request (NET_SERVER_AU_DOES_ACTIVE_USER_EXIST, request, request_size, reply,
9997  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
9998  if (!req_error)
9999  {
10000  or_unpack_int (reply, &xexisted);
10001  if ((bool) xexisted)
10002  {
10003  *existed = true;
10004  }
10005  error = NO_ERROR;
10006  }
10007  else
10008  {
10009  assert (er_errid () != NO_ERROR);
10010  error = er_errid ();
10011  }
10012 
10013  free_and_init (request);
10014 
10015  return error;
10016 #else /* CS_MODE */
10017 
10018  /* in SA_MODE, no other active user */
10019  *existed = false;
10020  return NO_ERROR;
10021 #endif /* !CS_MODE */
10022 }
10023 
10024 /*
10025  * locator_redistribute_partition_data () - redistribute partition data
10026  *
10027  * return : error code
10028  *
10029  * thread_p (in) :
10030  * class_oid (in) : parent class OID
10031  * no_oids (in) : number of OIDs in the list (promoted partitions)
10032  * oid_list (in) : partition OID list (promoted partitions)
10033  */
10034 int
10035 locator_redistribute_partition_data (OID * class_oid, int no_oids, OID * oid_list)
10036 {
10037 #if defined(CS_MODE)
10038  int success = ER_FAILED, req_error;
10039  char *request, *reply, *ptr;
10040  int request_size = 0;
10041  int i;
10042  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10043 
10044  reply = OR_ALIGNED_BUF_START (a_reply);
10045 
10046  if (oid_list == NULL || no_oids < 1)
10047  {
10049  }
10050 
10051  request_size = OR_OID_SIZE + OR_INT_SIZE + no_oids * OR_OID_SIZE;
10052 
10053  request = (char *) malloc (request_size);
10054  if (request == NULL)
10055  {
10056  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) request_size);
10057  return ER_OUT_OF_VIRTUAL_MEMORY;
10058  }
10059 
10060  ptr = request;
10061  ptr = or_pack_oid (ptr, class_oid);
10062  ptr = or_pack_int (ptr, no_oids);
10063 
10064  for (i = 0; i < no_oids; i++)
10065  {
10066  ptr = or_pack_oid (ptr, &oid_list[i]);
10067  }
10068 
10069  req_error =
10070  net_client_request (NET_SERVER_LC_REDISTRIBUTE_PARTITION_DATA, request, request_size, reply,
10071  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
10072  if (!req_error)
10073  {
10074  ptr = or_unpack_int (reply, &success);
10075  }
10076 
10077  free_and_init (request);
10078 
10079  return success;
10080 
10081 #else /* CS_MODE */
10082  int success = ER_FAILED;
10083 
10084  THREAD_ENTRY *thread_p = enter_server ();
10085 
10086  success = xlocator_redistribute_partition_data (thread_p, class_oid, no_oids, oid_list);
10087 
10088  exit_server (*thread_p);
10089 
10090  return success;
10091 #endif /* !CS_MODE */
10092 }
10093 
10094 /*
10095  * netcl_spacedb () - client-side function to get database space info
10096  *
10097  * return : error code
10098  * spaceall (out) : output aggregated space information
10099  * spacevols (out) : if not NULL, output space information per volume
10100  * spacefiles (out) : if not NULL, out detailed space information on file usage
10101  */
10102 int
10103 netcl_spacedb (SPACEDB_ALL * spaceall, SPACEDB_ONEVOL ** spacevols, SPACEDB_FILES * spacefiles)
10104 {
10105 #if defined (CS_MODE)
10106  int error_code = NO_ERROR;
10107  OR_ALIGNED_BUF (2 * OR_INT_SIZE) a_request;
10108  char *request;
10109  OR_ALIGNED_BUF (2 * OR_INT_SIZE) a_reply;
10110  char *reply;
10111  char *data_reply = NULL;
10112  int data_reply_size = 0;
10113  char *ptr;
10114 
10115  request = OR_ALIGNED_BUF_START (a_request);
10116  reply = OR_ALIGNED_BUF_START (a_reply);
10117 
10118  ptr = or_pack_int (request, spacevols != NULL ? 1 : 0);
10119  ptr = or_pack_int (ptr, spacefiles != NULL ? 1 : 0);
10120 
10121  error_code = net_client_request2 (NET_SERVER_SPACEDB, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
10122  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &data_reply, &data_reply_size);
10123  if (error_code != NO_ERROR)
10124  {
10125  assert (data_reply == NULL);
10126  return error_code;
10127  }
10128  ptr = or_unpack_int (reply, &data_reply_size);
10129  ptr = or_unpack_int (ptr, &error_code);
10130  if (error_code != NO_ERROR)
10131  {
10132  /* error */
10133  ASSERT_ERROR ();
10134  return error_code;
10135  }
10136  if (data_reply == NULL)
10137  {
10138  assert_release (false);
10139  return ER_FAILED;
10140  }
10141  ptr = or_unpack_spacedb (data_reply, spaceall, spacevols, spacefiles);
10142  if (ptr == NULL)
10143  {
10144  ASSERT_ERROR_AND_SET (error_code);
10145  return error_code;
10146  }
10147  assert ((ptr - data_reply) == data_reply_size);
10148 
10149  free_and_init (data_reply);
10150  return NO_ERROR;
10151 
10152 #else /* !CS_MODE */ /* SA_MDOE */
10153  int error_code = ER_FAILED;
10154 
10155  THREAD_ENTRY *thread_p = enter_server ();
10156  error_code = disk_spacedb (thread_p, spaceall, spacevols);
10157  if (error_code != NO_ERROR)
10158  {
10159  ASSERT_ERROR ();
10160  }
10161  else if (spacefiles != NULL)
10162  {
10163  error_code = file_spacedb (thread_p, spacefiles);
10164  if (error_code != NO_ERROR)
10165  {
10166  ASSERT_ERROR ();
10167  }
10168  }
10169  exit_server (*thread_p);
10170 
10171  return error_code;
10172 #endif /* SA_MODE */
10173 }
10174 
10175 int
10176 locator_demote_class_lock (const OID * class_oid, LOCK lock, LOCK * ex_lock)
10177 {
10178 #if defined(CS_MODE)
10179  int rc = ER_FAILED;
10180  int req_error;
10181  char *ptr;
10182  OR_ALIGNED_BUF (OR_OID_SIZE + OR_INT_SIZE) a_request;
10183  char *request;
10185  char *reply;
10186 
10187  request = OR_ALIGNED_BUF_START (a_request);
10188  reply = OR_ALIGNED_BUF_START (a_reply);
10189 
10190  ptr = or_pack_oid (request, class_oid);
10191  ptr = or_pack_lock (ptr, lock);
10192 
10193  req_error = net_client_request (NET_SERVER_LC_DEMOTE_CLASS_LOCK, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
10194  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
10195  if (!req_error)
10196  {
10197  ptr = or_unpack_int (reply, &rc);
10198  ptr = or_unpack_lock (ptr, ex_lock);
10199  }
10200 
10201  if (rc == NO_ERROR)
10202  {
10203  // demote cached lock
10204  MOP class_mop = ws_mop (class_oid, sm_Root_class_mop);
10205 
10206  if (class_mop != NULL)
10207  {
10208  ws_set_lock (class_mop, lock);
10209  }
10210  }
10211 
10212  return rc;
10213 #else /* CS_MODE */
10214  return NO_ERROR;
10215 #endif /* !CS_MODE */
10216 }
10217 
10218 int
10220 {
10221 #if defined(CS_MODE)
10222  int rc = ER_FAILED;
10223  packing_packer packer;
10225 
10226  packer.set_buffer_and_pack_all (eb, args);
10227 
10228  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10229  char *reply = OR_ALIGNED_BUF_START (a_reply);
10230 
10231  int req_error = net_client_request (NET_SERVER_LD_INIT, eb.get_ptr (), (int) packer.get_current_size (), reply,
10232  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, NULL, 0);
10233  if (!req_error)
10234  {
10235  or_unpack_int (reply, &rc);
10236  }
10237 
10238  return rc;
10239 #else /* CS_MODE */
10240  return NO_ERROR;
10241 #endif /* !CS_MODE */
10242 }
10243 
10244 int
10245 loaddb_install_class (const cubload::batch & batch, bool & class_is_ignored, std::string & class_name)
10246 {
10247 #if defined(CS_MODE)
10248  int rc = ER_FAILED;
10249  packing_packer packer;
10251  int class_ignored = 0;
10252  char *ptr = NULL;
10253 
10254  packer.set_buffer_and_pack_all (eb, batch);
10255 
10256  OR_ALIGNED_BUF (3 * OR_INT_SIZE) a_reply;
10257  char *reply = OR_ALIGNED_BUF_START (a_reply);
10258  char *area = NULL;
10259  int area_size;
10260  int req_error = net_client_request2 (NET_SERVER_LD_INSTALL_CLASS, eb.get_ptr (), (int) packer.get_current_size (),
10261  reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &area, &area_size);
10262  if (!req_error)
10263  {
10264  ptr = or_unpack_int (reply, &area_size);
10265  ptr = or_unpack_int (ptr, &rc);
10266  ptr = or_unpack_int (ptr, &class_ignored);
10267  assert (area_size < DB_MAX_IDENTIFIER_LENGTH);
10268 
10269  class_name = std::string (area, area_size);
10270 
10271  free_and_init (area);
10272  class_is_ignored = class_ignored != 0;
10273  }
10274 
10275  return rc;
10276 #else /* CS_MODE */
10277  return NO_ERROR;
10278 #endif /* !CS_MODE */
10279 }
10280 
10281 int
10282 loaddb_load_batch (const cubload::batch & batch, bool use_temp_batch, bool & is_batch_accepted, load_status & status)
10283 {
10284 #if defined(CS_MODE)
10285  char *data_reply = NULL;
10286  int data_reply_size = 0;
10287  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
10288  char *reply = OR_ALIGNED_BUF_START (a_reply);
10289 
10290  packing_packer packer;
10292 
10293  if (use_temp_batch)
10294  {
10295  packer.set_buffer_and_pack_all (eb, use_temp_batch);
10296  }
10297  else
10298  {
10299  packer.set_buffer_and_pack_all (eb, use_temp_batch, batch);
10300  }
10301 
10302  int req_error = net_client_request2 (NET_SERVER_LD_LOAD_BATCH, eb.get_ptr (), (int) packer.get_current_size (), reply,
10303  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0, &data_reply, &data_reply_size);
10304  if (req_error != NO_ERROR)
10305  {
10306  return req_error;
10307  }
10308 
10309  char *ptr = or_unpack_int (reply, &data_reply_size);
10310 
10311  int rc = ER_FAILED;
10312  ptr = or_unpack_int (ptr, &rc);
10313  if (rc != NO_ERROR)
10314  {
10315  free_and_init (data_reply);
10316  return rc;
10317  }
10318 
10319  int is_batch_accepted_;
10320  or_unpack_int (ptr, &is_batch_accepted_);
10321  is_batch_accepted = is_batch_accepted_ != 0;
10322 
10323  packing_unpacker unpacker (data_reply, (size_t) data_reply_size);
10324  status.unpack (unpacker);
10325 
10326  free_and_init (data_reply);
10327 
10328  return rc;
10329 #else /* CS_MODE */
10330  return NO_ERROR;
10331 #endif /* !CS_MODE */
10332 }
10333 
10334 int
10336 {
10337 #if defined(CS_MODE)
10338  char *data_reply = NULL;
10339  int data_reply_size = 0;
10340  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10341  char *reply = OR_ALIGNED_BUF_START (a_reply);
10342 
10343  int req_error = net_client_request2 (NET_SERVER_LD_FETCH_STATUS, NULL, 0, reply, OR_ALIGNED_BUF_SIZE (a_reply), NULL,
10344  0, &data_reply, &data_reply_size);
10345  if (req_error != NO_ERROR)
10346  {
10347  return req_error;
10348  }
10349 
10350  or_unpack_int (reply, &data_reply_size);
10351 
10352  if (data_reply_size <= 0)
10353  {
10354  return ER_FAILED;
10355  }
10356 
10357  packing_unpacker unpacker (data_reply, (size_t) data_reply_size);
10358  status.unpack (unpacker);
10359 
10360  free_and_init (data_reply);
10361 
10362  return req_error;
10363 #else /* CS_MODE */
10364  return NO_ERROR;
10365 #endif /* !CS_MODE */
10366 }
10367 
10368 int
10370 {
10371 #if defined(CS_MODE)
10372  int rc = ER_FAILED;
10373  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10374  char *reply = OR_ALIGNED_BUF_START (a_reply);
10375 
10376  int req_error =
10378  if (!req_error)
10379  {
10380  or_unpack_int (reply, &rc);
10381  }
10382 
10383  return rc;
10384 #else /* CS_MODE */
10385  return NO_ERROR;
10386 #endif /* !CS_MODE */
10387 }
10388 
10389 int
10391 {
10392 #if defined(CS_MODE)
10394 #else /* CS_MODE */
10395  return NO_ERROR;
10396 #endif /* !CS_MODE */
10397 }
10398 
10399 int
10401 {
10402 #if defined(CS_MODE)
10403  int rc = ER_FAILED;
10404  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10405  char *reply = OR_ALIGNED_BUF_START (a_reply);
10406 
10407  int req_error =
10409  if (!req_error)
10410  {
10411  or_unpack_int (reply, &rc);
10412  }
10413 
10414  return rc;
10415 #else /* CS_MODE */
10416  return NO_ERROR;
10417 #endif /* !CS_MODE */
10418 }
TRAN_STATE xtran_server_2pc_prepare_global_tran(THREAD_ENTRY *thread_p, int gtrid)
char * locator_pack_oid_set(char *buffer, LC_OIDSET *oidset)
Definition: locator.c:2400
LC_FIND_CLASSNAME xlocator_delete_class_name(THREAD_ENTRY *thread_p, const char *classname)
Definition: locator_sr.c:755
LC_FETCH_VERSION_TYPE
Definition: locator.h:178
void set_buffer_and_pack_all(ExtBlk &eb, Args &&...args)
Definition: packer.hpp:341
bool xlocator_notify_isolation_incons(THREAD_ENTRY *thread_p, LC_COPYAREA **synch_area)
Definition: locator_sr.c:9132
int locator_does_exist(OID *oidp, int chn, LOCK lock, OID *class_oid, int class_chn, int need_fetching, int prefetch, LC_COPYAREA **fetch_copyarea, LC_FETCH_VERSION_TYPE fetch_version_type)
Definition: sha1.h:50
int xsession_delete_prepared_statement(THREAD_ENTRY *thread_p, const char *name)
Definition: session_sr.c:233
int btree_load_index(BTID *btid, const char *bt_name, TP_DOMAIN *key_type, OID *class_oids, int n_classes, int n_attrs, int *attr_ids, int *attrs_prefix_length, HFID *hfids, int unique_pk, int not_null_flag, OID *fk_refcls_oid, BTID *fk_refcls_pk_btid, const char *fk_name, char *pred_stream, int pred_stream_size, char *expr_stream, int expr_stream_size, int func_col_id, int func_attr_index_start, SM_INDEX_STATUS index_status)
int perfmon_server_start_stats(void)
char * or_unpack_oid(char *ptr, OID *oid)
#define OR_BTID_ALIGNED_SIZE
struct db_value DB_VALUE
Definition: dbtype_def.h:1079
DKNPAGES disk_get_total_numpages(VOLID volid)
int btree_add_index(BTID *btid, TP_DOMAIN *key_type, OID *class_oid, int attr_id, int unique_pk)
char * or_pack_btid(char *buf, const BTID *btid)
int page_size
Definition: unloaddb.c:52
int xheap_get_class_num_objects_pages(THREAD_ENTRY *thread_p, const HFID *hfid, int approximation, int *nobjs, int *npages)
Definition: heap_file.c:16396
cubthread::entry * thread_get_thread_entry_info(void)
#define NO_ERROR
Definition: error_code.h:46
int repl_set_info(REPL_INFO *repl_info)
off_t es_posix_get_file_size(const char *path)
int thread_kill_or_interrupt_tran(int *tran_index_list, int num_tran_index, bool is_dba_group_member, bool interrupt_only, int *num_killed)
int heap_get_class_num_objects_pages(HFID *hfid, int approximation, int *nobjs, int *npages)
int xsession_get_prepared_statement(THREAD_ENTRY *thread_p, const char *name, char **info, int *info_len, XASL_ID *xasl_id, xasl_node_header *xasl_header_p)
Definition: session_sr.c:190
int net_client_request_2recv_copyarea(int request, char *argbuf, int argsize, char *replybuf, int replysize, char *databuf, int datasize, char *recvbuffer, int recvbuffer_size, LC_COPYAREA **reply_copy_area, int *eid)
Definition: network_cl.c:2769
int perfmon_server_copy_global_stats(UINT64 *to_stats)
int xlogtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
int net_histo_stop(void)
Definition: network_cl.c:804
int serial_get_next_value(DB_VALUE *value, OID *oid_p, int cached_num, int num_alloc, int is_auto_increment)
int xheap_has_instance(THREAD_ENTRY *thread_p, const HFID *hfid, OID *class_oid, int has_visible_instance)
Definition: heap_file.c:16429
char lang_name[LANG_MAX_LANGNAME]
int file_spacedb(THREAD_ENTRY *thread_p, SPACEDB_FILES *spacedb)
LC_FIND_CLASSNAME locator_find_lockhint_class_oids(int num_classes, const char **many_classnames, LOCK *many_locks, int *many_need_subclasses, LC_PREFETCH_FLAGS *many_flags, OID *guessed_class_oids, int *guessed_class_chns, int quit_on_errors, LOCK lock_rr_tran, LC_LOCKHINT **lockhint, LC_COPYAREA **fetch_copyarea)
#define BO_IS_SERVER_RESTARTED()
Definition: boot_sr.h:84
XASL_NODE_HEADER * xasl_header
Definition: xasl.h:611
SYSPRM_ERR sysprm_obtain_server_parameters(SYSPRM_ASSIGN_VALUE **prm_values_ptr)
int btree_class_test_unique(char *buf, int buf_size)
char * or_unpack_string(char *ptr, char **string)
#define ASSERT_ERROR()
int xboot_check_db_consistency(THREAD_ENTRY *thread_p, int check_flag, OID *oids, int num_oids, BTID *index_btid)
Definition: boot_sr.c:3713
struct trans_info TRANS_INFO
MOP ws_mop(const OID *oid, MOP class_mop)
Definition: work_space.c:614
int sysprm_packed_assign_values_length(const SYSPRM_ASSIGN_VALUE *assign_values, int offset)
PAGE_PTR last_pgptr
Definition: query_list.h:434
int es_posix_create_file(char *new_path)
float disk_compatibility
Definition: boot.h:146
int xlocator_fetch_lockhint_classes(THREAD_ENTRY *thread_p, LC_LOCKHINT *lockhint, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:11291
int locator_notify_isolation_incons(LC_COPYAREA **synch_copyarea)
int locator_get_packed_oid_set_size(LC_OIDSET *oidset)
Definition: locator.c:2363
void xsysprm_obtain_server_parameters(SYSPRM_ASSIGN_VALUE *prm_values)
int es_posix_delete_file(const char *path)
int boot_copy(const char *from_dbname, const char *new_db_name, const char *new_db_path, const char *new_log_path, const char *new_lob_path, const char *new_db_server_host, const char *new_volext_path, const char *fileof_vols_and_copypaths, bool new_db_overwrite)
void LSA_COPY(log_lsa *plsa1, const log_lsa *plsa2)
Definition: log_lsa.hpp:139
int stats_update_all_statistics(int with_fullscan)
#define SHA1_HASH_INITIALIZER
Definition: sha1.h:54
void locator_free_copy_area(LC_COPYAREA *copyarea)
Definition: locator.c:534
int db_Connect_status
Definition: db_macro.c:88
int tde_change_mk_on_server(int mk_index)
int locator_assign_oid_batch(LC_OIDSET *oidset)
PAGEID DKNPAGES
int qmgr_end_query(QUERY_ID query_id)
int boot_notify_ha_log_applier_state(HA_LOG_APPLIER_STATE state)
char * or_unpack_unbound_listid(char *ptr, void **listid_ptr)
int locator_fetch_lockset(LC_LOCKSET *lockset, LC_COPYAREA **fetch_copyarea)
int btree_get_stats(THREAD_ENTRY *thread_p, BTREE_STATS *stat_info_p, bool with_fullscan)
Definition: btree.c:6959
LC_LOCKHINT * locator_allocate_and_unpack_lockhint(char *unpacked, int unpacked_size, bool unpack_classes, bool reg_unpacked)
Definition: locator.c:1876
int xsession_get_row_count(THREAD_ENTRY *thread_p, int *row_count)
Definition: session_sr.c:91
int xfile_apply_tde_to_class_files(THREAD_ENTRY *thread_p, const OID *class_oid)
TRAN_STATE xtran_server_partial_abort(THREAD_ENTRY *thread_p, const char *savept_name, LOG_LSA *savept_lsa)
#define ER_FAILED
Definition: error_code.h:47
int locator_redistribute_partition_data(OID *class_oid, int no_oids, OID *oid_list)
int log_does_active_user_exist(const char *user_name, bool *existed)
int csession_reset_cur_insert_id(void)
#define NULL_TRANID
int net_client_request2(int request, char *argbuf, int argsize, char *replybuf, int replysize, char *databuf, int datasize, char **replydata_ptr, int *replydatasize_ptr)
Definition: network_cl.c:1288
bool boot_shutdown_server(ER_FINAL_CODE iserfinal)
int boot_soft_rename(const char *old_db_name, const char *new_db_name, const char *new_db_path, const char *new_log_path, const char *new_db_server_host, const char *new_volext_path, const char *fileof_vols_and_renamepaths, bool new_db_overwrite, bool extern_rename, bool force_delete)
char * xdisk_get_remarks(THREAD_ENTRY *thread_p, VOLID volid)
char * or_unpack_string_alloc(char *ptr, char **string)
const char * tran_get_tranlist_state_name(TRAN_STATE state)
int csession_set_row_count(int rows)
void sysprm_dump_server_parameters(FILE *outfp)
char * packed
Definition: locator.h:328
char * locator_unpack_copy_area_descriptor(int num_objs, LC_COPYAREA *copyarea, char *desc)
Definition: locator.c:619
char * or_pack_db_value(char *buffer, DB_VALUE *var)
int thread_kill_tran_index(int kill_tran_index, char *kill_user, char *kill_host, int kill_pid)
int xboot_register_client(THREAD_ENTRY *thread_p, BOOT_CLIENT_CREDENTIAL *client_credential, int client_lock_wait, TRAN_ISOLATION client_isolation, TRAN_STATE *tran_state, BOOT_SERVER_CREDENTIAL *server_credential)
Definition: boot_sr.c:3179
LOG_LSA * xrepl_log_get_append_lsa(void)
Definition: locator_sr.c:11669
#define LC_ERROR
int locator_repl_force(LC_COPYAREA *copy_area, LC_COPYAREA **reply_copy_area)
int tran_server_savepoint(const char *savept_name, LOG_LSA *savept_lsa)
int db_value_clone(DB_VALUE *src, DB_VALUE *dest)
Definition: db_macro.c:1564
int xserial_get_current_value(THREAD_ENTRY *thread_p, DB_VALUE *result_num, const OID *oid_p, int cached_num)
Definition: serial.c:156
char * mem
Definition: locator.h:247
#define OR_HFID_SIZE
char * packed
Definition: locator.h:302
int histo_stop(void)
int tran_lock_rep_read(LOCK lock_rr_tran)
char * or_pack_string(char *ptr, const char *string)
#define OR_UNPACK_XASL_NODE_HEADER(PTR, X)
Definition: xasl.h:86
void xlogtb_dump_trantable(THREAD_ENTRY *thread_p, FILE *out_fp)
const LOG_PAGEID LOGPB_HEADER_PAGE_ID
Definition: log_storage.hpp:51
int xcatalog_check_rep_dir(THREAD_ENTRY *thread_p, OID *class_id, OID *rep_dir_p)
char * or_pack_value(char *buf, DB_VALUE *value)
int net_client_request_no_reply(int request, char *argbuf, int argsize)
Definition: network_cl.c:896
#define ASSERT_ERROR_AND_SET(error_code)
int xlocator_force(THREAD_ENTRY *thread_p, LC_COPYAREA *copy_area, int num_ignore_error_list, int *ignore_error_list)
Definition: locator_sr.c:6983
BTID * xbtree_add_index(THREAD_ENTRY *thread_p, BTID *btid, TP_DOMAIN *key_type, OID *class_oid, int attr_id, int unique_pk, int num_oids, int num_nulls, int num_keys)
Definition: btree.c:5579
void qmgr_dump_query_plans(FILE *outfp)
#define assert_release(e)
Definition: error_manager.h:96
TRAN_STATE tran_server_2pc_prepare_global_tran(int gtrid)
int xtran_server_start_topop(THREAD_ENTRY *thread_p, LOG_LSA *topop_lsa)
int xrepl_set_info(THREAD_ENTRY *thread_p, REPL_INFO *repl_info)
Definition: locator_sr.c:11642
void logtb_dump_trantable(FILE *outfp)
VOLID boot_find_last_permanent(void)
int pkeys_size
Definition: statistics.h:66
INT16 VOLID
unsigned int db_on_server
int qmgr_drop_all_query_plans(void)
TRANS_INFO * logtb_get_trans_info(bool include_query_exec_info)
int sysprm_get_force_server_parameters(SYSPRM_ASSIGN_VALUE **change_values)
char * info
Definition: replication.h:54
int tran_server_2pc_recovery_prepared(int gtrids[], int size)
char * or_unpack_spacedb(char *ptr, SPACEDB_ALL *all, SPACEDB_ONEVOL **vols, SPACEDB_FILES *files)
VOLID xboot_find_last_permanent(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:377
#define OR_ALIGNED_BUF(size)
int locator_get_reserved_class_name_oid(const char *classname, OID *class_oid)
#define OR_PTR_SIZE
int locator_fetch_lockhint_classes(LC_LOCKHINT *lockhint, LC_COPYAREA **fetch_copyarea)
BTREE_SEARCH xbtree_find_multi_uniques(THREAD_ENTRY *thread_p, OID *class_oid, int pruning_type, BTID *btids, DB_VALUE *values, int count, SCAN_OPERATION_TYPE op_type, OID **oids, int *oids_count)
Definition: btree.c:5848
OID * ws_identifier(MOP mop)
Definition: work_space.c:2805
TRAN_STATE xtran_server_commit(THREAD_ENTRY *thrd, bool retain_lock)
int loaddb_destroy()
#define OID_SET_NULL(oidp)
Definition: oid.h:85
int csession_get_row_count(int *rows)
int xbtree_delete_index(THREAD_ENTRY *thread_p, BTID *btid)
Definition: btree.c:5691
static int eid
Definition: cas_error_log.c:61
int xqmgr_end_query(THREAD_ENTRY *thrd, QUERY_ID query_id)
int xlocator_fetch_all(THREAD_ENTRY *thread_p, const HFID *hfid, LOCK *lock, LC_FETCH_VERSION_TYPE fetch_type, OID *class_oid, int *nobjects, int *nfetched, OID *last_oid, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:2773
int logwr_get_log_pages(LOGWR_CONTEXT *ctx_ptr)
char * sysprm_pack_assign_values(char *ptr, const SYSPRM_ASSIGN_VALUE *assign_values)
int tde_get_mk_file_path(char *mk_path)
bool is_xasl_pinned_reference
int locator_fetch(OID *oidp, int chn, LOCK lock, LC_FETCH_VERSION_TYPE fetch_version_type, OID *class_oid, int class_chn, int prefetch, LC_COPYAREA **fetch_copyarea)
void log_set_interrupt(int set)
int xtran_server_2pc_attach_global_tran(THREAD_ENTRY *thread_p, int gtrid)
int xtran_server_set_global_tran_info(THREAD_ENTRY *thread_p, int gtrid, void *info, int size)
#define OR_INT64_SIZE
int xboot_initialize_server(const BOOT_CLIENT_CREDENTIAL *client_credential, BOOT_DB_PATH_INFO *db_path_info, bool db_overwrite, const char *file_addmore_vols, volatile DKNPAGES db_npages, PGLENGTH db_desired_pagesize, volatile DKNPAGES xlog_npages, PGLENGTH db_desired_log_page_size, OID *rootclass_oid, HFID *rootclass_hfid, int client_lock_wait, TRAN_ISOLATION client_isolation)
Definition: boot_sr.c:1462
char * or_unpack_string_nocopy(char *ptr, char **string)
enum lc_prefetch_flags LC_PREFETCH_FLAGS
Definition: locator.h:339
int xlocator_redistribute_partition_data(THREAD_ENTRY *thread_p, OID *class_oid, int no_oids, OID *oid_list)
Definition: locator_sr.c:12854
int SHA1Compute(const unsigned char *message_array, size_t length, SHA1Hash *hash)
Definition: sha1.c:372
int xqfile_get_list_file_page(THREAD_ENTRY *thread_p, QUERY_ID query_id, VOLID volid, PAGEID pageid, char *page_bufp, int *page_sizep)
Definition: list_file.c:2200
int er_errid(void)
int es_posix_rename_file(const char *src_path, const char *metaname, char *new_path)
int xboot_restart_from_backup(THREAD_ENTRY *thread_p, int print_restart, const char *db_name, BO_RESTART_ARG *r_args)
Definition: boot_sr.c:2850
#define OR_ALIGNED_BUF_SIZE(abuf)
void er_restore_last_error(void)
char * or_pack_oid(char *ptr, const OID *oid)
int compact_db_start(void)
int tran_server_set_global_tran_info(int gtrid, void *info, int size)
void sysprm_free_assign_values(SYSPRM_ASSIGN_VALUE **assign_values_ptr)
TRAN_STATE xtran_server_abort(THREAD_ENTRY *thrd)
void xserial_decache(THREAD_ENTRY *thread_p, OID *oidp)
Definition: serial.c:1366
int or_packed_domain_size(struct tp_domain *domain, int include_classoids)
ssize_t es_posix_read_file(const char *path, void *buf, size_t count, off_t offset)
#define er_log_debug(...)
int xsession_create_new(THREAD_ENTRY *thread_p, SESSION_ID *id)
Definition: session_sr.c:38
int net_client_request_recv_stream(int request, char *argbuf, int argsize, char *replybuf, int replybuf_size, char *databuf, int datasize, FILE *outfp)
Definition: network_cl.c:3587
void vacuum_dump(FILE *outfp)
char * or_unpack_log_lsa(char *ptr, struct log_lsa *lsa)
void xlogpb_dump_stat(FILE *outfp)
int locator_upgrade_instances_domain(OID *class_oid, int attribute_id)
int xboot_emergency_patch(const char *db_name, bool recreate_log, DKNPAGES log_npages, const char *db_locale, FILE *out_fp)
Definition: boot_sr.c:5335
int ib_get_thread_count()
#define ER_ONLY_IN_STANDALONE
Definition: error_code.h:731
int net_client_request2_no_malloc(int request, char *argbuf, int argsize, char *replybuf, int replysize, char *databuf, int datasize, char *replydata, int *replydatasize_ptr)
Definition: network_cl.c:1395
#define MAX_ALIGNMENT
Definition: memory_alloc.h:70
char * or_unpack_errcode(char *ptr, int *error)
struct lang_locale_compat LANG_LOCALE_COMPAT
int tran_server_2pc_start(void)
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
Definition: oid.h:63
int packed_size
Definition: locator.h:327
int length
Definition: locator.h:248
char * sysprm_pack_session_parameters(char *ptr, SESSION_PARAM *session_parameters)
int histo_print(FILE *stream)
int xboot_find_number_temp_volumes(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:359
int boot_register_client(BOOT_CLIENT_CREDENTIAL *client_credential, int client_lock_wait, TRAN_ISOLATION client_isolation, TRAN_STATE *tran_state, BOOT_SERVER_CREDENTIAL *server_credential)
int heap_destroy_newly_created(const HFID *hfid, const OID *class_oid)
int xtde_get_mk_info(THREAD_ENTRY *thread_p, int *mk_index, time_t *created_time, time_t *set_time)
Definition: tde.c:1214
int xlogtb_reset_wait_msecs(THREAD_ENTRY *thread_p, int wait_msecs)
int btree_get_statistics(BTID *btid, BTREE_STATS *stat_info)
int xlogin_user(THREAD_ENTRY *thread_p, const char *username)
Definition: session_sr.c:245
int tde_get_mk_info(int *mk_index, time_t *created_time, time_t *set_time)
bool include_query_exec_info
struct lang_coll_compat LANG_COLL_COMPAT
#define NET_SENDRECV_BUFFSIZE
void THREAD_ENTRY
int xlocator_assign_oid_batch(THREAD_ENTRY *thread_p, LC_OIDSET *oidset)
Definition: locator_sr.c:11512
#define TZ_CHECKSUM_SIZE
void xlogtb_set_interrupt(THREAD_ENTRY *thread_p, int set)
#define NULL_PAGEID
int or_packed_stream_length(size_t len)
int qp_get_server_info(PARSER_CONTEXT *parser, int server_info_bits)
#define OR_ALIGNED_BUF_START(abuf)
void net_histo_clear(void)
Definition: network_cl.c:666
LOCK
LC_FIND_CLASSNAME locator_find_class_oid(const char *class_name, OID *class_oid, LOCK lock)
int csession_get_variable(DB_VALUE *name, DB_VALUE *value)
int boot_heap_compact(OID *class_oid)
int locator_remove_class_from_index(OID *oid, BTID *btid, HFID *hfid)
BTREE_SEARCH xbtree_find_unique(THREAD_ENTRY *thread_p, BTID *btid, SCAN_OPERATION_TYPE scan_op_type, DB_VALUE *key, OID *class_oid, OID *oid, bool is_all_class_srch)
Definition: btree.c:23990
char * or_pack_int64(char *ptr, INT64 number)
int file_apply_tde_to_class_files(const OID *class_oid)
int es_posix_copy_file(const char *src_path, const char *metaname, char *new_path)
PGLENGTH log_page_size
Definition: boot.h:145
unsigned int DB_TIMESTAMP
Definition: dbtype_def.h:759
int boot_check_db_consistency(int check_flag, OID *oids, int num_oids, BTID *index_btid)
const char * boot_db_full_name()
Definition: boot_sr.c:470
LC_FIND_CLASSNAME xlocator_reserve_class_names(THREAD_ENTRY *thread_p, const int num_classes, const char **classname, OID *class_oid)
Definition: locator_sr.c:409
void acl_dump(FILE *outfp)
PGLENGTH page_size
Definition: boot.h:144
int histo_print_global_stats(FILE *stream, bool cumulative, const char *substr)
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
char * xdisk_get_fullname(THREAD_ENTRY *thread_p, VOLID volid, char *vol_fullname)
int xlocator_does_exist(THREAD_ENTRY *thread_p, OID *oid, int chn, LOCK lock, LC_FETCH_VERSION_TYPE fetch_version_type, OID *class_oid, int class_chn, int need_fetching, int prefetching, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:3891
int xboot_find_number_permanent_volumes(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:341
char * or_pack_hfid(const char *ptr, const HFID *hfid)
int xbtree_class_test_unique(THREAD_ENTRY *thread_p, char *buf, int buf_size)
Definition: btree.c:6065
char * or_pack_stream(char *ptr, const char *stream, size_t len)
void locator_manyobj_flag_remove(LC_COPYAREA_MANYOBJS *copyarea, enum MULTI_UPDATE_FLAG muf)
Definition: locator.c:2603
int log_set_no_logging(void)
Definition: log_manager.c:951
int xlocator_fetch(THREAD_ENTRY *thrd, OID *oid, int chn, LOCK lock, LC_FETCH_VERSION_TYPE fetch_version_type, LC_FETCH_VERSION_TYPE initial_fetch_version_type, OID *class_oid, int class_chn, int prefetching, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:2375
void net_cleanup_client_queues(void)
Definition: network_cl.c:3975
#define ER_QPROC_INVALID_PARAMETER
Definition: error_code.h:963
void tran_set_latest_query_status(int end_query_result, int tran_state, int should_conn_reset)
void xqmgr_dump_query_plans(THREAD_ENTRY *thread_p, FILE *outfp)
void db_clear_private_heap(THREAD_ENTRY *thread_p, HL_HEAPID heap_id)
Definition: memory_alloc.c:314
#define assert(x)
int xheap_destroy_newly_created(THREAD_ENTRY *thread_p, const HFID *hfid, const OID *class_oid)
Definition: heap_file.c:5818
FILEIO_ZIP_LEVEL
Definition: file_io.h:113
int heap_reclaim_addresses(const HFID *hfid)
int * pkeys
Definition: statistics.h:67
int xchksum_insert_repl_log_and_demote_table_lock(THREAD_ENTRY *thread_p, REPL_INFO *repl_info, const OID *class_oidp)
Definition: locator_sr.c:12560
int or_packed_string_length(const char *string, int *strlen)
int net_client_request_recv_copyarea(int request, char *argbuf, int argsize, char *replybuf, int replysize, LC_COPYAREA **reply_copy_area)
Definition: network_cl.c:2583
HL_HEAPID db_create_private_heap(void)
Definition: memory_alloc.c:294
void log_dump_stat(FILE *outfp)
char * or_unpack_btid(char *buf, BTID *btid)
int xlocator_assign_oid(THREAD_ENTRY *thread_p, const HFID *hfid, OID *perm_oid, int expected_length, OID *class_oid, const char *classname)
Definition: locator_sr.c:2044
#define ER_GENERIC_ERROR
Definition: error_code.h:49
char * perfmon_unpack_stats(char *buf, UINT64 *stats)
#define DB_CONNECTION_STATUS_RESET
Definition: db.h:48
int loaddb_install_class(const cubload::batch &batch, bool &class_is_ignored, std::string &class_name)
size_t get_current_size(void)
Definition: packer.cpp:936
int net_histo_print(FILE *stream)
Definition: network_cl.c:695
int qmgr_prepare_query(COMPILE_CONTEXT *context, xasl_stream *stream)
int xlocator_remove_class_from_index(THREAD_ENTRY *thread_p, OID *oid, BTID *btid, HFID *hfid)
Definition: locator_sr.c:8842
int locator_demote_class_lock(const OID *class_oid, LOCK lock, LOCK *ex_lock)
DB_IDENTIFIER OID
Definition: dbtype_def.h:967
LC_FIND_CLASSNAME xlocator_find_class_oid(THREAD_ENTRY *thread_p, const char *classname, OID *class_oid, LOCK lock)
Definition: locator_sr.c:1033
#define TDE_DATA_KEY_LENGTH
Definition: tde.h:55
#define ER_OUT_OF_VIRTUAL_MEMORY
Definition: error_code.h:50
TDE_CIPHER tde_Cipher
Definition: tde.c:69
int tran_server_has_updated(void)
HL_HEAPID private_heap_id
Definition: memory_alloc.c:55
char * or_unpack_hfid(char *ptr, HFID *hfid)
#define OR_VALUE_ALIGNED_SIZE(value)
char * sysprm_unpack_assign_values(char *ptr, SYSPRM_ASSIGN_VALUE **assign_values_ptr)
int xsession_get_last_insert_id(THREAD_ENTRY *thread_p, DB_VALUE *value, bool update_last_insert_id)
Definition: session_sr.c:126
char * or_unpack_lock(char *ptr, LOCK *lock)
int db_sys_date_and_epoch_time(DB_VALUE *dt_dbval, DB_VALUE *ts_dbval)
int sysprm_packed_session_parameters_length(SESSION_PARAM *session_parameters, int offset)
char * or_pack_sha1(char *ptr, const SHA1Hash *sha1)
BTREE_SEARCH
#define IS_QUERY_EXECUTED_WITHOUT_DATA_BUFFERS(flag)
Definition: query_list.h:581
DB_VALUE local_transaction_id
Definition: parse_tree.h:3583
void tde_make_keys_file_fullname(char *keys_vol_fullname, const char *db_full_name, bool ignore_parm)
Definition: tde.c:492
#define DB_MAX_IDENTIFIER_LENGTH
Definition: dbtype_def.h:495
LC_COPYAREA * locator_allocate_copy_area_by_length(int min_length)
Definition: locator.c:407
TRAN_STATE tran_server_commit(bool retain_lock)
char * or_pack_string_with_null_padding(char *ptr, const char *stream, size_t len)
#define OR_XASL_ID_SIZE
Definition: xasl.h:578
DB_TRAN_ISOLATION
Definition: dbtran_def.h:26
int xsession_create_prepared_statement(THREAD_ENTRY *thread_p, char *name, char *alias_print, SHA1Hash *sha1, char *info, int info_len)
Definition: session_sr.c:171
LC_LOCKSET * locator_allocate_and_unpack_lockset(char *unpacked, int unpacked_size, bool unpack_classes, bool unpack_objects, bool reg_unpacked)
Definition: locator.c:1302
static enum scanner_mode mode
void xsysprm_change_server_parameters(const SYSPRM_ASSIGN_VALUE *assignments)
void xlogtb_set_suppress_repl_on_transaction(THREAD_ENTRY *thread_p, int set)
DB_VALUE sys_epochtime
Definition: parse_tree.h:3581
unsigned char perm_key[TDE_DATA_KEY_LENGTH]
Definition: tde.h:87
char * disk_get_remarks(VOLID volid)
bool first_fetch_lockhint_call
Definition: locator.h:331
TRAN_STATE xtran_server_end_topop(THREAD_ENTRY *thread_p, LOG_RESULT_TOPOP result, LOG_LSA *topop_lsa)
int xboot_backup(THREAD_ENTRY *thread_p, const char *backup_path, FILEIO_BACKUP_LEVEL backup_level, bool delete_unneeded_logarchives, const char *backup_verbose_file, int num_threads, FILEIO_ZIP_METHOD zip_method, FILEIO_ZIP_LEVEL zip_level, int skip_activelog, int sleep_msecs, bool separate_keys)
Definition: boot_sr.c:3939
int net_histo_print_global_stats(FILE *stream, bool cumulative, const char *substr)
Definition: network_cl.c:756
enum ha_log_applier_state HA_LOG_APPLIER_STATE
int perfmon_get_number_of_statistic_values(void)
void thread_dump_cs_stat(FILE *outfp)
DB_OBJECT * db_get_object(const DB_VALUE *value)
int substr(std::string &result, bool &is_matched, const cub_regex_object &reg, const std::string &src, const int position, const int occurrence, const INTL_CODESET codeset)
#define LOGWR_COPY_FROM_FIRST_PHY_PAGE_MASK
Definition: log_writer.h:55
int xheap_create(THREAD_ENTRY *thread_p, HFID *hfid, const OID *class_oid, bool reuse_oid)
Definition: heap_file.c:5772
int loaddb_interrupt()
struct one_tran_info ONE_TRAN_INFO
#define DB_MAX_PATH_LENGTH
int xlogtb_reset_isolation(THREAD_ENTRY *thread_p, TRAN_ISOLATION isolation)
int xsession_check_session(THREAD_ENTRY *thread_p, const SESSION_ID id)
Definition: session_sr.c:53
int loaddb_update_stats()
char * disk_get_fullname(VOLID volid, char *vol_fullname)
static void cleanup(int signo)
Definition: broker.c:717
INT64 LOG_PAGEID
SP_PARSER_CTX * parser
int xtde_change_mk_without_flock(THREAD_ENTRY *thread_p, const int mk_index)
Definition: tde.c:1246
TRAN_STATE tran_server_2pc_prepare(void)
int db_sys_timestamp(DB_VALUE *result_timestamp)
#define NULL
Definition: freelistheap.h:34
static int total_objects
Definition: compactdb.c:56
ONE_TRAN_INFO tran[1]
int heap_create(HFID *hfid, const OID *class_oid, bool reuse_oid)
int csession_set_session_variables(DB_VALUE *variables, const int count)
int boot_unregister_client(int tran_index)
#define LC_EXIST
char * or_unpack_float(char *ptr, float *number)
bool locator_unpack_oid_set_to_exist(char *buffer, LC_OIDSET *use)
Definition: locator.c:2445
int net_client_request_3_data(int request, char *argbuf, int argsize, char *databuf1, int datasize1, char *databuf2, int datasize2, char *reply0, int replysize0, char *reply1, int replysize1, char *reply2, int replysize2)
Definition: network_cl.c:1490
LC_FIND_CLASSNAME xlocator_rename_class_name(THREAD_ENTRY *thread_p, const char *oldname, const char *newname, OID *class_oid)
Definition: locator_sr.c:916
int xqmgr_prepare_query(THREAD_ENTRY *thrd, compile_context *ctx, xasl_stream *stream)
#define OR_BIGINT_SIZE
int boot_backup(const char *backup_path, FILEIO_BACKUP_LEVEL backup_level, bool delete_unneeded_logarchives, const char *backup_verbose_file, int num_threads, FILEIO_ZIP_METHOD zip_method, FILEIO_ZIP_LEVEL zip_level, int skip_activelog, int sleep_msecs, bool separate_keys)
int csession_create_prepared_statement(const char *name, const char *alias_print, char *stmt_info, int info_length)
int xbtree_get_key_type(THREAD_ENTRY *thread_p, BTID btid, TP_DOMAIN **key_type)
Definition: btree.c:7167
DKNPAGES xdisk_get_total_numpages(THREAD_ENTRY *thread_p, VOLID volid)
static int success()
LC_FIND_CLASSNAME
void logtb_free_trans_info(TRANS_INFO *info)
#define err(fd,...)
Definition: porting.h:431
#define db_private_free_and_init(thrd, ptr)
Definition: memory_alloc.h:141
int xserial_get_next_value(THREAD_ENTRY *thread_p, DB_VALUE *result_num, const OID *oid_p, int cached_num, int num_alloc, int is_auto_increment, bool force_set_last_insert_id)
Definition: serial.c:282
int csession_get_last_insert_id(DB_VALUE *value, bool update_last_insert_id)
int boot_find_number_permanent_volumes(void)
int xvacuum(THREAD_ENTRY *thread_p)
Definition: vacuum.c:962
#define DB_EMPTY_SESSION
Definition: dbtype_def.h:483
static int failed_objects
Definition: compactdb.c:57
int locator_assign_oid(const HFID *hfid, OID *perm_oid, int expected_length, OID *class_oid, const char *class_name)
ssize_t es_posix_write_file(const char *path, const void *buf, size_t count, off_t offset)
int xsession_set_session_variables(THREAD_ENTRY *thread_p, DB_VALUE *values, const int count)
Definition: session_sr.c:258
int tran_server_2pc_attach_global_tran(int gtrid)
void xvacuum_dump(THREAD_ENTRY *thread_p, FILE *outfp)
Definition: vacuum.c:1104
char * or_unpack_int(char *ptr, int *number)
#define db_private_free(thrd, ptr)
Definition: memory_alloc.h:229
SCAN_OPERATION_TYPE
HA_SERVER_STATE ha_server_state
Definition: boot.h:147
int stats_get_statistics_from_server(OID *classoid, unsigned int timestamp, int *length_ptr, char **stats_buffer)
void db_set_execution_plan(char *plan, int length)
Definition: db_query.c:3567
int log_set_suppress_repl_on_transaction(int set)
#define db_private_alloc(thrd, size)
Definition: memory_alloc.h:227
int csession_delete_prepared_statement(const char *name)
char * or_unpack_int64(char *ptr, INT64 *number)
void xperfmon_server_copy_stats(THREAD_ENTRY *thread_p, UINT64 *to_stats)
#define OR_PTR_ALIGNED_SIZE
LC_FIND_CLASSNAME locator_reserve_class_names(const int num_classes, const char **class_names, OID *class_oids)
#define OR_LOG_LSA_ALIGNED_SIZE
#define OR_PACK_CACHE_TIME(PTR, T)
Definition: cache_time.h:58
LOCK tm_Tran_rep_read_lock
char * db_name
int btree_get_index_key_type(BTID btid, TP_DOMAIN **key_type_p)
int xtran_server_get_global_tran_info(THREAD_ENTRY *thread_p, int gtrid, void *buffer, int size)
void xlock_dump(THREAD_ENTRY *thread_p, FILE *outfp)
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
int perfmon_server_stop_stats(void)
int stats_update_statistics(OID *classoid, int with_fullscan)
int xtran_server_is_active_and_has_updated(THREAD_ENTRY *thread_p)
LC_FIND_CLASSNAME xlocator_find_lockhint_class_oids(THREAD_ENTRY *thread_p, int num_classes, const char **many_classnames, LOCK *many_locks, int *many_need_subclasses, LC_PREFETCH_FLAGS *many_flags, OID *guessed_class_oids, int *guessed_class_chns, bool quit_on_errors, LC_LOCKHINT **hlock, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:11017
int xsession_drop_session_variables(THREAD_ENTRY *thread_p, DB_VALUE *values, const int count)
Definition: session_sr.c:306
void sysprm_free_session_parameters(SESSION_PARAM **session_parameters_ptr)
bool histo_is_supported(void)
int xsession_reset_cur_insert_id(THREAD_ENTRY *thread_p)
Definition: session_sr.c:147
HA_SERVER_STATE boot_change_ha_mode(HA_SERVER_STATE state, bool force, int timeout)
#define d1
TRAN_STATE tran_server_abort(void)
#define CAST_BUFLEN
Definition: porting.h:471
int locator_get_class(OID *class_oid, int class_chn, const OID *oid, LOCK lock, int prefetching, LC_COPYAREA **fetch_copyarea)
int csession_drop_session_variables(DB_VALUE *variables, const int count)
#define NULL_TRAN_INDEX
int xsession_end_session(THREAD_ENTRY *thread, const SESSION_ID id)
Definition: session_sr.c:65
#define OR_UNPACK_XASL_ID(PTR, X)
Definition: xasl.h:591
static void error(const char *msg)
Definition: gencat.c:331
void ws_set_lock(MOP mop, LOCK lock)
Definition: work_space.c:2954
int xsession_set_row_count(THREAD_ENTRY *thread_p, int row_count)
Definition: session_sr.c:78
static int rc
Definition: serial.c:50
char * or_pack_int(char *ptr, int number)
int xsession_get_session_variable_no_copy(THREAD_ENTRY *thread_p, const DB_VALUE *name, DB_VALUE **value)
Definition: session_sr.c:288
int perfmon_server_copy_stats(UINT64 *to_stats)
int xtran_server_savepoint(THREAD_ENTRY *thread_p, const char *savept_name, LOG_LSA *savept_lsa)
int locator_check_fk_validity(OID *cls_oid, HFID *hfid, TP_DOMAIN *key_type, int n_attrs, int *attr_ids, OID *pk_cls_oid, BTID *pk_btid, char *fk_name)
int histo_start(bool for_all_trans)
#define IS_TRAN_AUTO_COMMIT(flag)
Definition: query_list.h:583
bool locator_manyobj_flag_is_set(LC_COPYAREA_MANYOBJS *copyarea, enum MULTI_UPDATE_FLAG muf)
Definition: locator.c:2597
int tran_server_get_global_tran_info(int gtrid, void *buffer, int size)
#define ARG_FILE_LINE
Definition: error_manager.h:44
int xstats_update_all_statistics(THREAD_ENTRY *thread_p, bool with_fullscan)
#define ER_NOT_IN_STANDALONE
Definition: error_code.h:942
#define NET_DEFER_END_QUERIES_MAX
int net_client_request_3recv_copyarea(int request, char *argbuf, int argsize, char *replybuf, int replysize, char *databuf, int datasize, char **recvbuffer, int *recvbuffer_size, LC_COPYAREA **reply_copy_area)
Definition: network_cl.c:3392
int xheap_destroy(THREAD_ENTRY *thread_p, const HFID *hfid, const OID *class_oid)
Definition: heap_file.c:5786
int compact_db_stop(void)
int repl_info_type
Definition: replication.h:55
int pr_clone_value(const DB_VALUE *src, DB_VALUE *dest)
void histo_clear(void)
SESSION_ID db_Session_id
Definition: db_macro.c:79
SYSPRM_ERR sysprm_change_server_parameters(const SYSPRM_ASSIGN_VALUE *assignments)
#define OR_UTIME_SIZE
BTREE_SEARCH btree_find_multi_uniques(OID *class_oid, int pruning_type, BTID *btids, DB_VALUE *keys, int count, SCAN_OPERATION_TYPE op_type, OID **oids, int *oids_count)
unsigned char temp_key[TDE_DATA_KEY_LENGTH]
Definition: tde.h:88
int locator_pack_lockhint(LC_LOCKHINT *lockhint, bool pack_classes)
Definition: locator.c:1970
INT16 PGLENGTH
int buffer_size
Definition: xasl.h:614
int xboot_soft_rename(THREAD_ENTRY *thread_p, const char *old_db_name, const char *new_db_name, const char *new_db_path, const char *new_log_path, const char *new_db_server_host, const char *new_volext_path, const char *fileof_vols_and_renamepaths, bool new_db_overwrite, bool extern_rename, bool force_delete)
Definition: boot_sr.c:4381
BTID * xbtree_load_online_index(THREAD_ENTRY *thread_p, BTID *btid, const char *bt_name, TP_DOMAIN *key_type, OID *class_oids, int n_classes, int n_attrs, int *attr_ids, int *attrs_prefix_length, HFID *hfids, int unique_pk, int not_null_flag, OID *fk_refcls_oid, BTID *fk_refcls_pk_btid, const char *fk_name, char *pred_stream, int pred_stream_size, char *expr_stream, int expr_steram_size, int func_col_id, int func_attr_index_start, int ib_thread_count)
Definition: btree_load.c:4438
#define OR_CACHE_TIME_SIZE
Definition: cache_time.h:56
int clogin_user(const char *username)
DB_VALUE sys_datetime
Definition: parse_tree.h:3580
int net_client_request(int request, char *argbuf, int argsize, char *replybuf, int replysize, char *databuf, int datasize, char *replydata, int replydatasize)
Definition: network_cl.c:1053
#define free_and_init(ptr)
Definition: memory_alloc.h:147
#define OR_UNPACK_CACHE_TIME(PTR, T)
Definition: cache_time.h:74
#define DB_ALIGN(offset, align)
Definition: memory_alloc.h:84
#define strlen(s1)
Definition: intl_support.c:43
#define BTID_COPY(btid_ptr1, btid_ptr2)
char * or_pack_lock(char *ptr, LOCK lock)
char * or_unpack_ptr(char *ptr, UINTPTR *ptrval)
int xstats_update_statistics(THREAD_ENTRY *thread_p, OID *classoid, bool with_fullscan)
INTL_CODESET codeset
bool xboot_shutdown_server(REFPTR(THREAD_ENTRY, thread_p), ER_FINAL_CODE is_er_final)
Definition: boot_sr.c:3080
QFILE_LIST_ID * qmgr_prepare_and_execute_query(char *xasl_stream, int xasl_stream_size, QUERY_ID *query_idp, int dbval_cnt, DB_VALUE *dbval_ptr, QUERY_FLAG flag, int query_timeout)
int xlogtb_get_pack_tran_table(THREAD_ENTRY *thread_p, char **buffer_p, int *size_p, int include_query_exec_info)
int net_client_request_with_logwr_context(LOGWR_CONTEXT *ctx_ptr, int request, char *argbuf, int argsize, char *replybuf, int replysize, char *databuf1, int datasize1, char *databuf2, int datasize2, char **replydata_ptr1, int *replydatasize_ptr1, char **replydata_ptr2, int *replydatasize_ptr2)
Definition: network_cl.c:2329
char * or_pack_string_with_length(char *ptr, const char *string, int length)
#define STATS_WITH_FULLSCAN
Definition: statistics.h:34
int csession_find_or_create_session(SESSION_ID *session_id, int *row_count, char *server_session_key, const char *db_user, const char *host, const char *program_name)
void xsysprm_dump_server_parameters(FILE *outfp)
#define ER_OBJ_INVALID_ARGUMENTS
Definition: error_code.h:275
int log_checkpoint(void)
#define ER_HA_LW_FAILED_GET_LOG_PAGE
Definition: error_code.h:1281
char * or_pack_domain(char *ptr, struct tp_domain *domain, int include_classoids, int is_null)
bool xtran_server_has_updated(THREAD_ENTRY *thread_p)
unsigned int SESSION_ID
Definition: dbtype_def.h:480
int db_get_row_count_cache(void)
Definition: db_admin.c:2914
int disk_spacedb(THREAD_ENTRY *thread_p, SPACEDB_ALL *spaceall, SPACEDB_ONEVOL **spacevols)
int log_get_mvcc_snapshot(void)
enum intl_codeset INTL_CODESET
Definition: intl_support.h:190
DKNPAGES xdisk_get_free_numpages(THREAD_ENTRY *thread_p, VOLID volid)
void lock_dump(FILE *outfp)
char * xstats_get_statistics_from_server(THREAD_ENTRY *thread_p, OID *class_id, unsigned int timestamp, int *length)
int query_timeout
Definition: cas.c:160
VOLID boot_add_volume_extension(DBDEF_VOL_EXT_INFO *ext_info)
bool prm_get_bool_value(PARAM_ID prm_id)
int boot_get_server_timezone_checksum(char *timezone_checksum)
#define LC_MANYOBJS_PTR_IN_COPYAREA(copy_areaptr)
Definition: locator.h:39
int catalog_check_rep_dir(OID *class_id, OID *rep_dir_p)
BTREE_SEARCH btree_find_unique(BTID *btid, DB_VALUE *key, OID *class_oid, OID *oid)
int locator_force(LC_COPYAREA *copy_area, int num_ignore_error_list, int *ignore_error_list, int content_size)
int loaddb_load_batch(const cubload::batch &batch, bool use_temp_batch, bool &is_batch_accepted, load_status &status)
int jsp_server_port(void)
Definition: jsp_sr.c:751
char * or_unpack_value(const char *buf, DB_VALUE *value)
LC_FIND_CLASSNAME locator_delete_class_name(const char *class_name)
DKNPAGES disk_get_free_numpages(VOLID volid)
int xlocator_fetch_lockset(THREAD_ENTRY *thread_p, LC_LOCKSET *lockset, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:3047
SYSPRM_ERR
LC_FIND_CLASSNAME locator_rename_class_name(const char *old_name, const char *new_name, OID *class_oid)
char * or_pack_ptr(char *ptr, UINTPTR ptrval)
enum logwr_mode LOGWR_MODE
Definition: log_writer.h:54
int serial_decache(OID *oid)
XASL_ID * xasl_id
Definition: xasl.h:610
int locator_fetch_all(const HFID *hfid, LOCK *lock, LC_FETCH_VERSION_TYPE fetch_version_type, OID *class_oidp, int *nobjects, int *nfetched, OID *last_oidp, LC_COPYAREA **fetch_copyarea)
int logtb_get_pack_tran_table(char **buffer_p, int *size_p, bool include_query_exec_info)
char * buffer
Definition: xasl.h:613
#define DB_VALUE_TYPE(value)
Definition: dbtype.h:72
int locator_fetch_all_reference_lockset(OID *oid, int chn, OID *class_oid, int class_chn, LOCK lock, int quit_on_errors, int prune_level, LC_LOCKSET **lockset, LC_COPYAREA **fetch_copyarea)
int heap_has_instance(HFID *hfid, OID *class_oid, int has_visible_instance)
int i
Definition: dynamic_load.c:954
QFILE_LIST_ID * xqmgr_execute_query(THREAD_ENTRY *thrd, const XASL_ID *xasl_id, QUERY_ID *query_idp, int dbval_cnt, void *data, QUERY_FLAG *flagp, CACHE_TIME *clt_cache_time, CACHE_TIME *srv_cache_time, int query_timeout, xasl_cache_ent **ret_cache_entry_p)
int db_make_null(DB_VALUE *value)
enum lob_locator_state LOB_LOCATOR_STATE
Definition: lob_locator.hpp:62
#define NET_COPY_AREA_SENDRECV_SIZE
TDE_DATA_KEY_SET data_keys
Definition: tde.h:149
#define ER_NET_SERVER_CRASHED
Definition: error_code.h:269
bool xtran_is_blocked(THREAD_ENTRY *thread_p, int tran_index)
int serial_get_current_value(DB_VALUE *value, OID *oid_p, int cached_num)
int packed_size
Definition: locator.h:301
int locator_unpack_lockset(LC_LOCKSET *lockset, bool unpack_classes, bool unpack_objects)
Definition: locator.c:1588
#define SERVER_SESSION_KEY_SIZE
int net_client_recv_copyarea(int request, char *replybuf, int replysize, char *recvbuffer, int recvbuffer_size, LC_COPYAREA **reply_copy_area, int rc)
Definition: network_cl.c:3169
int boot_find_last_temp(void)
char * strdup(const char *str)
Definition: porting.c:901
int xboot_delete(const char *db_name, bool force_delete, BOOT_SERVER_SHUTDOWN_MODE shutdown_common_modules)
Definition: boot_sr.c:4653
int boot_emergency_patch(const char *db_name, bool recreate_log, DKNPAGES log_npages, const char *db_locale, FILE *out_fp)
#define NULL_VOLID
const char * comments
int repl_log_get_append_lsa(LOG_LSA *lsa)
int chksum_insert_repl_log_and_demote_table_lock(REPL_INFO *repl_info, const OID *class_oidp)
int boot_find_number_temp_volumes(void)
TRAN_STATE
Definition: log_comm.h:36
int QUERY_FLAG
Definition: query_list.h:585
void xperfmon_server_copy_global_stats(UINT64 *to_stats)
MOP sm_Root_class_mop
#define BTID_IS_NULL(btid)
BTID * xbtree_load_index(THREAD_ENTRY *thread_p, BTID *btid, const char *bt_name, TP_DOMAIN *key_type, OID *class_oids, int n_classes, int n_attrs, int *attr_ids, int *attrs_prefix_length, HFID *hfids, int unique_pk, int not_null_flag, OID *fk_refcls_oid, BTID *fk_refcls_pk_btid, const char *fk_name, char *pred_stream, int pred_stream_size, char *expr_stream, int expr_steram_size, int func_col_id, int func_attr_index_start)
Definition: btree_load.c:716
int db_value_clear(DB_VALUE *value)
Definition: db_macro.c:1588
int db_make_timestamp(DB_VALUE *value, const DB_C_TIMESTAMP timeval)
int db_make_int(DB_VALUE *value, const int num)
char * sysprm_unpack_session_parameters(char *ptr, SESSION_PARAM **session_parameters_ptr)
unsigned char log_key[TDE_DATA_KEY_LENGTH]
Definition: tde.h:89
int csession_end_session(SESSION_ID session_id)
void xqmgr_dump_query_cache(THREAD_ENTRY *thread_p, FILE *outfp)
int db_make_oid(DB_VALUE *value, const OID *oid)
char * or_unpack_stream(char *ptr, char *stream, size_t len)
VOLID xboot_add_volume_extension(THREAD_ENTRY *thread_p, DBDEF_VOL_EXT_INFO *ext_info)
Definition: boot_sr.c:551
#define STATS_WITH_SAMPLING
Definition: statistics.h:35
enum ha_server_state HA_SERVER_STATE
Definition: boot.h:126
INT32 PAGEID
#define OID_ISNULL(oidp)
Definition: oid.h:81
#define INIT_XASL_NODE_HEADER(X)
Definition: xasl.h:98
void er_stack_push_if_exists(void)
TRAN_STATE tran_server_partial_abort(const char *savept_name, LOG_LSA *savept_lsa)
int log_reset_isolation(TRAN_ISOLATION isolation)
LOG_RESULT_TOPOP
Definition: log_comm.h:73
bool log_does_allow_replication(void)
Definition: log_comm.c:270
DB_VOLPURPOSE purpose
QFILE_LIST_ID * xqmgr_prepare_and_execute_query(THREAD_ENTRY *thrd, char *xasl_stream, int xasl_stream_size, QUERY_ID *query_id, int dbval_cnt, void *data, QUERY_FLAG *flag, int query_timeout)
TRAN_STATE xtran_server_2pc_prepare(THREAD_ENTRY *thread_p)
int net_client_request_with_callback(int request, char *argbuf, int argsize, char *replybuf, int replysize, char *databuf1, int datasize1, char *databuf2, int datasize2, char **replydata_listid, int *replydatasize_listid, char **replydata_page, int *replydatasize_page, char **replydata_plan, int *replydatasize_plan)
Definition: network_cl.c:1611
const char * program_name
Definition: cas.c:147
int loaddb_init(cubload::load_args &args)
int tran_wait_server_active_trans(void)
char * db_full_name
Definition: boot.h:138
net_server_request
Definition: network.h:44
static char * host
void qmgr_dump_query_cache(FILE *outfp)
char * or_unpack_domain(char *ptr, struct tp_domain **domain_ptr, int *is_null)
int xlocator_check_fk_validity(THREAD_ENTRY *thread_p, OID *cls_oid, HFID *hfid, TP_DOMAIN *key_type, int n_attrs, int *attr_ids, OID *pk_cls_oid, BTID *pk_btid, char *fk_name)
Definition: locator_sr.c:11689
int boot_compact_classes(OID **class_oids, int num_classes, int space_to_process, int instance_lock_timeout, int class_lock_timeout, bool delete_old_repr, OID *last_processed_class_oid, OID *last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects, int *big_objects, int *ids_repr)
int csession_get_prepared_statement(const char *name, XASL_ID *xasl_id, char **stmt_info, xasl_node_header *xasl_header_p)
int xlocator_get_reserved_class_name_oid(THREAD_ENTRY *thread_p, const char *classname, OID *class_oid)
Definition: locator_sr.c:689
void unpack(cubpacking::unpacker &deserializator) override
int xtran_server_2pc_start(THREAD_ENTRY *thread_p)
int netcl_spacedb(SPACEDB_ALL *spaceall, SPACEDB_ONEVOL **spacevols, SPACEDB_FILES *spacefiles)
FILEIO_BACKUP_LEVEL
Definition: file_io.h:96
int xheap_reclaim_addresses(THREAD_ENTRY *thread_p, const HFID *hfid)
Definition: heap_file.c:6122
bool first_fetch_lockset_call
Definition: locator.h:306
int net_client_request_3_data_recv_copyarea(int request, char *argbuf, int argsize, char *databuf1, int datasize1, char *databuf2, int datasize2, char *replybuf, int replysize, LC_COPYAREA **reply_copy_area)
Definition: network_cl.c:3004
int net_histo_start(bool for_all_trans)
Definition: network_cl.c:775
FILEIO_ZIP_METHOD
Definition: file_io.h:104
int btree_delete_index(BTID *btid)
int acl_reload()
int xboot_copy(REFPTR(THREAD_ENTRY, thread_p), const char *from_dbname, const char *new_db_name, const char *new_db_path, const char *new_log_path, const char *new_lob_path, const char *new_db_server_host, const char *new_volext_path, const char *fileof_vols_and_copypaths, bool new_db_overwrite)
Definition: boot_sr.c:3975
SM_INDEX_STATUS
Definition: class_object.h:510
#define EXECUTE_QUERY_MAX_ARGUMENT_DATA_SIZE
Definition: network.h:41
int xboot_unregister_client(REFPTR(THREAD_ENTRY, thread_p), int tran_index)
Definition: boot_sr.c:3343
int xlocator_fetch_all_reference_lockset(THREAD_ENTRY *thread_p, OID *oid, int chn, OID *class_oid, int class_chn, LOCK lock, int quit_on_errors, int prune_level, LC_LOCKSET **lockset, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:3813
char coll_name[COLL_NAME_SIZE]
TRAN_QUERY_EXEC_INFO query_exec_info
int locator_unpack_lockhint(LC_LOCKHINT *lockhint, bool unpack_classes)
Definition: locator.c:2083
int xqmgr_drop_all_query_plans(THREAD_ENTRY *thread_p)
static int domain_size(TP_DOMAIN *domain)
int xlocator_upgrade_instances_domain(THREAD_ENTRY *thread_p, OID *class_oid, int att_id)
Definition: locator_sr.c:12070
int boot_delete(const char *db_name, bool force_delete)
int class_id
Definition: load_common.hpp:40
int boot_get_server_locales(LANG_COLL_COMPAT **server_collations, LANG_LOCALE_COMPAT **server_locales, int *server_coll_cnt, int *server_locales_cnt)
const char ** p
Definition: dynamic_load.c:945
char * or_unpack_db_value(char *buffer, DB_VALUE *val)
QFILE_LIST_ID * qmgr_execute_query(const XASL_ID *xasl_id, QUERY_ID *query_idp, int dbval_cnt, const DB_VALUE *dbvals, QUERY_FLAG flag, CACHE_TIME *clt_cache_time, CACHE_TIME *srv_cache_time, int query_timeout)
enum er_final_code ER_FINAL_CODE
int tran_server_is_active_and_has_updated(void)
int cvacuum(void)
int xtran_get_local_transaction_id(THREAD_ENTRY *thread_p, DB_VALUE *trid)
int locator_pack_lockset(LC_LOCKSET *lockset, bool pack_classes, bool pack_objects)
Definition: locator.c:1429
#define IS_QUERY_EXECUTE_WITH_COMMIT(flag)
Definition: query_list.h:582
int jsp_get_server_port(void)
int boot_initialize_server(const BOOT_CLIENT_CREDENTIAL *client_credential, BOOT_DB_PATH_INFO *db_path_info, bool db_overwrite, const char *file_addmore_vols, DKNPAGES db_npages, PGLENGTH db_desired_pagesize, DKNPAGES log_npages, PGLENGTH db_desired_log_page_size, OID *rootclass_oid, HFID *rootclass_hfid, int client_lock_wait, TRAN_ISOLATION client_isolation)
int xlocator_get_class(THREAD_ENTRY *thread_p, OID *class_oid, int class_chn, const OID *oid, LOCK lock, int prefetching, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:2704
VOLID xboot_find_last_temp(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:407
int qfile_get_list_file_page(QUERY_ID query_id, VOLID volid, PAGEID pageid, char *buffer, int *buffer_size)
int loaddb_fetch_status(load_status &status)
int locator_log_force_nologging(void)
int xtran_server_2pc_recovery_prepared(THREAD_ENTRY *thread_p, int gtrids[], int size)
#define ER_NET_CLIENT_DATA_RECEIVE
Definition: error_code.h:255
int log_reset_wait_msecs(int wait_msecs)
int db_local_transaction_id(DB_VALUE *result_trid)
#define OR_PACK_XASL_ID(PTR, X)
Definition: xasl.h:581
int locator_send_copy_area(LC_COPYAREA *copyarea, char **contents_ptr, int *contents_length, char **desc_ptr, int *desc_length)
Definition: locator.c:664
bool tran_is_blocked(int tran_index)