CUBRID Engine  latest
network_interface_sr.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_sr.c - Server side network interface functions
21  * for client requests.
22  */
23 
24 #ident "$Id$"
25 
26 #include "config.h"
27 
28 #include <stdio.h>
29 #include <string.h>
30 #include <assert.h>
31 
32 #include "porting.h"
33 #include "porting_inline.hpp"
34 #include "perf_monitor.h"
35 #include "memory_alloc.h"
36 #include "storage_common.h"
37 #include "xserver_interface.h"
38 #include "statistics_sr.h"
39 #include "btree_load.h"
40 #include "perf_monitor.h"
41 #include "log_impl.h"
42 #include "log_lsa.hpp"
43 #include "boot_sr.h"
44 #include "locator_sr.h"
45 #include "server_interface.h"
46 #include "oid.h"
47 #include "error_manager.h"
48 #include "object_representation.h"
49 #include "network.h"
50 #include "log_comm.h"
51 #include "network_interface_sr.h"
52 #include "page_buffer.h"
53 #include "file_manager.h"
54 #include "boot_sr.h"
55 #include "arithmetic.h"
56 #include "serial.h"
57 #include "query_manager.h"
58 #include "transaction_sr.h"
59 #include "release_string.h"
60 #include "critical_section.h"
61 #include "statistics.h"
62 #include "chartype.h"
63 #include "heap_file.h"
64 #include "jsp_sr.h"
65 #include "replication.h"
66 #include "server_support.h"
67 #include "connection_sr.h"
68 #include "log_writer.h"
69 #include "databases_file.h"
70 #include "es.h"
71 #include "es_posix.h"
72 #include "event_log.h"
73 #include "tsc_timer.h"
74 #include "vacuum.h"
75 #include "object_primitive.h"
76 #include "tz_support.h"
77 #include "dbtype.h"
78 #include "thread_manager.hpp" // for thread_get_thread_entry_info
79 #include "compile_context.h"
80 #include "load_session.hpp"
81 #include "session.h"
82 #include "xasl.h"
83 #include "xasl_cache.h"
84 #include "elo.h"
86 
87 #if defined (SUPPRESS_STRLEN_WARNING)
88 #define strlen(s1) ((int) strlen(s1))
89 #endif /* defined (SUPPRESS_STRLEN_WARNING) */
90 
91 #define NET_COPY_AREA_SENDRECV_SIZE (OR_INT_SIZE * 3)
92 #define NET_SENDRECV_BUFFSIZE (OR_INT_SIZE)
93 
94 #define STATDUMP_BUF_SIZE (2 * 16 * 1024)
95 #define QUERY_INFO_BUF_SIZE (2048 + STATDUMP_BUF_SIZE)
96 
97 #define NET_DEFER_END_QUERIES_MAX 10
98 
99 /* Query execution with commit. */
100 #define QEWC_SAFE_GUARD_SIZE 1024
101 // To have the safe area is just a safe guard to avoid potential issues of bad size calculation.
102 #define QEWC_MAX_DATA_SIZE (DB_PAGESIZE - QEWC_SAFE_GUARD_SIZE)
103 
104 /* This file is only included in the server. So set the on_server flag on */
105 unsigned int db_on_server = 1;
106 
107 STATIC_INLINE TRAN_STATE stran_server_commit_internal (THREAD_ENTRY * thread_p, unsigned int rid, bool retain_lock,
108  bool * should_conn_reset) __attribute__ ((ALWAYS_INLINE));
109 STATIC_INLINE TRAN_STATE stran_server_abort_internal (THREAD_ENTRY * thread_p, unsigned int rid, bool retain_lock,
110  bool * should_conn_reset) __attribute__ ((ALWAYS_INLINE));
111 STATIC_INLINE void stran_server_auto_commit_or_abort (THREAD_ENTRY * thread_p, unsigned int rid,
112  QUERY_ID * p_end_queries, int n_query_ids, bool need_abort,
113  bool has_updated, bool * end_query_allowed,
114  TRAN_STATE * tran_state, bool * should_conn_reset)
116 STATIC_INLINE int stran_can_end_after_query_execution (THREAD_ENTRY * thread_p, int query_flag, QFILE_LIST_ID * list_id,
117  bool * can_end_transaction) __attribute__ ((ALWAYS_INLINE));
118 
119 static bool need_to_abort_tran (THREAD_ENTRY * thread_p, int *errid);
120 static int server_capabilities (void);
121 static int check_client_capabilities (THREAD_ENTRY * thread_p, int client_cap, int rel_compare,
122  REL_COMPATIBILITY * compatibility, const char *client_host);
123 static void sbtree_find_unique_internal (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen);
124 static int er_log_slow_query (THREAD_ENTRY * thread_p, EXECUTION_INFO * info, int time,
125  UINT64 * diff_stats, char *queryinfo_string);
126 static void event_log_slow_query (THREAD_ENTRY * thread_p, EXECUTION_INFO * info, int time, UINT64 * diff_stats);
127 static void event_log_many_ioreads (THREAD_ENTRY * thread_p, EXECUTION_INFO * info, int time, UINT64 * diff_stats);
128 static void event_log_temp_expand_pages (THREAD_ENTRY * thread_p, EXECUTION_INFO * info);
129 
130 /*
131  * stran_server_commit_internal - commit transaction on server.
132  *
133  * return:
134  *
135  * thread_p(in): thred entry.
136  * rid(in): request id.
137  * retain_lock(in): true, if retains lock.
138  * should_conn_reset(out): reset on commit.
139  *
140  * NOTE: This function must be called at transaction commit.
141  */
143 stran_server_commit_internal (THREAD_ENTRY * thread_p, unsigned int rid, bool retain_lock, bool * should_conn_reset)
144 {
145  bool has_updated;
146  TRAN_STATE state;
147 
148  assert (should_conn_reset != NULL);
149  has_updated = logtb_has_updated (thread_p);
150 
151  state = xtran_server_commit (thread_p, retain_lock);
152 
154 
156  {
157  /* Likely the commit failed.. somehow */
158  (void) return_error_to_client (thread_p, rid);
159  }
160 
161  *should_conn_reset = xtran_should_connection_reset (thread_p, has_updated);
162 
163  return state;
164 }
165 
166 /*
167  * stran_server_abort_internal - abort transaction on server.
168  *
169  * return:
170  *
171  * thread_p(in): thred entry.
172  * rid(in): request id.
173  * should_conn_reset(out): reset on commit.
174  *
175  * NOTE: This function must be called at transaction abort.
176  */
178 stran_server_abort_internal (THREAD_ENTRY * thread_p, unsigned int rid, bool * should_conn_reset)
179 {
180  TRAN_STATE state;
181  bool has_updated;
182 
183  has_updated = logtb_has_updated (thread_p);
184 
185  state = xtran_server_abort (thread_p);
186 
188 
190  {
191  /* Likely the abort failed.. somehow */
192  (void) return_error_to_client (thread_p, rid);
193  }
194 
195  *should_conn_reset = xtran_should_connection_reset (thread_p, has_updated);
196 
197  return state;
198 }
199 
200 /*
201  * stran_server_auto_commit_or_abort - do server-side auto-commit or abort
202  *
203  * return: nothing
204  *
205  * thread_p(in): thread entry
206  * rid(in): request id
207  * p_end_queries(in): queries to end
208  * n_query_ids(in): the number of queries to end
209  * need_abort(in): true, if need to abort
210  * has_updated(in):true, if has updated before abort
211  * end_query_allowed(in/out): true, if end query is allowed
212  * tran_state(in/out): transaction state
213  * should_conn_reset(in/out): reset on commit
214  *
215  * Note: This function must be called only when the query is executed with commit, soon after query execution.
216  * When we call this function, it is possible that transaction was aborted.
217  */
218 STATIC_INLINE void
219 stran_server_auto_commit_or_abort (THREAD_ENTRY * thread_p, unsigned int rid, QUERY_ID * p_end_queries,
220  int n_query_ids, bool need_abort, bool has_updated, bool * end_query_allowed,
221  TRAN_STATE * tran_state, bool * should_conn_reset)
222 {
223  int error_code, all_error_code, i;
224 
225  assert (tran_state != NULL && should_conn_reset != NULL && end_query_allowed != NULL);
226 
227  *should_conn_reset = false;
228 
229  if (*end_query_allowed == false)
230  {
232  {
233  _er_log_debug (ARG_FILE_LINE, "stran_server_auto_commit_or_abort: active transaction.\n");
234  }
235  return;
236  }
237 
238  /* We commit/abort transaction, after ending queries. */
239  all_error_code = NO_ERROR;
240  if ((*tran_state != TRAN_UNACTIVE_ABORTED) && (*tran_state != TRAN_UNACTIVE_ABORTED_INFORMING_PARTICIPANTS))
241  {
242  /* If not already aborted, ends the queries. */
243  for (i = 0; i < n_query_ids; i++)
244  {
245  if (p_end_queries[i] > 0)
246  {
247  error_code = xqmgr_end_query (thread_p, p_end_queries[i]);
248  if (error_code != NO_ERROR)
249  {
250  all_error_code = error_code;
251  /* Continue to try to close as many queries as possible. */
252  }
253  }
254  }
255  }
256 
257  if (all_error_code != NO_ERROR)
258  {
259  (void) return_error_to_client (thread_p, rid);
260  *end_query_allowed = false;
261  }
262  else if (need_abort == false)
263  {
264  /* Needs commit. */
265  *tran_state = stran_server_commit_internal (thread_p, rid, false, should_conn_reset);
267  {
268  _er_log_debug (ARG_FILE_LINE, "stran_server_auto_commit_or_abort: transaction committed. \n");
269  }
270  }
271  else
272  {
273  /* Needs abort. */
274  if ((*tran_state != TRAN_UNACTIVE_ABORTED) && (*tran_state != TRAN_UNACTIVE_ABORTED_INFORMING_PARTICIPANTS))
275  {
276  /* We have an error and the transaction was not aborted. Since is auto commit transaction, we can abort it.
277  * In this way, we can avoid abort request.
278  */
279  *tran_state = stran_server_abort_internal (thread_p, rid, should_conn_reset);
281  {
282  _er_log_debug (ARG_FILE_LINE, "stran_server_auto_commit_or_abort: transaction aborted. \n");
283  }
284  }
285  else
286  {
287  /* Transaction was already aborted. */
288  *should_conn_reset = xtran_should_connection_reset (thread_p, has_updated);
289  }
290  }
291 }
292 
293 /*
294  * need_to_abort_tran - check whether the transaction should be aborted
295  *
296  * return: true/false
297  *
298  * thread_p(in): thread entry
299  * errid(out): the latest error code
300  */
301 static bool
302 need_to_abort_tran (THREAD_ENTRY * thread_p, int *errid)
303 {
304  LOG_TDES *tdes;
305  bool flag_abort = false;
306 
307  assert (thread_p != NULL);
308 
309 #if 0 /* TODO */
310  assert (er_errid () != NO_ERROR);
311 #endif
312 
313  *errid = er_errid ();
314  if (*errid == ER_LK_UNILATERALLY_ABORTED || *errid == ER_DB_NO_MODIFICATIONS)
315  {
316  flag_abort = true;
317  }
318 
319  /*
320  * DEFENCE CODE:
321  * below block means ER_LK_UNILATERALLY_ABORTED occurs but another error
322  * set after that.
323  * So, re-set that error to rollback in client side.
324  */
325  tdes = LOG_FIND_CURRENT_TDES (thread_p);
326  if (tdes != NULL && tdes->tran_abort_reason != TRAN_NORMAL && flag_abort == false)
327  {
328  flag_abort = true;
329 
331  tdes->client.get_db_user (), tdes->client.get_host_name (), tdes->client.process_id);
332  }
333 
334  return flag_abort;
335 }
336 
337 /*
338  * return_error_to_client -
339  *
340  * return: state of operation
341  *
342  * rid(in):
343  *
344  * NOTE:
345  */
347 return_error_to_client (THREAD_ENTRY * thread_p, unsigned int rid)
348 {
349  LOG_TDES *tdes;
350  int errid;
351  bool flag_abort = false;
352  char *area;
353  OR_ALIGNED_BUF (1024) a_buffer;
354  char *buffer;
355  int length = 1024;
356  TRAN_STATE tran_state = TRAN_UNACTIVE_UNKNOWN;
357 
358  CSS_CONN_ENTRY *conn;
359 
360  assert (thread_p != NULL);
361 
362  conn = thread_p->conn_entry;
363  assert (conn != NULL);
364 
365  tdes = LOG_FIND_CURRENT_TDES (thread_p);
366  if (tdes != NULL)
367  {
368  tran_state = tdes->state;
369  }
370  flag_abort = need_to_abort_tran (thread_p, &errid);
371 
372  /* check some errors which require special actions */
373  /*
374  * ER_LK_UNILATERALLY_ABORTED may have occurred due to deadlock.
375  * If it happened, do server-side rollback of the transaction.
376  * If ER_DB_NO_MODIFICATIONS error is occurred in server-side,
377  * it means that the user tried to update the database
378  * when the server was disabled to modify. (aka standby mode)
379  */
380  if (flag_abort == true)
381  {
382  /* need to hide the previous error, ER_LK_UNILATERALLY_ABORTED to rollback the current transaction. */
383  er_stack_push ();
384  tran_state = tran_server_unilaterally_abort_tran (thread_p);
385  er_stack_pop ();
386  }
387 
388  if (errid == ER_DB_NO_MODIFICATIONS)
389  {
390  conn->reset_on_commit = true;
391  }
392 
393  buffer = OR_ALIGNED_BUF_START (a_buffer);
394  area = er_get_area_error (buffer, &length);
395  if (area != NULL)
396  {
397  conn->db_error = errid;
398  css_send_error_to_client (conn, rid, area, length);
399  conn->db_error = 0;
400  }
401 
402  if (tdes != NULL)
403  {
405  }
406 
407  return tran_state;
408 }
409 
410 /*
411  * server_capabilities -
412  *
413  * return:
414  */
415 static int
417 {
418  int capabilities = 0;
419 
420  capabilities |= NET_CAP_INTERRUPT_ENABLED;
421  if (db_Disable_modifications > 0)
422  {
423  capabilities |= NET_CAP_UPDATE_DISABLED;
424  }
426  {
427  capabilities |= NET_CAP_REMOTE_DISABLED;
428  }
429  if (css_is_ha_repl_delayed () == true)
430  {
431  capabilities |= NET_CAP_HA_REPL_DELAY;
432  }
433  if (HA_GET_MODE () == HA_MODE_REPLICA)
434  {
436  capabilities |= NET_CAP_HA_REPLICA;
437  }
438 
439  return capabilities;
440 }
441 
442 /*
443  * check_client_capabilities -
444  *
445  * return:
446  * client_cap(in): client capability
447  *
448  */
449 static int
450 check_client_capabilities (THREAD_ENTRY * thread_p, int client_cap, int rel_compare, REL_COMPATIBILITY * compatibility,
451  const char *client_host)
452 {
453  int server_cap;
454 
455  assert (compatibility != NULL);
456 
457  server_cap = server_capabilities ();
458  /* interrupt-ability should be same */
459  if ((server_cap ^ client_cap) & NET_CAP_INTERRUPT_ENABLED)
460  {
461  client_cap ^= NET_CAP_INTERRUPT_ENABLED;
462  }
463  /* network protocol compatibility */
464  if (*compatibility == REL_NOT_COMPATIBLE)
465  {
466  if (rel_compare < 0 && (client_cap & NET_CAP_FORWARD_COMPATIBLE))
467  {
468  /*
469  * The client is older than the server but the client has a forward
470  * compatible capability.
471  */
472  *compatibility = REL_FORWARD_COMPATIBLE;
473  }
474  if (rel_compare > 0 && (client_cap & NET_CAP_BACKWARD_COMPATIBLE))
475  {
476  /*
477  * The client is newer than the server but the client has a backward
478  * compatible capability.
479  */
480  *compatibility = REL_BACKWARD_COMPATIBLE;
481  }
482  }
483  /* remote connection capability */
484  if (server_cap & NET_CAP_REMOTE_DISABLED)
485  {
486  /* do capability check on client side */
487  er_log_debug (ARG_FILE_LINE, "NET_CAP_REMOTE_DISABLED server %s %d client %s %d\n", boot_Host_name,
488  server_cap & NET_CAP_REMOTE_DISABLED, client_host, client_cap & NET_CAP_REMOTE_DISABLED);
489  }
490 
491  if (client_cap & NET_CAP_HA_IGNORE_REPL_DELAY)
492  {
493  thread_p->conn_entry->ignore_repl_delay = true;
494 
495  er_log_debug (ARG_FILE_LINE, "NET_CAP_HA_IGNORE_REPL_DELAY client %s %d\n", client_host,
496  client_cap & NET_CAP_HA_IGNORE_REPL_DELAY);
497  }
498 
499  return client_cap;
500 }
501 
502 /*
503  * server_ping - return that the server is alive
504  * return:
505  * rid(in): request id
506  */
507 void
508 server_ping (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
509 {
510  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
511  char *reply = OR_ALIGNED_BUF_START (a_reply);
512  int client_val, server_val;
513 
514  er_log_debug (ARG_FILE_LINE, "The server_ping() is called.");
515 
516  /* you can get something useful from the request */
517  or_unpack_int (request, &client_val);
518 
519  /* you can envelope something useful into the reply */
520  server_val = 0;
521  or_pack_int (reply, server_val);
522  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_INT_SIZE);
523 }
524 
525 /*
526  * server_ping_with_handshake -
527  *
528  * return:
529  *
530  * rid(in): request id
531  * request(in):
532  * reqlen(in):
533  *
534  * NOTE: Handler for the SERVER_PING_WITH_HANDSHAKE request.
535  * We record the client's version string here and send back our own
536  * version string so the client can determine compatibility.
537  */
538 int
539 server_ping_with_handshake (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
540 {
542  char *reply = OR_ALIGNED_BUF_START (a_reply);
543  int reply_size = OR_ALIGNED_BUF_SIZE (a_reply);
544  char *ptr, *client_release, *client_host;
545  const char *server_release;
546  int client_capabilities, client_bit_platform, status = CSS_NO_ERRORS;
547  int client_type;
548  int strlen1, strlen2;
549  REL_COMPATIBILITY compat;
550 
551  server_release = rel_release_string ();
552 
553  if (reqlen > 0)
554  {
555  ptr = or_unpack_string_nocopy (request, &client_release);
556  ptr = or_unpack_int (ptr, &client_capabilities);
557  ptr = or_unpack_int (ptr, &client_bit_platform);
558  ptr = or_unpack_int (ptr, &client_type);
559  ptr = or_unpack_string_nocopy (ptr, &client_host);
560  if (client_release != NULL)
561  {
562  client_release = css_add_client_version_string (thread_p, client_release);
563  }
564  }
565  else
566  {
567  client_release = NULL;
568  client_bit_platform = 0;
569  client_capabilities = 0;
570  client_host = NULL;
571  }
572 
573  /* check bits model */
574  if (client_bit_platform != rel_bit_platform ())
575  {
577  client_bit_platform);
578  (void) return_error_to_client (thread_p, rid);
579  status = CSS_UNPLANNED_SHUTDOWN;
580  }
581 
582  /* If we can't get the client version, we have to disconnect it. */
583  if (client_release == NULL)
584  {
586  (void) return_error_to_client (thread_p, rid);
587  status = CSS_UNPLANNED_SHUTDOWN;
588  }
589 
590  /*
591  * 1. get the result of compatibility check.
592  * 2. check if the both capabilities of client and server are compatible.
593  * 3. check if the client has a capability to make it compatible.
594  */
595  compat = rel_get_net_compatible (client_release, server_release);
596  if (check_client_capabilities (thread_p, client_capabilities, rel_compare (client_release, server_release),
597  &compat, client_host) != client_capabilities)
598  {
600  (void) return_error_to_client (thread_p, rid);
601  }
602  if (compat == REL_NOT_COMPATIBLE)
603  {
604  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_NET_DIFFERENT_RELEASE, 2, server_release, client_release);
605  (void) return_error_to_client (thread_p, rid);
606  status = CSS_UNPLANNED_SHUTDOWN;
607  }
608 
609  /* update connection counters for reserved connections */
610  if (css_increment_num_conn ((BOOT_CLIENT_TYPE) client_type) != NO_ERROR)
611  {
613  (void) return_error_to_client (thread_p, rid);
614  status = CSS_UNPLANNED_SHUTDOWN;
615  }
616  else
617  {
618  thread_p->conn_entry->client_type = (BOOT_CLIENT_TYPE) client_type;
619  }
620 
621  reply_size = (or_packed_string_length (server_release, &strlen1) + (OR_INT_SIZE * 3)
623  ptr = or_pack_string_with_length (reply, (char *) server_release, strlen1);
624  ptr = or_pack_string (ptr, NULL); /* for backward compatibility */
625  ptr = or_pack_int (ptr, server_capabilities ());
626  ptr = or_pack_int (ptr, rel_bit_platform ());
627  ptr = or_pack_string_with_length (ptr, boot_Host_name, strlen2);
628  css_send_data_to_client (thread_p->conn_entry, rid, reply, reply_size);
629 
630  return status;
631 }
632 
633 /*
634  * slocator_fetch -
635  *
636  * return:
637  *
638  * thrd(in):
639  * rid(in):
640  * request(in):
641  * reqlen(in):
642  *
643  * NOTE:
644  */
645 void
646 slocator_fetch (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
647 {
648  OID oid;
649  int chn;
650  LOCK lock;
651  OID class_oid;
652  int class_chn;
653  int prefetch;
654  LC_COPYAREA *copy_area;
655  char *ptr;
656  int success;
658  char *reply = OR_ALIGNED_BUF_START (a_reply);
659  char *desc_ptr = NULL;
660  int desc_size;
661  char *content_ptr;
662  int content_size;
663  int num_objs = 0;
664  int fetch_version_type;
665 
666  ptr = or_unpack_oid (request, &oid);
667  ptr = or_unpack_int (ptr, &chn);
668  ptr = or_unpack_lock (ptr, &lock);
669  ptr = or_unpack_int (ptr, &fetch_version_type);
670  ptr = or_unpack_oid (ptr, &class_oid);
671  ptr = or_unpack_int (ptr, &class_chn);
672  ptr = or_unpack_int (ptr, &prefetch);
673 
674  copy_area = NULL;
675  success =
676  xlocator_fetch (thread_p, &oid, chn, lock, (LC_FETCH_VERSION_TYPE) fetch_version_type,
677  (LC_FETCH_VERSION_TYPE) fetch_version_type, &class_oid, class_chn, prefetch, &copy_area);
678 
679  if (success != NO_ERROR)
680  {
681  (void) return_error_to_client (thread_p, rid);
682  }
683 
684  if (copy_area != NULL)
685  {
686  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
687  }
688  else
689  {
690  desc_ptr = NULL;
691  desc_size = 0;
692  content_ptr = NULL;
693  content_size = 0;
694  }
695 
696  /* Send sizes of databuffer and copy area (descriptor + content) */
697 
698  ptr = or_pack_int (reply, num_objs);
699  ptr = or_pack_int (ptr, desc_size);
700  ptr = or_pack_int (ptr, content_size);
701  ptr = or_pack_int (ptr, success);
702 
703  if (copy_area == NULL)
704  {
705  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
706  }
707  else
708  {
709  css_send_reply_and_2_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), desc_ptr,
710  desc_size, content_ptr, content_size);
711  locator_free_copy_area (copy_area);
712  }
713  if (desc_ptr)
714  {
715  free_and_init (desc_ptr);
716  }
717 }
718 
719 /*
720  * slocator_get_class -
721  *
722  * return:
723  *
724  * rid(in):
725  * request(in):
726  * reqlen(in):
727  *
728  * NOTE:
729  */
730 void
731 slocator_get_class (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
732 {
733  OID class_oid, oid;
734  int class_chn;
735  LOCK lock;
736  int prefetching;
737  LC_COPYAREA *copy_area;
738  int success;
739  char *ptr;
741  char *reply = OR_ALIGNED_BUF_START (a_reply);
742  char *desc_ptr = NULL;
743  int desc_size;
744  char *content_ptr;
745  int content_size;
746  int num_objs = 0;
747 
748  ptr = or_unpack_oid (request, &class_oid);
749  ptr = or_unpack_int (ptr, &class_chn);
750  ptr = or_unpack_oid (ptr, &oid);
751  ptr = or_unpack_lock (ptr, &lock);
752  ptr = or_unpack_int (ptr, &prefetching);
753 
754  copy_area = NULL;
755  success = xlocator_get_class (thread_p, &class_oid, class_chn, &oid, lock, prefetching, &copy_area);
756  if (success != NO_ERROR)
757  {
758  (void) return_error_to_client (thread_p, rid);
759  }
760 
761  if (copy_area != NULL)
762  {
763  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
764  }
765  else
766  {
767  desc_ptr = NULL;
768  desc_size = 0;
769  content_ptr = NULL;
770  content_size = 0;
771  }
772 
773  /* Send sizes of databuffer and copy area (descriptor + content) */
774 
775  ptr = or_pack_int (reply, num_objs);
776  ptr = or_pack_int (ptr, desc_size);
777  ptr = or_pack_int (ptr, content_size);
778  ptr = or_pack_oid (ptr, &class_oid);
779  ptr = or_pack_int (ptr, success);
780 
781  if (copy_area == NULL)
782  {
783  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
784  }
785  else
786  {
787  css_send_reply_and_2_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), desc_ptr,
788  desc_size, content_ptr, content_size);
789  locator_free_copy_area (copy_area);
790  }
791 
792  if (desc_ptr)
793  {
794  free_and_init (desc_ptr);
795  }
796 }
797 
798 /*
799  * slocator_fetch_all -
800  *
801  * return:
802  *
803  * rid(in):
804  * request(in):
805  * reqlen(in):
806  *
807  * NOTE:
808  */
809 void
810 slocator_fetch_all (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
811 {
812  HFID hfid;
813  LOCK lock;
814  OID class_oid, last_oid;
815  int nobjects, nfetched;
816  LC_COPYAREA *copy_area;
817  int success;
818  char *ptr;
819  int fetch_version_type;
821  char *reply = OR_ALIGNED_BUF_START (a_reply);
822  char *desc_ptr = NULL;
823  int desc_size;
824  char *content_ptr;
825  int content_size;
826  int num_objs = 0;
827 
828  ptr = or_unpack_hfid (request, &hfid);
829  ptr = or_unpack_lock (ptr, &lock);
830  ptr = or_unpack_int (ptr, &fetch_version_type);
831  ptr = or_unpack_oid (ptr, &class_oid);
832  ptr = or_unpack_int (ptr, &nobjects);
833  ptr = or_unpack_int (ptr, &nfetched);
834  ptr = or_unpack_oid (ptr, &last_oid);
835 
836  copy_area = NULL;
837  success =
838  xlocator_fetch_all (thread_p, &hfid, &lock, (LC_FETCH_VERSION_TYPE) fetch_version_type, &class_oid, &nobjects,
839  &nfetched, &last_oid, &copy_area);
840 
841  if (success != NO_ERROR)
842  {
843  (void) return_error_to_client (thread_p, rid);
844  }
845 
846  if (copy_area != NULL)
847  {
848  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
849  }
850  else
851  {
852  desc_ptr = NULL;
853  desc_size = 0;
854  content_ptr = NULL;
855  content_size = 0;
856  }
857 
858  /* Send sizes of databuffer and copy area (descriptor + content) */
859 
860  ptr = or_pack_int (reply, num_objs);
861  ptr = or_pack_int (ptr, desc_size);
862  ptr = or_pack_int (ptr, content_size);
863  ptr = or_pack_lock (ptr, lock);
864  ptr = or_pack_int (ptr, nobjects);
865  ptr = or_pack_int (ptr, nfetched);
866  ptr = or_pack_oid (ptr, &last_oid);
867  ptr = or_pack_int (ptr, success);
868 
869  if (copy_area == NULL)
870  {
871  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
872  }
873  else
874  {
875  css_send_reply_and_2_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), desc_ptr,
876  desc_size, content_ptr, content_size);
877  locator_free_copy_area (copy_area);
878  }
879 
880  if (desc_ptr)
881  {
882  free_and_init (desc_ptr);
883  }
884 }
885 
886 /*
887  * slocator_does_exist -
888  *
889  * return:
890  *
891  * rid(in):
892  * request(in):
893  * reqlen(in):
894  *
895  * NOTE:
896  */
897 void
898 slocator_does_exist (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
899 {
900  OID oid, class_oid;
901  int chn, class_chn, prefetch, doesexist;
902  int need_fetching;
903  LOCK lock;
904  int fetch_version_type;
905  LC_COPYAREA *copy_area;
906  char *ptr;
908  char *reply = OR_ALIGNED_BUF_START (a_reply);
909  char *desc_ptr = NULL;
910  int desc_size;
911  char *content_ptr;
912  int content_size;
913  int num_objs = 0;
914 
915  ptr = or_unpack_oid (request, &oid);
916  ptr = or_unpack_int (ptr, &chn);
917  ptr = or_unpack_lock (ptr, &lock);
918  ptr = or_unpack_int (ptr, &fetch_version_type);
919  ptr = or_unpack_oid (ptr, &class_oid);
920  ptr = or_unpack_int (ptr, &class_chn);
921  ptr = or_unpack_int (ptr, &need_fetching);
922  ptr = or_unpack_int (ptr, &prefetch);
923 
924  copy_area = NULL;
925  doesexist =
926  xlocator_does_exist (thread_p, &oid, chn, lock, (LC_FETCH_VERSION_TYPE) fetch_version_type, &class_oid, class_chn,
927  need_fetching, prefetch, &copy_area);
928 
929  if (doesexist == LC_ERROR)
930  {
931  (void) return_error_to_client (thread_p, rid);
932  }
933 
934  if (copy_area != NULL)
935  {
936  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
937  }
938  else
939  {
940  desc_ptr = NULL;
941  desc_size = 0;
942  content_ptr = NULL;
943  content_size = 0;
944  }
945 
946  /* Send sizes of databuffer and copy area (descriptor + content) */
947 
948  ptr = or_pack_int (reply, num_objs);
949  ptr = or_pack_int (ptr, desc_size);
950  ptr = or_pack_int (ptr, content_size);
951  ptr = or_pack_int (ptr, doesexist);
952  ptr = or_pack_oid (ptr, &class_oid);
953 
954  if (copy_area == NULL)
955  {
956  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
957  }
958  else
959  {
960  css_send_reply_and_2_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), desc_ptr,
961  desc_size, content_ptr, content_size);
962  locator_free_copy_area (copy_area);
963  }
964  if (desc_ptr)
965  {
966  free_and_init (desc_ptr);
967  }
968 }
969 
970 /*
971  * slocator_notify_isolation_incons -
972  *
973  * return:
974  *
975  * rid(in):
976  * request(in):
977  * reqlen(in):
978  *
979  * NOTE:
980  */
981 void
982 slocator_notify_isolation_incons (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
983 {
984  LC_COPYAREA *copy_area;
985  char *ptr;
986  int success;
988  char *reply = OR_ALIGNED_BUF_START (a_reply);
989  char *desc_ptr = NULL;
990  int desc_size;
991  char *content_ptr;
992  int content_size;
993  int num_objs = 0;
994 
995  copy_area = NULL;
996  success = xlocator_notify_isolation_incons (thread_p, &copy_area);
997  if (success != NO_ERROR)
998  {
999  (void) return_error_to_client (thread_p, rid);
1000  }
1001 
1002  if (copy_area != NULL)
1003  {
1004  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
1005  }
1006  else
1007  {
1008  desc_ptr = NULL;
1009  desc_size = 0;
1010  content_ptr = NULL;
1011  content_size = 0;
1012  }
1013 
1014  /* Send sizes of databuffer and copy area (descriptor + content) */
1015 
1016  ptr = or_pack_int (reply, num_objs);
1017  ptr = or_pack_int (ptr, desc_size);
1018  ptr = or_pack_int (ptr, content_size);
1019 
1020  ptr = or_pack_int (ptr, success);
1021 
1022  if (copy_area == NULL)
1023  {
1024  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1025  }
1026  else
1027  {
1028  css_send_reply_and_2_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), desc_ptr,
1029  desc_size, content_ptr, content_size);
1030  locator_free_copy_area (copy_area);
1031  }
1032  if (desc_ptr)
1033  {
1034  free_and_init (desc_ptr);
1035  }
1036 }
1037 
1038 /*
1039  * slocator_repl_force - process log applier's request to replicate data
1040  *
1041  * return:
1042  *
1043  * rid(in):
1044  * request(in):
1045  * reqlen(in):
1046  *
1047  * NOTE:
1048  */
1049 void
1050 slocator_repl_force (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1051 {
1052  int size;
1053  int success;
1054  LC_COPYAREA *copy_area = NULL, *reply_copy_area = NULL;
1055  char *ptr;
1056  int csserror;
1058  char *reply = OR_ALIGNED_BUF_START (a_reply);
1059  int content_size;
1060  char *content_ptr = NULL, *new_content_ptr = NULL;
1061  char *reply_content_ptr = NULL;
1062  int num_objs;
1063  char *packed_desc = NULL;
1064  int packed_desc_size;
1065  LC_COPYAREA_MANYOBJS *mobjs, *reply_mobjs;
1066  char *desc_ptr = NULL;
1067  int desc_size;
1068 
1069  ptr = or_unpack_int (request, &num_objs);
1070  ptr = or_unpack_int (ptr, &packed_desc_size);
1071  ptr = or_unpack_int (ptr, &content_size);
1072 
1073  csserror = 0;
1074 
1075  copy_area = locator_recv_allocate_copyarea (num_objs, &content_ptr, content_size);
1076  if (copy_area)
1077  {
1078  if (num_objs > 0)
1079  {
1080  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &packed_desc, &size);
1081  }
1082 
1083  if (csserror)
1084  {
1086  css_send_abort_to_client (thread_p->conn_entry, rid);
1087  goto end;
1088  }
1089  else
1090  {
1091  locator_unpack_copy_area_descriptor (num_objs, copy_area, packed_desc);
1092  mobjs = LC_MANYOBJS_PTR_IN_COPYAREA (copy_area);
1093 
1094  if (content_size > 0)
1095  {
1096  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &new_content_ptr, &size);
1097 
1098  if (new_content_ptr != NULL)
1099  {
1100  memcpy (content_ptr, new_content_ptr, size);
1101  free_and_init (new_content_ptr);
1102  }
1103 
1104  if (csserror)
1105  {
1107  css_send_abort_to_client (thread_p->conn_entry, rid);
1108  goto end;
1109  }
1110 
1111  /* make copy_area (estimated size) to report errors */
1112  reply_copy_area =
1113  locator_recv_allocate_copyarea (num_objs, &reply_content_ptr, content_size + OR_INT_SIZE * num_objs);
1114  reply_mobjs = LC_MANYOBJS_PTR_IN_COPYAREA (reply_copy_area);
1115  reply_mobjs->num_objs = 0;
1116  }
1117 
1118  success = xlocator_repl_force (thread_p, copy_area, &reply_copy_area);
1119 
1120  /*
1121  * Send the descriptor and content to handle errors
1122  */
1123 
1124  num_objs = locator_send_copy_area (reply_copy_area, &reply_content_ptr, &content_size, &desc_ptr, &desc_size);
1125 
1126  ptr = or_pack_int (reply, num_objs);
1127  ptr = or_pack_int (ptr, desc_size);
1128  ptr = or_pack_int (ptr, content_size);
1129  ptr = or_pack_int (ptr, success);
1130 
1131  if (success != NO_ERROR && success != ER_LC_PARTIALLY_FAILED_TO_FLUSH)
1132  {
1133  (void) return_error_to_client (thread_p, rid);
1134  }
1135 
1136  css_send_reply_and_2_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply),
1137  desc_ptr, desc_size, reply_content_ptr, content_size);
1138  }
1139  }
1140 
1141 end:
1142  if (packed_desc)
1143  {
1144  free_and_init (packed_desc);
1145  }
1146  if (copy_area != NULL)
1147  {
1148  locator_free_copy_area (copy_area);
1149  }
1150  if (reply_copy_area != NULL)
1151  {
1152  locator_free_copy_area (reply_copy_area);
1153  }
1154  if (desc_ptr)
1155  {
1156  free_and_init (desc_ptr);
1157  }
1158 
1159  return;
1160 }
1161 
1162 /*
1163  * slocator_force -
1164  *
1165  * return:
1166  *
1167  * rid(in):
1168  * request(in):
1169  * reqlen(in):
1170  *
1171  * NOTE:
1172  */
1173 void
1174 slocator_force (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1175 {
1176  int received_size;
1177  int success;
1178  LC_COPYAREA *copy_area = NULL;
1179  char *ptr;
1180  int csserror;
1181  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
1182  char *reply = OR_ALIGNED_BUF_START (a_reply);
1183  int content_size;
1184  char *content_ptr = NULL, *new_content_ptr = NULL;
1185  int num_objs;
1186  char *packed_desc = NULL;
1187  int packed_desc_size;
1188  int multi_update_flags;
1189  LC_COPYAREA_MANYOBJS *mobjs;
1190  int i, num_ignore_error_list;
1191  int ignore_error_list[-ER_LAST_ERROR];
1192 
1193  ptr = or_unpack_int (request, &num_objs);
1194  ptr = or_unpack_int (ptr, &multi_update_flags);
1195  ptr = or_unpack_int (ptr, &packed_desc_size);
1196  ptr = or_unpack_int (ptr, &content_size);
1197 
1198  ptr = or_unpack_int (ptr, &num_ignore_error_list);
1199  for (i = 0; i < num_ignore_error_list; i++)
1200  {
1201  ptr = or_unpack_int (ptr, &ignore_error_list[i]);
1202  }
1203 
1204  csserror = 0;
1205 
1206  copy_area = locator_recv_allocate_copyarea (num_objs, &content_ptr, content_size);
1207  if (copy_area)
1208  {
1209  if (num_objs > 0)
1210  {
1211  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &packed_desc, &received_size);
1212  assert (csserror || packed_desc_size == received_size);
1213  }
1214 
1215  if (csserror)
1216  {
1218  css_send_abort_to_client (thread_p->conn_entry, rid);
1219  goto end;
1220  }
1221  else
1222  {
1223  locator_unpack_copy_area_descriptor (num_objs, copy_area, packed_desc);
1224  mobjs = LC_MANYOBJS_PTR_IN_COPYAREA (copy_area);
1225  mobjs->multi_update_flags = multi_update_flags;
1226 
1227  if (content_size > 0)
1228  {
1229  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &new_content_ptr, &received_size);
1230 
1231  if (new_content_ptr != NULL)
1232  {
1233  memcpy (content_ptr, new_content_ptr, received_size);
1234  free_and_init (new_content_ptr);
1235  }
1236 
1237  if (csserror)
1238  {
1240  css_send_abort_to_client (thread_p->conn_entry, rid);
1241  goto end;
1242  }
1243  }
1244 
1245  success = xlocator_force (thread_p, copy_area, num_ignore_error_list, ignore_error_list);
1246 
1247  /*
1248  * Send the descriptor part since some information about the objects
1249  * (e.g., OIDs) may be send back to client.
1250  * Don't need to send the content since it is not updated.
1251  */
1252 
1253  locator_pack_copy_area_descriptor (num_objs, copy_area, packed_desc, packed_desc_size);
1254  ptr = or_pack_int (reply, success);
1255  ptr = or_pack_int (ptr, packed_desc_size);
1256  ptr = or_pack_int (ptr, 0);
1257 
1258  if (success != NO_ERROR && success != ER_LC_PARTIALLY_FAILED_TO_FLUSH)
1259  {
1260  (void) return_error_to_client (thread_p, rid);
1261  }
1262 
1263  css_send_reply_and_2_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply),
1264  packed_desc, packed_desc_size, NULL, 0);
1265  if (packed_desc)
1266  {
1267  free_and_init (packed_desc);
1268  }
1269  }
1270  }
1271 
1272 end:
1273  if (packed_desc)
1274  {
1275  free_and_init (packed_desc);
1276  }
1277  if (copy_area != NULL)
1278  {
1279  locator_free_copy_area (copy_area);
1280  }
1281 }
1282 
1283 /*
1284  * slocator_fetch_lockset -
1285  *
1286  * return:
1287  *
1288  * rid(in):
1289  * request(in):
1290  * reqlen(in):
1291  *
1292  * NOTE:
1293  */
1294 void
1295 slocator_fetch_lockset (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1296 {
1297  int success;
1298  LC_COPYAREA *copy_area;
1299  LC_LOCKSET *lockset;
1301  char *reply = OR_ALIGNED_BUF_START (a_reply);
1302  char *desc_ptr;
1303  int desc_size;
1304  char *content_ptr;
1305  int content_size;
1306  char *ptr;
1307  bool first_call;
1308  int num_objs;
1309  char *packed = NULL;
1310  int packed_size;
1311  int send_size;
1312 
1313  ptr = or_unpack_int (request, &packed_size);
1314 
1315  if (packed_size == 0 || css_receive_data_from_client (thread_p->conn_entry, rid, &packed, (int *) &packed_size))
1316  {
1318  css_send_abort_to_client (thread_p->conn_entry, rid);
1319  if (packed)
1320  {
1321  free_and_init (packed);
1322  }
1323  return;
1324  }
1325 
1326  lockset = locator_allocate_and_unpack_lockset (packed, packed_size, true, true, false);
1327  free_and_init (packed);
1328 
1329  if ((lockset == NULL) || (lockset->length <= 0))
1330  {
1331  (void) return_error_to_client (thread_p, rid);
1332  ptr = or_pack_int (reply, 0);
1333  ptr = or_pack_int (ptr, 0);
1334  ptr = or_pack_int (ptr, 0);
1335  ptr = or_pack_int (ptr, 0);
1336  ptr = or_pack_int (ptr, ER_FAILED);
1337  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1338  return;
1339  }
1340 
1341  first_call = true;
1342  do
1343  {
1344  desc_ptr = NULL;
1345  num_objs = 0;
1346 
1347  copy_area = NULL;
1348  success = xlocator_fetch_lockset (thread_p, lockset, &copy_area);
1349 
1350  if (success != NO_ERROR)
1351  {
1352  (void) return_error_to_client (thread_p, rid);
1353  }
1354 
1355  if (copy_area != NULL)
1356  {
1357  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
1358  }
1359  else
1360  {
1361  desc_ptr = NULL;
1362  desc_size = 0;
1363  content_ptr = NULL;
1364  content_size = 0;
1365  }
1366 
1367  /* Send sizes of databuffer and copy area (descriptor + content) */
1368 
1369  send_size = locator_pack_lockset (lockset, first_call, false);
1370 
1371  packed = lockset->packed;
1372  packed_size = lockset->packed_size;
1373 
1374  ptr = or_pack_int (reply, send_size);
1375  ptr = or_pack_int (ptr, num_objs);
1376  ptr = or_pack_int (ptr, desc_size);
1377  ptr = or_pack_int (ptr, content_size);
1378 
1379  ptr = or_pack_int (ptr, success);
1380 
1381  if (copy_area == NULL && lockset == NULL)
1382  {
1383  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1384  }
1385  else
1386  {
1387  css_send_reply_and_3_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), packed,
1388  send_size, desc_ptr, desc_size, content_ptr, content_size);
1389  }
1390  if (copy_area != NULL)
1391  {
1392  locator_free_copy_area (copy_area);
1393  }
1394  if (desc_ptr)
1395  {
1396  free_and_init (desc_ptr);
1397  }
1398 
1399  first_call = false;
1400  }
1401  while (copy_area && lockset
1403  || (lockset->num_reqobjs > lockset->num_reqobjs_processed)));
1404 
1405  if (lockset)
1406  {
1407  locator_free_lockset (lockset);
1408  }
1409 }
1410 
1411 /*
1412  * slocator_fetch_all_reference_lockset -
1413  *
1414  * return:
1415  *
1416  * rid(in):
1417  * request(in):
1418  * reqlen(in):
1419  *
1420  * NOTE:
1421  */
1422 void
1423 slocator_fetch_all_reference_lockset (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1424 {
1425  OID oid;
1426  int chn;
1427  LOCK lock;
1428  OID class_oid;
1429  int class_chn;
1430  int prune_level;
1431  int quit_on_errors;
1432  int success;
1433  LC_COPYAREA *copy_area;
1434  LC_LOCKSET *lockset;
1436  char *reply = OR_ALIGNED_BUF_START (a_reply);
1437  char *desc_ptr = NULL;
1438  int desc_size;
1439  char *content_ptr;
1440  int content_size;
1441  char *ptr;
1442  int num_objs = 0;
1443  char *packed = NULL;
1444  int packed_size;
1445  int send_size = 0;
1446 
1447  ptr = or_unpack_oid (request, &oid);
1448  ptr = or_unpack_int (ptr, &chn);
1449  ptr = or_unpack_oid (ptr, &class_oid);
1450  ptr = or_unpack_int (ptr, &class_chn);
1451  ptr = or_unpack_lock (ptr, &lock);
1452  ptr = or_unpack_int (ptr, &quit_on_errors);
1453  ptr = or_unpack_int (ptr, &prune_level);
1454 
1455  lockset = NULL;
1456  copy_area = NULL;
1457 
1458  success =
1459  xlocator_fetch_all_reference_lockset (thread_p, &oid, chn, &class_oid, class_chn, lock, quit_on_errors, prune_level,
1460  &lockset, &copy_area);
1461 
1462  if (success != NO_ERROR)
1463  {
1464  (void) return_error_to_client (thread_p, rid);
1465  }
1466 
1467  if (lockset != NULL && lockset->length > 0)
1468  {
1469  send_size = locator_pack_lockset (lockset, true, true);
1470 
1471  packed = lockset->packed;
1472  packed_size = lockset->packed_size;
1473 
1474  if (!packed)
1475  {
1476  (void) return_error_to_client (thread_p, rid);
1477  success = ER_FAILED;
1478  }
1479  }
1480 
1481  if (copy_area != NULL)
1482  {
1483  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
1484  }
1485  else
1486  {
1487  desc_ptr = NULL;
1488  desc_size = 0;
1489  content_ptr = NULL;
1490  content_size = 0;
1491  }
1492 
1493  /* Send sizes of databuffer and copy area (descriptor + content) */
1494 
1495  ptr = or_pack_int (reply, send_size);
1496  ptr = or_pack_int (ptr, num_objs);
1497  ptr = or_pack_int (ptr, desc_size);
1498  ptr = or_pack_int (ptr, content_size);
1499 
1500  ptr = or_pack_int (ptr, success);
1501 
1502  if (copy_area == NULL && lockset == NULL)
1503  {
1504  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1505  }
1506  else
1507  {
1508  css_send_reply_and_3_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), packed,
1509  send_size, desc_ptr, desc_size, content_ptr, content_size);
1510  if (copy_area != NULL)
1511  {
1512  locator_free_copy_area (copy_area);
1513  }
1514 
1515  if (lockset != NULL)
1516  {
1517  locator_free_lockset (lockset);
1518  }
1519 
1520  if (desc_ptr)
1521  {
1522  free_and_init (desc_ptr);
1523  }
1524  }
1525 }
1526 
1527 /*
1528  * slocator_find_class_oid -
1529  *
1530  * return:
1531  *
1532  * rid(in):
1533  * request(in):
1534  * reqlen(in):
1535  *
1536  * NOTE:
1537  */
1538 void
1539 slocator_find_class_oid (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1540 {
1541  LC_FIND_CLASSNAME found;
1542  char *classname;
1543  OID class_oid;
1544  LOCK lock;
1545  char *ptr;
1547  char *reply = OR_ALIGNED_BUF_START (a_reply);
1548 
1549  ptr = or_unpack_string_nocopy (request, &classname);
1550  ptr = or_unpack_oid (ptr, &class_oid);
1551  ptr = or_unpack_lock (ptr, &lock);
1552 
1553  found = xlocator_find_class_oid (thread_p, classname, &class_oid, lock);
1554 
1555  if (found == LC_CLASSNAME_ERROR)
1556  {
1557  (void) return_error_to_client (thread_p, rid);
1558  }
1559 
1560  ptr = or_pack_int (reply, found);
1561  ptr = or_pack_oid (ptr, &class_oid);
1562  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1563 }
1564 
1565 /*
1566  * slocator_reserve_classnames -
1567  *
1568  * return:
1569  *
1570  * rid(in):
1571  * request(in):
1572  * reqlen(in):
1573  *
1574  * NOTE:
1575  */
1576 void
1577 slocator_reserve_classnames (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1578 {
1580  int num_classes;
1581  char **classnames;
1582  OID *class_oids;
1583  char *ptr;
1584  int i;
1585  int malloc_size;
1586  char *malloc_area;
1587  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1588  char *reply = OR_ALIGNED_BUF_START (a_reply);
1589 
1590  ptr = or_unpack_int (request, &num_classes);
1591 
1592  malloc_size = ((sizeof (char *) + sizeof (OID)) * num_classes);
1593  malloc_area = (char *) db_private_alloc (thread_p, malloc_size);
1594  if (malloc_area != NULL)
1595  {
1596  classnames = (char **) malloc_area;
1597  class_oids = (OID *) ((char *) malloc_area + (sizeof (char *) * num_classes));
1598  for (i = 0; i < num_classes; i++)
1599  {
1600  ptr = or_unpack_string_nocopy (ptr, &classnames[i]);
1601  ptr = or_unpack_oid (ptr, &class_oids[i]);
1602  }
1603  reserved = xlocator_reserve_class_names (thread_p, num_classes, (const char **) classnames, class_oids);
1604  }
1605 
1606  if (reserved == LC_CLASSNAME_ERROR)
1607  {
1608  (void) return_error_to_client (thread_p, rid);
1609  }
1610 
1611  (void) or_pack_int (reply, reserved);
1612 
1613  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1614 
1615  if (malloc_area)
1616  {
1617  db_private_free_and_init (thread_p, malloc_area);
1618  }
1619 }
1620 
1621 /*
1622  * slocator_get_reserved_class_name_oid () - Send to client whether class name was
1623  * reserved by it.
1624  *
1625  * return : Void.
1626  * thread_p (in) : Thread entry.
1627  * rid (in) : ??
1628  * request (in) : Request data.
1629  * reqlen (in) : Request.
1630  */
1631 void
1632 slocator_get_reserved_class_name_oid (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1633 {
1634  char *classname;
1635  OID class_oid = OID_INITIALIZER;
1636  OR_ALIGNED_BUF (OR_OID_SIZE) a_reply;
1637  char *reply = OR_ALIGNED_BUF_START (a_reply);
1638  int error = NO_ERROR;
1639 
1640  (void) or_unpack_string_nocopy (request, &classname);
1641 
1642  error = xlocator_get_reserved_class_name_oid (thread_p, classname, &class_oid);
1643  if (error != NO_ERROR)
1644  {
1645  ASSERT_ERROR ();
1646  (void) return_error_to_client (thread_p, rid);
1647  }
1648  else
1649  {
1650  assert (!OID_ISNULL (&class_oid));
1651  }
1652  (void) or_pack_oid (reply, &class_oid);
1653  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1654 }
1655 
1656 /*
1657  * slocator_delete_class_name -
1658  *
1659  * return:
1660  *
1661  * rid(in):
1662  * request(in):
1663  * reqlen(in):
1664  *
1665  * NOTE:
1666  */
1667 void
1668 slocator_delete_class_name (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1669 {
1670  char *classname;
1671  LC_FIND_CLASSNAME deleted;
1672  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1673  char *reply = OR_ALIGNED_BUF_START (a_reply);
1674 
1675  (void) or_unpack_string_nocopy (request, &classname);
1676 
1677  deleted = xlocator_delete_class_name (thread_p, classname);
1678  if (deleted == LC_CLASSNAME_ERROR)
1679  {
1680  (void) return_error_to_client (thread_p, rid);
1681  }
1682 
1683  (void) or_pack_int (reply, deleted);
1684  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1685 }
1686 
1687 /*
1688  * slocator_rename_class_name -
1689  *
1690  * return:
1691  *
1692  * rid(in):
1693  * request(in):
1694  * reqlen(in):
1695  *
1696  * NOTE:
1697  */
1698 void
1699 slocator_rename_class_name (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1700 {
1701  char *oldname, *newname;
1702  OID class_oid;
1703  LC_FIND_CLASSNAME renamed;
1704  char *ptr;
1705  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1706  char *reply = OR_ALIGNED_BUF_START (a_reply);
1707 
1708  ptr = or_unpack_string_nocopy (request, &oldname);
1709  ptr = or_unpack_string_nocopy (ptr, &newname);
1710  ptr = or_unpack_oid (ptr, &class_oid);
1711 
1712  renamed = xlocator_rename_class_name (thread_p, oldname, newname, &class_oid);
1713  if (renamed == LC_CLASSNAME_ERROR)
1714  {
1715  (void) return_error_to_client (thread_p, rid);
1716  }
1717 
1718  (void) or_pack_int (reply, renamed);
1719  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1720 }
1721 
1722 /*
1723  * slocator_assign_oid -
1724  *
1725  * return:
1726  *
1727  * rid(in):
1728  * request(in):
1729  * reqlen(in):
1730  *
1731  * NOTE:
1732  */
1733 void
1734 slocator_assign_oid (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1735 {
1736  HFID hfid;
1737  int expected_length;
1738  OID class_oid, perm_oid;
1739  char *classname;
1740  int success;
1741  char *ptr;
1743  char *reply = OR_ALIGNED_BUF_START (a_reply);
1744 
1745  ptr = or_unpack_hfid (request, &hfid);
1746  ptr = or_unpack_int (ptr, &expected_length);
1747  ptr = or_unpack_oid (ptr, &class_oid);
1748  ptr = or_unpack_string_nocopy (ptr, &classname);
1749 
1750  success = ((xlocator_assign_oid (thread_p, &hfid, &perm_oid, expected_length, &class_oid, classname) == NO_ERROR)
1751  ? NO_ERROR : ER_FAILED);
1752  if (success != NO_ERROR)
1753  {
1754  (void) return_error_to_client (thread_p, rid);
1755  }
1756 
1757  ptr = or_pack_int (reply, success);
1758  ptr = or_pack_oid (ptr, &perm_oid);
1759  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1760 }
1761 
1762 /*
1763  * sqst_server_get_statistics -
1764  *
1765  * return:
1766  *
1767  * rid(in):
1768  * request(in):
1769  * reqlen(in):
1770  *
1771  * NOTE:
1772  */
1773 void
1774 sqst_server_get_statistics (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1775 {
1776  OID classoid;
1777  unsigned int timestamp;
1778  char *ptr;
1779  char *buffer;
1780  int buffer_length;
1781  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1782  char *reply = OR_ALIGNED_BUF_START (a_reply);
1783 
1784  ptr = or_unpack_oid (request, &classoid);
1785  ptr = or_unpack_int (ptr, (int *) &timestamp);
1786 
1787  buffer = xstats_get_statistics_from_server (thread_p, &classoid, timestamp, &buffer_length);
1788  if (buffer == NULL && buffer_length < 0)
1789  {
1790  (void) return_error_to_client (thread_p, rid);
1791  buffer_length = 0;
1792  }
1793 
1794  (void) or_pack_int (reply, buffer_length);
1795 
1796  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), buffer,
1797  buffer_length);
1798  if (buffer != NULL)
1799  {
1800  /* since this was copied to the client, we don't need it on the server */
1801  free_and_init (buffer);
1802  }
1803 }
1804 
1805 /*
1806  * slog_checkpoint -
1807  *
1808  * return:
1809  *
1810  * rid(in):
1811  * request(in):
1812  * reqlen(in):
1813  *
1814  * NOTE:
1815  */
1816 void
1817 slog_checkpoint (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1818 {
1819  int error = NO_ERROR;
1820  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1821  char *reply = OR_ALIGNED_BUF_START (a_reply);
1822 
1824 
1825  /* just send back a dummy message */
1826  (void) or_pack_errcode (reply, error);
1827  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1828 }
1829 
1830 #if defined(ENABLE_UNUSED_FUNCTION)
1831 /*
1832  * slogtb_has_updated -
1833  *
1834  * return:
1835  *
1836  * rid(in):
1837  * request(in):
1838  * reqlen(in):
1839  *
1840  * NOTE:
1841  */
1842 void
1843 slogtb_has_updated (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1844 {
1845  int has_updated;
1846  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1847  char *reply = OR_ALIGNED_BUF_START (a_reply);
1848 
1849  has_updated = logtb_has_updated (thread_p);
1850 
1851  (void) or_pack_int (reply, has_updated);
1852  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1853 }
1854 #endif /* ENABLE_UNUSED_FUNCTION */
1855 /*
1856  * slogtb_set_interrupt -
1857  *
1858  * return:
1859  *
1860  * rid(in):
1861  * request(in):
1862  * reqlen(in):
1863  *
1864  * NOTE:
1865  */
1866 void
1867 slogtb_set_interrupt (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1868 {
1869  int set;
1870 
1871  (void) or_unpack_int (request, &set);
1872  xlogtb_set_interrupt (thread_p, set);
1873 
1874  /*
1875  * No reply expected...
1876  */
1877 }
1878 
1879 /*
1880  * slogtb_set_suppress_repl_on_transaction -
1881  *
1882  * return:
1883  *
1884  * rid(in):
1885  * request(in):
1886  * reqlen(in):
1887  *
1888  * NOTE:
1889  */
1890 void
1891 slogtb_set_suppress_repl_on_transaction (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1892 {
1893  int set;
1894  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1895  char *reply = OR_ALIGNED_BUF_START (a_reply);
1896 
1897  (void) or_unpack_int (request, &set);
1899 
1900  /* always success */
1901  (void) or_pack_int (reply, NO_ERROR);
1902  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1903 }
1904 
1905 /*
1906  * slogtb_reset_wait_msecs -
1907  *
1908  * return:
1909  *
1910  * rid(in):
1911  * request(in):
1912  * reqlen(in):
1913  *
1914  * NOTE:
1915  */
1916 void
1917 slogtb_reset_wait_msecs (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1918 {
1919  int wait_msecs;
1920  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1921  char *reply = OR_ALIGNED_BUF_START (a_reply);
1922 
1923  (void) or_unpack_int (request, &wait_msecs);
1924 
1925  wait_msecs = xlogtb_reset_wait_msecs (thread_p, wait_msecs);
1926 
1927  (void) or_pack_int (reply, wait_msecs);
1928  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1929 }
1930 
1931 /*
1932  * slogtb_reset_isolation -
1933  *
1934  * return:
1935  *
1936  * rid(in):
1937  * request(in):
1938  * reqlen(in):
1939  *
1940  * NOTE:
1941  */
1942 void
1943 slogtb_reset_isolation (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1944 {
1945  int isolation, error_code;
1946  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1947  char *reply = OR_ALIGNED_BUF_START (a_reply);
1948  char *ptr;
1949 
1950  ptr = or_unpack_int (request, &isolation);
1951 
1952  error_code = (int) xlogtb_reset_isolation (thread_p, (TRAN_ISOLATION) isolation);
1953 
1954  if (error_code != NO_ERROR)
1955  {
1956  (void) return_error_to_client (thread_p, rid);
1957  }
1958 
1959  (void) or_pack_int (reply, error_code);
1960  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
1961 }
1962 
1963 /*
1964  * slogpb_dump_stat -
1965  *
1966  * return:
1967  *
1968  * rid(in):
1969  * request(in):
1970  * reqlen(in):
1971  *
1972  * NOTE:
1973  */
1974 void
1975 slogpb_dump_stat (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
1976 {
1977  FILE *outfp;
1978  int file_size;
1979  char *buffer;
1980  int buffer_size;
1981  int send_size;
1982  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
1983  char *reply = OR_ALIGNED_BUF_START (a_reply);
1984 
1985  (void) or_unpack_int (request, &buffer_size);
1986 
1987  buffer = (char *) db_private_alloc (NULL, buffer_size);
1988  if (buffer == NULL)
1989  {
1990  css_send_abort_to_client (thread_p->conn_entry, rid);
1991  return;
1992  }
1993 
1994  outfp = tmpfile ();
1995  if (outfp == NULL)
1996  {
1998  css_send_abort_to_client (thread_p->conn_entry, rid);
1999  db_private_free_and_init (NULL, buffer);
2000  return;
2001  }
2002 
2003  xlogpb_dump_stat (outfp);
2004  file_size = ftell (outfp);
2005 
2006  /*
2007  * Send the file in pieces
2008  */
2009  rewind (outfp);
2010 
2011  (void) or_pack_int (reply, (int) file_size);
2012  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2013 
2014  while (file_size > 0)
2015  {
2016  if (file_size > buffer_size)
2017  {
2018  send_size = buffer_size;
2019  }
2020  else
2021  {
2022  send_size = file_size;
2023  }
2024 
2025  file_size -= send_size;
2026  if (fread (buffer, 1, send_size, outfp) == 0)
2027  {
2029  css_send_abort_to_client (thread_p->conn_entry, rid);
2030  /*
2031  * Continue sending the stuff that was prmoised to client. In this case
2032  * junk (i.e., whatever it is in the buffers) is sent.
2033  */
2034  }
2035  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
2036  }
2037  fclose (outfp);
2038  db_private_free_and_init (NULL, buffer);
2039 }
2040 
2041 /*
2042  * slog_find_lob_locator -
2043  *
2044  * return:
2045  *
2046  * rid(in):
2047  * request(in):
2048  * reqlen(in):
2049  *
2050  * NOTE:
2051  */
2052 void
2053 slog_find_lob_locator (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2054 {
2055  char *locator;
2056  ES_URI real_locator;
2057  int real_loc_size;
2058  LOB_LOCATOR_STATE state;
2060  char *reply = OR_ALIGNED_BUF_START (a_reply);
2061  char *ptr;
2062 
2063  (void) or_unpack_string_nocopy (request, &locator);
2064 
2065  state = xtx_find_lob_locator (thread_p, locator, real_locator);
2066  real_loc_size = strlen (real_locator) + 1;
2067 
2068  ptr = or_pack_int (reply, real_loc_size);
2069  (void) or_pack_int (ptr, (int) state);
2070  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), real_locator,
2071  real_loc_size);
2072 }
2073 
2074 /*
2075  * slog_add_lob_locator -
2076  *
2077  * return:
2078  *
2079  * rid(in):
2080  * request(in):
2081  * reqlen(in):
2082  *
2083  * NOTE:
2084  */
2085 void
2086 slog_add_lob_locator (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2087 {
2088  char *locator;
2089  LOB_LOCATOR_STATE state;
2090  int tmp_int, error;
2091  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2092  char *reply = OR_ALIGNED_BUF_START (a_reply);
2093  char *ptr;
2094 
2095  ptr = or_unpack_string_nocopy (request, &locator);
2096  ptr = or_unpack_int (ptr, &tmp_int);
2097  state = (LOB_LOCATOR_STATE) tmp_int;
2098 
2099  error = xtx_add_lob_locator (thread_p, locator, state);
2100  if (error != NO_ERROR)
2101  {
2102  (void) return_error_to_client (thread_p, rid);
2103  }
2104 
2105  or_pack_int (reply, error);
2106  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2107 }
2108 
2109 /*
2110  * slog_change_state_of_locator -
2111  *
2112  * return:
2113  *
2114  * rid(in):
2115  * request(in):
2116  * reqlen(in):
2117  *
2118  * NOTE:
2119  */
2120 void
2121 slog_change_state_of_locator (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2122 {
2123  char *locator, *new_locator;
2124  LOB_LOCATOR_STATE state;
2125  int tmp_int, error;
2126  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2127  char *reply = OR_ALIGNED_BUF_START (a_reply);
2128  char *ptr;
2129 
2130  ptr = or_unpack_string_nocopy (request, &locator);
2131  ptr = or_unpack_string_nocopy (ptr, &new_locator);
2132  ptr = or_unpack_int (ptr, &tmp_int);
2133  state = (LOB_LOCATOR_STATE) tmp_int;
2134 
2135  error = xtx_change_state_of_locator (thread_p, locator, new_locator, state);
2136  if (error != NO_ERROR)
2137  {
2138  (void) return_error_to_client (thread_p, rid);
2139  }
2140 
2141  or_pack_int (reply, error);
2142  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2143 }
2144 
2145 /*
2146  * slog_drop_lob_locator -
2147  *
2148  * return:
2149  *
2150  * rid(in):
2151  * request(in):
2152  * reqlen(in):
2153  *
2154  * NOTE:
2155  */
2156 void
2157 slog_drop_lob_locator (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2158 {
2159  char *locator;
2160  int error;
2161  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2162  char *reply = OR_ALIGNED_BUF_START (a_reply);
2163  char *ptr;
2164 
2165  ptr = or_unpack_string_nocopy (request, &locator);
2166 
2167  error = xtx_drop_lob_locator (thread_p, locator);
2168  if (error != NO_ERROR)
2169  {
2170  (void) return_error_to_client (thread_p, rid);
2171  }
2172 
2173  or_pack_int (reply, error);
2174  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2175 }
2176 
2177 /*
2178  * sacl_reload -
2179  *
2180  * return:
2181  *
2182  * rid(in):
2183  * request(in):
2184  * reqlen(in):
2185  *
2186  * NOTE:
2187  */
2188 void
2189 sacl_reload (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2190 {
2191  int error;
2192  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2193  char *reply = OR_ALIGNED_BUF_START (a_reply);
2194 
2195  error = xacl_reload (thread_p);
2196  if (error != NO_ERROR)
2197  {
2198  (void) return_error_to_client (thread_p, rid);
2199  }
2200 
2201  (void) or_pack_errcode (reply, error);
2202  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2203 }
2204 
2205 /*
2206  * sacl_dump -
2207  *
2208  * return:
2209  *
2210  * rid(in):
2211  * request(in):
2212  * reqlen(in):
2213  *
2214  * NOTE:
2215  */
2216 void
2217 sacl_dump (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2218 {
2219  FILE *outfp;
2220  int file_size;
2221  char *buffer;
2222  int buffer_size;
2223  int send_size;
2224  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2225  char *reply = OR_ALIGNED_BUF_START (a_reply);
2226 
2227  (void) or_unpack_int (request, &buffer_size);
2228 
2229  buffer = (char *) db_private_alloc (thread_p, buffer_size);
2230  if (buffer == NULL)
2231  {
2232  css_send_abort_to_client (thread_p->conn_entry, rid);
2233  return;
2234  }
2235 
2236  outfp = tmpfile ();
2237  if (outfp == NULL)
2238  {
2240  css_send_abort_to_client (thread_p->conn_entry, rid);
2241  db_private_free_and_init (thread_p, buffer);
2242  return;
2243  }
2244 
2245  xacl_dump (thread_p, outfp);
2246  file_size = ftell (outfp);
2247 
2248  /*
2249  * Send the file in pieces
2250  */
2251  rewind (outfp);
2252 
2253  (void) or_pack_int (reply, (int) file_size);
2254  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2255 
2256  while (file_size > 0)
2257  {
2258  if (file_size > buffer_size)
2259  {
2260  send_size = buffer_size;
2261  }
2262  else
2263  {
2264  send_size = file_size;
2265  }
2266 
2267  file_size -= send_size;
2268  if (fread (buffer, 1, send_size, outfp) == 0)
2269  {
2271  css_send_abort_to_client (thread_p->conn_entry, rid);
2272  /*
2273  * Continue sending the stuff that was prmoised to client. In this case
2274  * junk (i.e., whatever it is in the buffers) is sent.
2275  */
2276  }
2277  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
2278  }
2279  fclose (outfp);
2280  db_private_free_and_init (thread_p, buffer);
2281 }
2282 
2283 /*
2284  * slock_dump -
2285  *
2286  * return:
2287  *
2288  * rid(in):
2289  * request(in):
2290  * reqlen(in):
2291  *
2292  * NOTE:
2293  */
2294 void
2295 slock_dump (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2296 {
2297  FILE *outfp;
2298  int file_size;
2299  char *buffer;
2300  int buffer_size;
2301  int send_size;
2302  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2303  char *reply = OR_ALIGNED_BUF_START (a_reply);
2304 
2305  (void) or_unpack_int (request, &buffer_size);
2306 
2307  buffer = (char *) db_private_alloc (thread_p, buffer_size);
2308  if (buffer == NULL)
2309  {
2310  css_send_abort_to_client (thread_p->conn_entry, rid);
2311  return;
2312  }
2313 
2314  outfp = tmpfile ();
2315  if (outfp == NULL)
2316  {
2318  css_send_abort_to_client (thread_p->conn_entry, rid);
2319  db_private_free_and_init (thread_p, buffer);
2320  return;
2321  }
2322 
2323  xlock_dump (thread_p, outfp);
2324  file_size = ftell (outfp);
2325 
2326  /*
2327  * Send the file in pieces
2328  */
2329  rewind (outfp);
2330 
2331  (void) or_pack_int (reply, (int) file_size);
2332  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2333 
2334  while (file_size > 0)
2335  {
2336  if (file_size > buffer_size)
2337  {
2338  send_size = buffer_size;
2339  }
2340  else
2341  {
2342  send_size = file_size;
2343  }
2344 
2345  file_size -= send_size;
2346  if (fread (buffer, 1, send_size, outfp) == 0)
2347  {
2349  css_send_abort_to_client (thread_p->conn_entry, rid);
2350  /*
2351  * Continue sending the stuff that was prmoised to client. In this case
2352  * junk (i.e., whatever it is in the buffers) is sent.
2353  */
2354  }
2355  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
2356  }
2357  fclose (outfp);
2358  db_private_free_and_init (thread_p, buffer);
2359 }
2360 
2361 /*
2362  * shf_create -
2363  *
2364  * return:
2365  *
2366  * rid(in):
2367  * request(in):
2368  * reqlen(in):
2369  *
2370  * NOTE:
2371  */
2372 void
2373 shf_create (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2374 {
2375  int error;
2376  HFID hfid;
2377  char *ptr;
2378  OID class_oid;
2380  char *reply = OR_ALIGNED_BUF_START (a_reply);
2381  int reuse_oid = 0;
2382 
2383  ptr = or_unpack_hfid (request, &hfid);
2384  ptr = or_unpack_oid (ptr, &class_oid);
2385  ptr = or_unpack_int (ptr, &reuse_oid);
2386 
2387  error = xheap_create (thread_p, &hfid, &class_oid, (bool) reuse_oid);
2388  if (error != NO_ERROR)
2389  {
2390  (void) return_error_to_client (thread_p, rid);
2391  }
2392 
2393  ptr = or_pack_errcode (reply, error);
2394  ptr = or_pack_hfid (ptr, &hfid);
2395  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2396 }
2397 
2398 /*
2399  * shf_destroy -
2400  *
2401  * return:
2402  *
2403  * rid(in):
2404  * request(in):
2405  * reqlen(in):
2406  *
2407  * NOTE:
2408  */
2409 void
2410 shf_destroy (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2411 {
2412 #if defined(ENABLE_UNUSED_FUNCTION)
2413  int error;
2414  HFID hfid;
2415  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2416  char *reply = OR_ALIGNED_BUF_START (a_reply);
2417 
2418  (void) or_unpack_hfid (request, &hfid);
2419 
2420  error = xheap_destroy (thread_p, &hfid, NULL);
2421  if (error != NO_ERROR)
2422  {
2423  (void) return_error_to_client (thread_p, rid);
2424  }
2425 
2426  (void) or_pack_errcode (reply, error);
2427  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2428 #endif /* ENABLE_UNUSED_FUNCTION */
2429 }
2430 
2431 /*
2432  * shf_destroy_when_new -
2433  *
2434  * return:
2435  *
2436  * rid(in):
2437  * request(in):
2438  * reqlen(in):
2439  *
2440  * NOTE:
2441  */
2442 void
2443 shf_destroy_when_new (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2444 {
2445  int error;
2446  HFID hfid;
2447  OID class_oid;
2448  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2449  char *reply = OR_ALIGNED_BUF_START (a_reply);
2450  char *ptr;
2451 
2452  ptr = or_unpack_hfid (request, &hfid);
2453  ptr = or_unpack_oid (ptr, &class_oid);
2454 
2455  error = xheap_destroy_newly_created (thread_p, &hfid, &class_oid);
2456  if (error != NO_ERROR)
2457  {
2458  (void) return_error_to_client (thread_p, rid);
2459  }
2460 
2461  (void) or_pack_errcode (reply, error);
2462  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2463 }
2464 
2465 /*
2466  * shf_heap_reclaim_addresses -
2467  *
2468  * return:
2469  *
2470  * rid(in):
2471  * request(in):
2472  * reqlen(in):
2473  *
2474  * NOTE:
2475  */
2476 void
2477 shf_heap_reclaim_addresses (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2478 {
2479  int error;
2480  HFID hfid;
2481  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2482  char *reply = OR_ALIGNED_BUF_START (a_reply);
2483  char *ptr = NULL;
2484 
2485  if (boot_can_compact (thread_p) == false)
2486  {
2488 
2489  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2490 
2491  return;
2492  }
2493 
2494  ptr = or_unpack_hfid (request, &hfid);
2495 
2496  error = xheap_reclaim_addresses (thread_p, &hfid);
2497  if (error != NO_ERROR)
2498  {
2499  (void) return_error_to_client (thread_p, rid);
2500  }
2501 
2502  (void) or_pack_errcode (reply, error);
2503  if (css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply)) != NO_ERROR)
2504  {
2505  boot_compact_stop (thread_p);
2506  }
2507 
2508 }
2509 
2510 /*
2511  * sfile_apply_tde_to_class_files -
2512  *
2513  * return:
2514  *
2515  * rid(in):
2516  * request(in):
2517  * reqlen(in):
2518  *
2519  * NOTE:
2520  */
2521 void
2522 sfile_apply_tde_to_class_files (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2523 {
2524  int error;
2525  char *ptr;
2526  OID class_oid;
2527  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2528  char *reply = OR_ALIGNED_BUF_START (a_reply);
2529 
2530  ptr = or_unpack_oid (request, &class_oid);
2531 
2532  error = xfile_apply_tde_to_class_files (thread_p, &class_oid);
2533  if (error != NO_ERROR)
2534  {
2535  (void) return_error_to_client (thread_p, rid);
2536  }
2537 
2538  ptr = or_pack_errcode (reply, error);
2539  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2540 }
2541 
2542 void
2543 stde_get_data_keys (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2544 {
2545  int area_size = -1;
2546  char *reply, *area, *ptr;
2548  int err = NO_ERROR;
2549 
2550  reply = OR_ALIGNED_BUF_START (a_reply);
2551 
2552  if (!tde_Cipher.is_loaded)
2553  {
2554  (void) return_error_to_client (thread_p, rid);
2555  area = NULL;
2556  area_size = 0;
2558  }
2559  else
2560  {
2561  area_size = 3 * or_packed_stream_length (TDE_DATA_KEY_LENGTH);
2562 
2563  area = (char *) db_private_alloc (thread_p, area_size);
2564  if (area == NULL)
2565  {
2566  (void) return_error_to_client (thread_p, rid);
2567  area_size = 0;
2568  }
2569  else
2570  {
2574  }
2575  }
2576 
2577  ptr = or_pack_int (reply, area_size);
2578  ptr = or_pack_int (ptr, err);
2579  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), area, area_size);
2580 
2581  if (area != NULL)
2582  {
2583  db_private_free_and_init (thread_p, area);
2584  }
2585 }
2586 
2587 /*
2588  * stde_get_mk_file_path -
2589  *
2590  * return:
2591  *
2592  * rid(in):
2593  * request(in):
2594  * reqlen(in):
2595  *
2596  * NOTE:
2597  */
2598 void
2599 stde_get_mk_file_path (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2600 {
2601  char mk_path[PATH_MAX] = { 0, };
2602  int pathlen = 0;
2603  int area_size = -1;
2604  char *reply, *area, *ptr;
2606  int err = NO_ERROR;
2607 
2608  reply = OR_ALIGNED_BUF_START (a_reply);
2609 
2610  tde_make_keys_file_fullname (mk_path, boot_db_full_name (), false);
2611 
2612  area_size = or_packed_string_length (mk_path, &pathlen);
2613 
2614  area = (char *) db_private_alloc (thread_p, area_size);
2615  if (area == NULL)
2616  {
2617  (void) return_error_to_client (thread_p, rid);
2618  area_size = 0;
2619  }
2620  else
2621  {
2622  ptr = or_pack_string_with_length (area, (char *) mk_path, pathlen);
2623  }
2624 
2625  ptr = or_pack_int (reply, area_size);
2626  ptr = or_pack_int (ptr, err);
2627  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), area, area_size);
2628 
2629  if (area != NULL)
2630  {
2631  db_private_free_and_init (thread_p, area);
2632  }
2633 }
2634 
2635 /*
2636  * stde_get_set_mk_info -
2637  *
2638  * return:
2639  *
2640  * rid(in):
2641  * request(in):
2642  * reqlen(in):
2643  *
2644  * NOTE:
2645  */
2646 void
2647 stde_get_mk_info (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2648 {
2649  int error;
2650  char *ptr;
2651  int mk_index;
2652  time_t created_time, set_time;
2654  char *reply = OR_ALIGNED_BUF_START (a_reply);
2655 
2656  error = xtde_get_mk_info (thread_p, &mk_index, &created_time, &set_time);
2657  if (error != NO_ERROR)
2658  {
2659  (void) return_error_to_client (thread_p, rid);
2660  }
2661 
2662  ptr = or_pack_errcode (reply, error);
2663  ptr = or_pack_int (ptr, mk_index);
2664  ptr = or_pack_int64 (ptr, created_time);
2665  ptr = or_pack_int64 (ptr, set_time);
2666  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2667 }
2668 
2669 /*
2670  * stde_change_mk_on_server -
2671  *
2672  * return:
2673  *
2674  * rid(in):
2675  * request(in):
2676  * reqlen(in):
2677  *
2678  * NOTE:
2679  */
2680 void
2681 stde_change_mk_on_server (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2682 {
2683  int error;
2684  char *ptr;
2685  int mk_index;
2686  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2687  char *reply = OR_ALIGNED_BUF_START (a_reply);
2688 
2689  ptr = or_unpack_int (request, &mk_index);
2690 
2691  error = xtde_change_mk_without_flock (thread_p, mk_index);
2692  if (error != NO_ERROR)
2693  {
2694  (void) return_error_to_client (thread_p, rid);
2695  }
2696 
2697  ptr = or_pack_errcode (reply, error);
2698  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2699 }
2700 
2701 /*
2702  * stran_server_commit -
2703  *
2704  * return:
2705  *
2706  * thrd(in):
2707  * rid(in):
2708  * request(in):
2709  * reqlen(in):
2710  *
2711  * NOTE:
2712  */
2713 void
2714 stran_server_commit (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2715 {
2716  TRAN_STATE state;
2717  int xretain_lock;
2718  bool retain_lock, should_conn_reset = false;
2720  char *reply = OR_ALIGNED_BUF_START (a_reply);
2721  char *ptr;
2722  int row_count = DB_ROW_COUNT_NOT_SET;
2723  int n_query_ids = 0, i = 0;
2724  QUERY_ID query_id;
2725 
2726  ptr = or_unpack_int (request, &xretain_lock);
2727  ptr = or_unpack_int (ptr, &row_count);
2728 
2729  /* First end deferred queries */
2730  ptr = or_unpack_int (ptr, &n_query_ids);
2731  for (i = 0; i < n_query_ids; i++)
2732  {
2733  ptr = or_unpack_ptr (ptr, &query_id);
2734  if (query_id > 0)
2735  {
2736  (void) xqmgr_end_query (thread_p, query_id);
2737  }
2738  }
2739 
2740  retain_lock = (bool) xretain_lock;
2741 
2742  /* set row count */
2743  xsession_set_row_count (thread_p, row_count);
2744 
2745  state = stran_server_commit_internal (thread_p, rid, retain_lock, &should_conn_reset);
2746 
2747  ptr = or_pack_int (reply, (int) state);
2748  ptr = or_pack_int (ptr, (int) should_conn_reset);
2749  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2750 }
2751 
2752 /*
2753  * stran_server_abort -
2754  *
2755  * return:
2756  *
2757  * thrd(in):
2758  * rid(in):
2759  * request(in):
2760  * reqlen(in):
2761  *
2762  * NOTE:
2763  */
2764 void
2765 stran_server_abort (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2766 {
2767  TRAN_STATE state;
2768  bool should_conn_reset = false, has_updated;
2770  char *reply = OR_ALIGNED_BUF_START (a_reply);
2771  char *ptr;
2772 
2773  has_updated = logtb_has_updated (thread_p);
2774 
2775  state = stran_server_abort_internal (thread_p, rid, &should_conn_reset);
2776 
2777  ptr = or_pack_int (reply, state);
2778  ptr = or_pack_int (ptr, (int) should_conn_reset);
2779  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2780 }
2781 
2782 /*
2783  * stran_server_has_updated -
2784  *
2785  * return:
2786  *
2787  * rid(in):
2788  * request(in):
2789  * reqlen(in):
2790  *
2791  * NOTE:
2792  */
2793 void
2794 stran_server_has_updated (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2795 {
2796  int has_updated;
2797  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2798  char *reply = OR_ALIGNED_BUF_START (a_reply);
2799 
2800  has_updated = xtran_server_has_updated (thread_p);
2801 
2802  (void) or_pack_int (reply, has_updated);
2803  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2804 }
2805 
2806 /*
2807  * stran_server_start_topop -
2808  *
2809  * return:
2810  *
2811  * rid(in):
2812  * request(in):
2813  * reqlen(in):
2814  *
2815  * NOTE:
2816  */
2817 void
2818 stran_server_start_topop (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2819 {
2820  int success;
2821  LOG_LSA topop_lsa;
2823  char *reply = OR_ALIGNED_BUF_START (a_reply);
2824  char *ptr;
2825 
2826  success = (xtran_server_start_topop (thread_p, &topop_lsa) == NO_ERROR) ? NO_ERROR : ER_FAILED;
2827  if (success != NO_ERROR)
2828  {
2829  (void) return_error_to_client (thread_p, rid);
2830  }
2831 
2832  ptr = or_pack_int (reply, success);
2833  ptr = or_pack_log_lsa (ptr, &topop_lsa);
2834  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2835 }
2836 
2837 /*
2838  * stran_server_end_topop -
2839  *
2840  * return:
2841  *
2842  * rid(in):
2843  * request(in):
2844  * reqlen(in):
2845  *
2846  * NOTE:
2847  */
2848 void
2849 stran_server_end_topop (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2850 {
2851  TRAN_STATE state;
2852  LOG_LSA topop_lsa;
2853  int xresult;
2854  LOG_RESULT_TOPOP result;
2856  char *reply = OR_ALIGNED_BUF_START (a_reply);
2857  char *ptr;
2858 
2859  (void) or_unpack_int (request, &xresult);
2860  result = (LOG_RESULT_TOPOP) xresult;
2861 
2862  state = xtran_server_end_topop (thread_p, result, &topop_lsa);
2863 
2864  ptr = or_pack_int (reply, (int) state);
2865  ptr = or_pack_log_lsa (ptr, &topop_lsa);
2866  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2867 }
2868 
2869 /*
2870  * stran_server_savepoint -
2871  *
2872  * return:
2873  *
2874  * rid(in):
2875  * request(in):
2876  * reqlen(in):
2877  *
2878  * NOTE:
2879  */
2880 void
2881 stran_server_savepoint (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2882 {
2883  int success;
2884  char *savept_name;
2885  LOG_LSA topop_lsa;
2887  char *reply = OR_ALIGNED_BUF_START (a_reply);
2888  char *ptr;
2889 
2890  ptr = or_unpack_string_nocopy (request, &savept_name);
2891 
2892  success = (xtran_server_savepoint (thread_p, savept_name, &topop_lsa) == NO_ERROR) ? NO_ERROR : ER_FAILED;
2893  if (success != NO_ERROR)
2894  {
2895  (void) return_error_to_client (thread_p, rid);
2896  }
2897 
2898  ptr = or_pack_int (reply, success);
2899  ptr = or_pack_log_lsa (ptr, &topop_lsa);
2900  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2901 }
2902 
2903 /*
2904  * stran_server_partial_abort -
2905  *
2906  * return:
2907  *
2908  * rid(in):
2909  * request(in):
2910  * reqlen(in):
2911  *
2912  * NOTE:
2913  */
2914 void
2915 stran_server_partial_abort (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2916 {
2917  TRAN_STATE state;
2918  char *savept_name;
2919  LOG_LSA savept_lsa;
2921  char *reply = OR_ALIGNED_BUF_START (a_reply);
2922  char *ptr;
2923 
2924  ptr = or_unpack_string_nocopy (request, &savept_name);
2925 
2926  state = xtran_server_partial_abort (thread_p, savept_name, &savept_lsa);
2927  if (state != TRAN_UNACTIVE_ABORTED)
2928  {
2929  /* Likely the abort failed.. somehow */
2930  (void) return_error_to_client (thread_p, rid);
2931  }
2932 
2933  ptr = or_pack_int (reply, (int) state);
2934  ptr = or_pack_log_lsa (ptr, &savept_lsa);
2935  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2936 }
2937 
2938 /*
2939  * stran_server_is_active_and_has_updated -
2940  *
2941  * return:
2942  *
2943  * rid(in):
2944  * request(in):
2945  * reqlen(in):
2946  *
2947  * NOTE:
2948  */
2949 void
2950 stran_server_is_active_and_has_updated (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2951 {
2952  int isactive_has_updated;
2953  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2954  char *reply = OR_ALIGNED_BUF_START (a_reply);
2955 
2956  isactive_has_updated = xtran_server_is_active_and_has_updated (thread_p);
2957 
2958  (void) or_pack_int (reply, isactive_has_updated);
2959  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2960 }
2961 
2962 /*
2963  * stran_wait_server_active_trans -
2964  *
2965  * return:
2966  *
2967  * rid(in):
2968  * request(in):
2969  * reqlen(in):
2970  *
2971  * NOTE:
2972  */
2973 void
2974 stran_wait_server_active_trans (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2975 {
2976  int status;
2977  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
2978  char *reply = OR_ALIGNED_BUF_START (a_reply);
2979 
2980  status = xtran_wait_server_active_trans (thread_p);
2981 
2982  (void) or_pack_int (reply, status);
2983  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
2984 }
2985 
2986 /*
2987  * stran_is_blocked -
2988  *
2989  * return:
2990  *
2991  * rid(in):
2992  * request(in):
2993  * reqlen(in):
2994  *
2995  * NOTE:
2996  */
2997 void
2998 stran_is_blocked (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
2999 {
3000  int tran_index;
3001  bool blocked;
3002  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3003  char *reply = OR_ALIGNED_BUF_START (a_reply);
3004 
3005  (void) or_unpack_int (request, &tran_index);
3006 
3007  blocked = xtran_is_blocked (thread_p, tran_index);
3008 
3009  (void) or_pack_int (reply, blocked ? 1 : 0);
3010  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3011 }
3012 
3013 /*
3014  * stran_server_set_global_tran_info -
3015  *
3016  * return:
3017  *
3018  * rid(in):
3019  * request(in):
3020  * reqlen(in):
3021  *
3022  * NOTE:
3023  */
3024 void
3025 stran_server_set_global_tran_info (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3026 {
3027  int success;
3028  int gtrid;
3029  void *info;
3030  int size;
3031  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3032  char *reply = OR_ALIGNED_BUF_START (a_reply);
3033 
3034  (void) or_unpack_int (request, &gtrid);
3035 
3036  if (css_receive_data_from_client (thread_p->conn_entry, rid, (char **) &info, (int *) &size))
3037  {
3039  css_send_abort_to_client (thread_p->conn_entry, rid);
3040  return;
3041  }
3042 
3043  success = (xtran_server_set_global_tran_info (thread_p, gtrid, info, size) == NO_ERROR) ? NO_ERROR : ER_FAILED;
3044  if (success != NO_ERROR)
3045  {
3046  (void) return_error_to_client (thread_p, rid);
3047  }
3048 
3049  (void) or_pack_int (reply, success);
3050  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3051 
3052  if (info != NULL)
3053  {
3054  free_and_init (info);
3055  }
3056 }
3057 
3058 /*
3059  * stran_server_get_global_tran_info -
3060  *
3061  * return:
3062  *
3063  * rid(in):
3064  * request(in):
3065  * reqlen(in):
3066  *
3067  * NOTE:
3068  */
3069 void
3070 stran_server_get_global_tran_info (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3071 {
3072  int success;
3073  int gtrid;
3074  void *buffer;
3075  int size;
3076  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
3077  char *reply = OR_ALIGNED_BUF_START (a_reply), *ptr;
3078 
3079  ptr = or_unpack_int (request, &gtrid);
3080  ptr = or_unpack_int (ptr, &size);
3081 
3082  buffer = malloc (size);
3083  if (buffer == NULL)
3084  {
3085  css_send_abort_to_client (thread_p->conn_entry, rid);
3086  return;
3087  }
3088 
3089  success = (xtran_server_get_global_tran_info (thread_p, gtrid, buffer, size) == NO_ERROR) ? NO_ERROR : ER_FAILED;
3090  if (success != NO_ERROR)
3091  {
3092  (void) return_error_to_client (thread_p, rid);
3093  size = 0;
3094  }
3095 
3096  ptr = or_pack_int (reply, size);
3097  ptr = or_pack_int (ptr, success);
3098  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), (char *) buffer,
3099  size);
3100  free_and_init (buffer);
3101 }
3102 
3103 /*
3104  * stran_server_2pc_start -
3105  *
3106  * return:
3107  *
3108  * rid(in):
3109  * request(in):
3110  * reqlen(in):
3111  *
3112  * NOTE:
3113  */
3114 void
3115 stran_server_2pc_start (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3116 {
3117  int gtrid = NULL_TRANID;
3118  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3119  char *reply = OR_ALIGNED_BUF_START (a_reply);
3120 
3121  gtrid = xtran_server_2pc_start (thread_p);
3122  if (gtrid < 0)
3123  {
3124  (void) return_error_to_client (thread_p, rid);
3125  }
3126 
3127  (void) or_pack_int (reply, gtrid);
3128  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3129 }
3130 
3131 /*
3132  * stran_server_2pc_prepare -
3133  *
3134  * return:
3135  *
3136  * rid(in):
3137  * request(in):
3138  * reqlen(in):
3139  *
3140  * NOTE:
3141  */
3142 void
3143 stran_server_2pc_prepare (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3144 {
3146  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3147  char *reply = OR_ALIGNED_BUF_START (a_reply);
3148 
3149  state = xtran_server_2pc_prepare (thread_p);
3150  if (state != TRAN_UNACTIVE_2PC_PREPARE && state != TRAN_UNACTIVE_COMMITTED)
3151  {
3152  /* the prepare failed. */
3153  (void) return_error_to_client (thread_p, rid);
3154  }
3155 
3156  (void) or_pack_int (reply, state);
3157  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3158 }
3159 
3160 /*
3161  * stran_server_2pc_recovery_prepared -
3162  *
3163  * return:
3164  *
3165  * rid(in):
3166  * request(in):
3167  * reqlen(in):
3168  *
3169  * NOTE:
3170  */
3171 void
3172 stran_server_2pc_recovery_prepared (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3173 {
3174  int count, *gtrids, size, i;
3175  int reply_size;
3176  char *reply, *ptr;
3177 
3178  (void) or_unpack_int (request, &size);
3179 
3180  gtrids = (int *) malloc (sizeof (int) * size);
3181  if (gtrids == NULL)
3182  {
3183  css_send_abort_to_client (thread_p->conn_entry, rid);
3184  return;
3185  }
3186 
3187  count = xtran_server_2pc_recovery_prepared (thread_p, gtrids, size);
3188  if (count < 0 || count > size)
3189  {
3190  (void) return_error_to_client (thread_p, rid);
3191  }
3192 
3193  reply_size = OR_INT_SIZE + (OR_INT_SIZE * size);
3194  reply = (char *) malloc (reply_size);
3195  if (reply == NULL)
3196  {
3197  css_send_abort_to_client (thread_p->conn_entry, rid);
3198  free_and_init (gtrids);
3199  return;
3200  }
3201  (void) memset (reply, 0, reply_size);
3202  ptr = or_pack_int (reply, count);
3203  for (i = 0; i < count; i++)
3204  {
3205  ptr = or_pack_int (ptr, gtrids[i]);
3206  }
3207  css_send_data_to_client (thread_p->conn_entry, rid, reply, reply_size);
3208 
3209  free_and_init (gtrids);
3210  free_and_init (reply);
3211 }
3212 
3213 /*
3214  * stran_server_2pc_attach_global_tran -
3215  *
3216  * return:
3217  *
3218  * rid(in):
3219  * request(in):
3220  * reqlen(in):
3221  *
3222  * NOTE:
3223  */
3224 void
3225 stran_server_2pc_attach_global_tran (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3226 {
3227  int gtrid;
3228  int tran_index;
3229  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3230  char *reply = OR_ALIGNED_BUF_START (a_reply);
3231 
3232  (void) or_unpack_int (request, &gtrid);
3233 
3234  tran_index = xtran_server_2pc_attach_global_tran (thread_p, gtrid);
3235  if (tran_index == NULL_TRAN_INDEX)
3236  {
3237  (void) return_error_to_client (thread_p, rid);
3238  }
3239 
3240  (void) or_pack_int (reply, tran_index);
3241  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3242 }
3243 
3244 /*
3245  * stran_server_2pc_prepare_global_tran -
3246  *
3247  * return:
3248  *
3249  * rid(in):
3250  * request(in):
3251  * reqlen(in):
3252  *
3253  * NOTE:
3254  */
3255 void
3256 stran_server_2pc_prepare_global_tran (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3257 {
3258  TRAN_STATE state;
3259  int gtrid;
3260  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3261  char *reply = OR_ALIGNED_BUF_START (a_reply);
3262 
3263  (void) or_unpack_int (request, &gtrid);
3264 
3265  state = xtran_server_2pc_prepare_global_tran (thread_p, gtrid);
3266  if (state != TRAN_UNACTIVE_2PC_PREPARE && state != TRAN_UNACTIVE_COMMITTED)
3267  {
3268  /* Likely the prepare failed.. somehow */
3269  (void) return_error_to_client (thread_p, rid);
3270  }
3271 
3272  (void) or_pack_int (reply, state);
3273  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3274 }
3275 
3276 /*
3277  * stran_lock_rep_read -
3278  *
3279  * return:
3280  *
3281  * rid(in):
3282  * request(in):
3283  * reqlen(in):
3284  *
3285  * NOTE:
3286  */
3287 void
3288 stran_lock_rep_read (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3289 {
3290  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3291  char *reply = OR_ALIGNED_BUF_START (a_reply);
3292  char *ptr;
3293  int lock_rr_tran;
3294  int success;
3295 
3296  ptr = request;
3297  ptr = or_unpack_int (ptr, &lock_rr_tran);
3298 
3299  success = xtran_lock_rep_read (thread_p, (LOCK) lock_rr_tran);
3300 
3301  if (success != NO_ERROR)
3302  {
3303  (void) return_error_to_client (thread_p, rid);
3304  }
3305 
3306  ptr = or_pack_int (reply, success);
3307  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3308 }
3309 
3310 /*
3311  * sboot_initialize_server -
3312  *
3313  * return:
3314  *
3315  * rid(in):
3316  * request(in):
3317  * reqlen(in):
3318  *
3319  * NOTE:
3320  */
3321 void
3322 sboot_initialize_server (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3323 {
3324  css_send_abort_to_client (thread_p->conn_entry, rid);
3325 }
3326 
3327 /*
3328  * sboot_register_client -
3329  *
3330  * return:
3331  *
3332  * rid(in):
3333  * request(in):
3334  * reqlen(in):
3335  *
3336  * NOTE:
3337  */
3338 void
3339 sboot_register_client (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3340 {
3341  int xint;
3342  BOOT_CLIENT_CREDENTIAL client_credential;
3343  BOOT_SERVER_CREDENTIAL server_credential;
3344  int tran_index, client_lock_wait;
3345  TRAN_ISOLATION client_isolation;
3346  TRAN_STATE tran_state;
3347  int area_size, strlen1, strlen2, strlen3, strlen4;
3348  char *reply, *area, *ptr;
3349  packing_unpacker unpacker;
3350 
3351  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3352 
3353  reply = OR_ALIGNED_BUF_START (a_reply);
3354 
3355  memset (&server_credential, 0, sizeof (server_credential));
3356 
3357  unpacker.set_buffer (request, (size_t) reqlen);
3358  unpacker.unpack_all (client_credential, client_lock_wait, xint);
3359  client_isolation = (TRAN_ISOLATION) xint;
3360 
3361  tran_index = xboot_register_client (thread_p, &client_credential, client_lock_wait, client_isolation, &tran_state,
3362  &server_credential);
3363  if (tran_index == NULL_TRAN_INDEX)
3364  {
3365  (void) return_error_to_client (thread_p, rid);
3366  area = NULL;
3367  area_size = 0;
3368  }
3369  else
3370  {
3371  area_size = (OR_INT_SIZE /* tran_index */
3372  + OR_INT_SIZE /* tran_state */
3373  + or_packed_string_length (server_credential.db_full_name, &strlen1) /* db_full_name */
3374  + or_packed_string_length (server_credential.host_name, &strlen2) /* host_name */
3375  + or_packed_string_length (server_credential.lob_path, &strlen3) /* lob_path */
3376  + OR_INT_SIZE /* process_id */
3377  + OR_OID_SIZE /* root_class_oid */
3378  + OR_HFID_SIZE /* root_class_hfid */
3379  + OR_INT_SIZE /* page_size */
3380  + OR_INT_SIZE /* log_page_size */
3381  + OR_FLOAT_SIZE /* disk_compatibility */
3382  + OR_INT_SIZE /* ha_server_state */
3383  + OR_INT_SIZE /* db_charset */
3384  + or_packed_string_length (server_credential.db_lang, &strlen4) /* db_lang */ );
3385 
3386  area = (char *) db_private_alloc (thread_p, area_size);
3387  if (area == NULL)
3388  {
3389  (void) return_error_to_client (thread_p, rid);
3390  area_size = 0;
3391  }
3392  else
3393  {
3394  ptr = or_pack_int (area, tran_index);
3395  ptr = or_pack_int (ptr, (int) tran_state);
3396  ptr = or_pack_string_with_length (ptr, server_credential.db_full_name, strlen1);
3397  ptr = or_pack_string_with_length (ptr, server_credential.host_name, strlen2);
3398  ptr = or_pack_string_with_length (ptr, server_credential.lob_path, strlen3);
3399  ptr = or_pack_int (ptr, server_credential.process_id);
3400  ptr = or_pack_oid (ptr, &server_credential.root_class_oid);
3401  ptr = or_pack_hfid (ptr, &server_credential.root_class_hfid);
3402  ptr = or_pack_int (ptr, (int) server_credential.page_size);
3403  ptr = or_pack_int (ptr, (int) server_credential.log_page_size);
3404  ptr = or_pack_float (ptr, server_credential.disk_compatibility);
3405  ptr = or_pack_int (ptr, (int) server_credential.ha_server_state);
3406  ptr = or_pack_int (ptr, server_credential.db_charset);
3407  ptr = or_pack_string_with_length (ptr, server_credential.db_lang, strlen4);
3408  }
3409  }
3410 
3411  ptr = or_pack_int (reply, area_size);
3412  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), area, area_size);
3413 
3414  if (area != NULL)
3415  {
3416  db_private_free_and_init (thread_p, area);
3417  }
3418 }
3419 
3420 /*
3421  * sboot_notify_unregister_client -
3422  *
3423  * return:
3424  *
3425  * rid(in):
3426  * request(in):
3427  * reqlen(in):
3428  *
3429  * NOTE:
3430  */
3431 void
3432 sboot_notify_unregister_client (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3433 {
3434  CSS_CONN_ENTRY *conn;
3435  int tran_index;
3436  int success = NO_ERROR;
3437  int r;
3438  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3439  char *reply = OR_ALIGNED_BUF_START (a_reply);
3440 
3441  (void) or_unpack_int (request, &tran_index);
3442 
3443  if (thread_p == NULL)
3444  {
3445  thread_p = thread_get_thread_entry_info ();
3446  if (thread_p == NULL)
3447  {
3448  return;
3449  }
3450  }
3451  conn = thread_p->conn_entry;
3452  assert (conn != NULL);
3453 
3454  /* There's an interesting race condition among client, worker thread and connection handler.
3455  * Please find CBRD-21375 for detail and also see css_connection_handler_thread.
3456  *
3457  * It is important to synchronize worker thread with connection handler to avoid the race condition.
3458  * To change conn->status and send reply to client should be atomic.
3459  * Otherwise, connection handler may disconnect the connection and it prevents client from receiving the reply.
3460  */
3461  r = rmutex_lock (thread_p, &conn->rmutex);
3462  assert (r == NO_ERROR);
3463 
3464  xboot_notify_unregister_client (thread_p, tran_index);
3465 
3466  (void) or_pack_int (reply, success);
3467  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3468 
3469  r = rmutex_unlock (thread_p, &conn->rmutex);
3470  assert (r == NO_ERROR);
3471 }
3472 
3473 /*
3474  * sboot_backup -
3475  *
3476  * return:
3477  *
3478  * rid(in):
3479  * request(in):
3480  * reqlen(in):
3481  *
3482  * NOTE:
3483  */
3484 void
3485 sboot_backup (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3486 {
3487  int success;
3488  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
3489  char *reply = OR_ALIGNED_BUF_START (a_reply);
3490  char *ptr;
3491  char *backup_path;
3492  FILEIO_BACKUP_LEVEL backup_level;
3493  int delete_unneeded_logarchives;
3494  char *backup_verbose_file;
3495  int num_threads;
3496  FILEIO_ZIP_METHOD zip_method;
3497  FILEIO_ZIP_LEVEL zip_level;
3498  int skip_activelog;
3499  int sleep_msecs;
3500  int separate_keys;
3501 
3502  ptr = or_unpack_string_nocopy (request, &backup_path);
3503  ptr = or_unpack_int (ptr, (int *) &backup_level);
3504  ptr = or_unpack_int (ptr, &delete_unneeded_logarchives);
3505  ptr = or_unpack_string_nocopy (ptr, &backup_verbose_file);
3506  ptr = or_unpack_int (ptr, &num_threads);
3507  ptr = or_unpack_int (ptr, (int *) &zip_method);
3508  ptr = or_unpack_int (ptr, (int *) &zip_level);
3509  ptr = or_unpack_int (ptr, (int *) &skip_activelog);
3510  ptr = or_unpack_int (ptr, (int *) &sleep_msecs);
3511  ptr = or_unpack_int (ptr, (int *) &separate_keys);
3512 
3513  success =
3514  xboot_backup (thread_p, backup_path, backup_level, delete_unneeded_logarchives, backup_verbose_file, num_threads,
3515  zip_method, zip_level, skip_activelog, sleep_msecs, separate_keys);
3516 
3517  if (success != NO_ERROR)
3518  {
3519  (void) return_error_to_client (thread_p, rid);
3520  }
3521 
3522  /*
3523  * To indicate results we really only need 2 ints, but the remote
3524  * bo and callback routine was expecting to receive 3 ints.
3525  */
3526  ptr = or_pack_int (reply, (int) END_CALLBACK);
3527  ptr = or_pack_int (ptr, success);
3528  ptr = or_pack_int (ptr, 0xEEABCDFFL); /* padding, not used */
3529 
3530  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3531 }
3532 
3533 /*
3534  * sboot_add_volume_extension -
3535  *
3536  * return:
3537  *
3538  * rid(in):
3539  * request(in):
3540  * reqlen(in):
3541  *
3542  * NOTE:
3543  */
3544 void
3545 sboot_add_volume_extension (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3546 {
3547  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3548  char *reply = OR_ALIGNED_BUF_START (a_reply);
3549  char *ptr;
3550  DBDEF_VOL_EXT_INFO ext_info;
3551  int tmp;
3552  VOLID volid;
3553  char *unpack_char; /* to suppress warning */
3554 
3555  ptr = or_unpack_string_nocopy (request, &unpack_char);
3556  ext_info.path = unpack_char;
3557  ptr = or_unpack_string_nocopy (ptr, &unpack_char);
3558  ext_info.name = unpack_char;
3559  ptr = or_unpack_string_nocopy (ptr, &unpack_char);
3560  ext_info.comments = unpack_char;
3561  ptr = or_unpack_int (ptr, &ext_info.max_npages);
3562  ptr = or_unpack_int (ptr, &ext_info.max_writesize_in_sec);
3563  ptr = or_unpack_int (ptr, &tmp);
3564  ext_info.purpose = (DB_VOLPURPOSE) tmp;
3565  ptr = or_unpack_int (ptr, &tmp);
3566  ext_info.overwrite = (bool) tmp;
3567 
3568  volid = xboot_add_volume_extension (thread_p, &ext_info);
3569 
3570  if (volid == NULL_VOLID)
3571  {
3572  (void) return_error_to_client (thread_p, rid);
3573  }
3574 
3575  (void) or_pack_int (reply, (int) volid);
3576  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3577 }
3578 
3579 /*
3580  * sboot_check_db_consistency -
3581  *
3582  * return:
3583  *
3584  * rid(in):
3585  * request(in):
3586  * reqlen(in):
3587  *
3588  * NOTE:
3589  */
3590 void
3591 sboot_check_db_consistency (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3592 {
3593  int success;
3594  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
3595  char *reply = OR_ALIGNED_BUF_START (a_reply);
3596  char *ptr;
3597  int check_flag;
3598  int num = 0, i;
3599  OID *oids = NULL;
3600  BTID index_btid;
3601 
3602  if (request == NULL)
3603  {
3605  }
3606  else
3607  {
3608  ptr = or_unpack_int (request, &check_flag);
3609  ptr = or_unpack_int (ptr, &num);
3610  oids = (OID *) malloc (sizeof (OID) * num);
3611  if (oids == NULL)
3612  {
3613  success = ER_FAILED;
3614  goto function_exit;
3615  }
3616  for (i = 0; i < num; i++)
3617  {
3618  ptr = or_unpack_oid (ptr, &oids[i]);
3619  }
3620  ptr = or_unpack_btid (ptr, &index_btid);
3621  }
3622 
3623  success = xboot_check_db_consistency (thread_p, check_flag, oids, num, &index_btid);
3624  success = success == NO_ERROR ? NO_ERROR : ER_FAILED;
3625  free_and_init (oids);
3626 
3627  if (success != NO_ERROR)
3628  {
3629  (void) return_error_to_client (thread_p, rid);
3630  }
3631 
3632 function_exit:
3633  /*
3634  * To indicate results we really only need 2 ints, but the remote
3635  * bo and callback routine was expecting to receive 3 ints.
3636  */
3637  ptr = or_pack_int (reply, (int) END_CALLBACK);
3638  ptr = or_pack_int (ptr, success);
3639  ptr = or_pack_int (ptr, 0xEEABCDFFL); /* padding, not used */
3640  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3641 }
3642 
3643 /*
3644  * sboot_find_number_permanent_volumes -
3645  *
3646  * return:
3647  *
3648  * rid(in):
3649  * request(in):
3650  * reqlen(in):
3651  *
3652  * NOTE:
3653  */
3654 void
3655 sboot_find_number_permanent_volumes (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3656 {
3657  int nvols;
3658  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3659  char *reply = OR_ALIGNED_BUF_START (a_reply);
3660 
3661  nvols = xboot_find_number_permanent_volumes (thread_p);
3662 
3663  (void) or_pack_int (reply, nvols);
3664  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3665 }
3666 
3667 /*
3668  * sboot_find_number_temp_volumes -
3669  *
3670  * return:
3671  *
3672  * rid(in):
3673  * request(in):
3674  * reqlen(in):
3675  *
3676  * NOTE:
3677  */
3678 void
3679 sboot_find_number_temp_volumes (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3680 {
3681  int nvols;
3682  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3683  char *reply = OR_ALIGNED_BUF_START (a_reply);
3684 
3685  nvols = xboot_find_number_temp_volumes (thread_p);
3686 
3687  (void) or_pack_int (reply, nvols);
3688  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3689 }
3690 
3691 /*
3692  * sboot_find_last_permanent -
3693  *
3694  * return:
3695  *
3696  * rid(in):
3697  * request(in):
3698  * reqlen(in):
3699  *
3700  * NOTE:
3701  */
3702 void
3703 sboot_find_last_permanent (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3704 {
3705  VOLID volid;
3706  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3707  char *reply = OR_ALIGNED_BUF_START (a_reply);
3708 
3709  volid = xboot_find_last_permanent (thread_p);
3710 
3711  (void) or_pack_int (reply, (int) volid);
3712  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3713 }
3714 
3715 /*
3716  * sboot_find_last_temp -
3717  *
3718  * return:
3719  *
3720  * rid(in):
3721  * request(in):
3722  * reqlen(in):
3723  *
3724  * NOTE:
3725  */
3726 void
3727 sboot_find_last_temp (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3728 {
3729  int nvols;
3730  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3731  char *reply = OR_ALIGNED_BUF_START (a_reply);
3732 
3733  nvols = xboot_find_last_temp (thread_p);
3734 
3735  (void) or_pack_int (reply, nvols);
3736  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3737 }
3738 
3739 /*
3740  * sboot_change_ha_mode -
3741  */
3742 void
3743 sboot_change_ha_mode (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3744 {
3745  int req_state, force, timeout;
3746  HA_SERVER_STATE state;
3747  DB_INFO *db;
3748  char *ptr;
3749  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3750  char *reply = OR_ALIGNED_BUF_START (a_reply);
3751 
3752  ptr = or_unpack_int (request, &req_state);
3753  state = (HA_SERVER_STATE) req_state;
3754  ptr = or_unpack_int (ptr, &force);
3755  ptr = or_unpack_int (ptr, &timeout);
3756 
3757  if (state > HA_SERVER_STATE_IDLE && state < HA_SERVER_STATE_DEAD)
3758  {
3759  if (css_change_ha_server_state (thread_p, state, force, timeout, false) != NO_ERROR)
3760  {
3761  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_ERROR_FROM_SERVER, 1, "Cannot change server HA mode");
3762  (void) return_error_to_client (thread_p, rid);
3763  }
3764  else
3765  {
3766  /* it is good chance to call 'css_set_ha_num_of_hosts' */
3767  db = cfg_find_db (boot_db_name ());
3768  if (db != NULL)
3769  {
3771  cfg_free_directory (db);
3772  }
3773  }
3774  }
3775 
3776  state = css_ha_server_state ();
3777  or_pack_int (reply, (int) state);
3778  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3779 }
3780 
3781 /*
3782  * sboot_notify_ha_log_applier_state -
3783  */
3784 void
3785 sboot_notify_ha_log_applier_state (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3786 {
3787  int i, status;
3788  HA_LOG_APPLIER_STATE state;
3789  char *ptr;
3790  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3791  char *reply = OR_ALIGNED_BUF_START (a_reply);
3792 
3793  ptr = or_unpack_int (request, &i);
3794  state = (HA_LOG_APPLIER_STATE) i;
3795 
3797  {
3798  status = css_notify_ha_log_applier_state (thread_p, state);
3799  if (status != NO_ERROR)
3800  {
3801  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ERR_CSS_ERROR_FROM_SERVER, 1, "Error in log applier state");
3802  (void) return_error_to_client (thread_p, rid);
3803  }
3804  }
3805  else
3806  {
3807  status = ER_FAILED;
3808  }
3809  or_pack_int (reply, status);
3810  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3811 }
3812 
3813 /*
3814  * sqst_update_statistics -
3815  *
3816  * return:
3817  *
3818  * rid(in):
3819  * request(in):
3820  * reqlen(in):
3821  *
3822  * NOTE:
3823  */
3824 void
3825 sqst_update_statistics (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3826 {
3827  int error, with_fullscan;
3828  OID classoid;
3829  char *ptr;
3830  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3831  char *reply = OR_ALIGNED_BUF_START (a_reply);
3832 
3833  ptr = or_unpack_oid (request, &classoid);
3834  ptr = or_unpack_int (ptr, &with_fullscan);
3835 
3836  error = xstats_update_statistics (thread_p, &classoid, (with_fullscan ? STATS_WITH_FULLSCAN : STATS_WITH_SAMPLING));
3837  if (error != NO_ERROR)
3838  {
3839  (void) return_error_to_client (thread_p, rid);
3840  }
3841 
3842  (void) or_pack_errcode (reply, error);
3843  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3844 }
3845 
3846 /*
3847  * sqst_update_all_statistics -
3848  *
3849  * return:
3850  *
3851  * rid(in):
3852  * request(in):
3853  * reqlen(in):
3854  *
3855  * NOTE:
3856  */
3857 void
3858 sqst_update_all_statistics (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3859 {
3860  int error, with_fullscan;
3861  char *ptr;
3862  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
3863  char *reply = OR_ALIGNED_BUF_START (a_reply);
3864 
3865  ptr = or_unpack_int (request, &with_fullscan);
3866 
3867  error = xstats_update_all_statistics (thread_p, (with_fullscan ? STATS_WITH_FULLSCAN : STATS_WITH_SAMPLING));
3868  if (error != NO_ERROR)
3869  {
3870  (void) return_error_to_client (thread_p, rid);
3871  }
3872 
3873  (void) or_pack_errcode (reply, error);
3874  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3875 }
3876 
3877 /*
3878  * sbtree_add_index -
3879  *
3880  * return:
3881  *
3882  * rid(in):
3883  * request(in):
3884  * reqlen(in):
3885  *
3886  * NOTE:
3887  */
3888 void
3889 sbtree_add_index (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3890 {
3891  BTID btid;
3892  BTID *return_btid = NULL;
3893  TP_DOMAIN *key_type;
3894  OID class_oid;
3895  int attr_id, unique_pk;
3896  char *ptr;
3898  char *reply = OR_ALIGNED_BUF_START (a_reply);
3899 
3900  ptr = or_unpack_btid (request, &btid);
3901  ptr = or_unpack_domain (ptr, &key_type, 0);
3902  ptr = or_unpack_oid (ptr, &class_oid);
3903  ptr = or_unpack_int (ptr, &attr_id);
3904  ptr = or_unpack_int (ptr, &unique_pk);
3905 
3906  return_btid = xbtree_add_index (thread_p, &btid, key_type, &class_oid, attr_id, unique_pk, 0, 0, 0);
3907  if (return_btid == NULL)
3908  {
3909  (void) return_error_to_client (thread_p, rid);
3910  ptr = or_pack_int (reply, er_errid ());
3911  }
3912  else
3913  {
3914  ptr = or_pack_int (reply, NO_ERROR);
3915  }
3916  ptr = or_pack_btid (ptr, &btid);
3917  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
3918 }
3919 
3920 /*
3921  * sbtree_load_index -
3922  *
3923  * return:
3924  *
3925  * rid(in):
3926  * request(in):
3927  * reqlen(in):
3928  *
3929  * NOTE:
3930  */
3931 void
3932 sbtree_load_index (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
3933 {
3934  BTID btid;
3935  BTID *return_btid = NULL;
3936  OID *class_oids = NULL;
3937  HFID *hfids = NULL;
3938  int unique_pk, not_null_flag;
3939  OID fk_refcls_oid;
3940  BTID fk_refcls_pk_btid;
3941  char *bt_name, *fk_name;
3942  int n_classes, n_attrs, *attr_ids = NULL;
3943  int *attr_prefix_lengths = NULL;
3944  TP_DOMAIN *key_type;
3945  char *ptr;
3947  char *reply = OR_ALIGNED_BUF_START (a_reply);
3948  char *pred_stream = NULL;
3949  int pred_stream_size = 0, size = 0;
3950  int func_col_id = -1, expr_stream_size = 0, func_attr_index_start = -1;
3951  int index_info_type;
3952  char *expr_stream = NULL;
3953  int csserror;
3954  int index_status = 0;
3955  int ib_thread_count = 0;
3956 
3957  ptr = or_unpack_btid (request, &btid);
3958  ptr = or_unpack_string_nocopy (ptr, &bt_name);
3959  ptr = or_unpack_domain (ptr, &key_type, 0);
3960 
3961  ptr = or_unpack_int (ptr, &n_classes);
3962  ptr = or_unpack_int (ptr, &n_attrs);
3963 
3964  ptr = or_unpack_oid_array (ptr, n_classes, &class_oids);
3965  if (ptr == NULL)
3966  {
3967  (void) return_error_to_client (thread_p, rid);
3968  goto end;
3969  }
3970 
3971  ptr = or_unpack_int_array (ptr, (n_classes * n_attrs), &attr_ids);
3972  if (ptr == NULL)
3973  {
3974  (void) return_error_to_client (thread_p, rid);
3975  goto end;
3976  }
3977 
3978  if (n_classes == 1)
3979  {
3980  ptr = or_unpack_int_array (ptr, n_attrs, &attr_prefix_lengths);
3981  if (ptr == NULL)
3982  {
3983  (void) return_error_to_client (thread_p, rid);
3984  goto end;
3985  }
3986  }
3987 
3988  ptr = or_unpack_hfid_array (ptr, n_classes, &hfids);
3989  if (ptr == NULL)
3990  {
3991  (void) return_error_to_client (thread_p, rid);
3992  goto end;
3993  }
3994 
3995  ptr = or_unpack_int (ptr, &unique_pk);
3996  ptr = or_unpack_int (ptr, &not_null_flag);
3997 
3998  ptr = or_unpack_oid (ptr, &fk_refcls_oid);
3999  ptr = or_unpack_btid (ptr, &fk_refcls_pk_btid);
4000  ptr = or_unpack_string_nocopy (ptr, &fk_name);
4001  ptr = or_unpack_int (ptr, &index_info_type);
4002  switch (index_info_type)
4003  {
4004  case 0:
4005  ptr = or_unpack_int (ptr, &pred_stream_size);
4006  if (pred_stream_size > 0)
4007  {
4008  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, (char **) &pred_stream, &size);
4009  if (csserror)
4010  {
4012  css_send_abort_to_client (thread_p->conn_entry, rid);
4013  goto end;
4014  }
4015  }
4016  break;
4017 
4018  case 1:
4019  ptr = or_unpack_int (ptr, &expr_stream_size);
4020  ptr = or_unpack_int (ptr, &func_col_id);
4021  ptr = or_unpack_int (ptr, &func_attr_index_start);
4022 
4023  if (expr_stream_size > 0)
4024  {
4025  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, (char **) &expr_stream, &size);
4026  if (csserror)
4027  {
4029  css_send_abort_to_client (thread_p->conn_entry, rid);
4030  goto end;
4031  }
4032  }
4033 
4034  break;
4035  default:
4036  break;
4037  }
4038 
4039  ptr = or_unpack_int (ptr, &index_status); /* Get index status. */
4040  ptr = or_unpack_int (ptr, &ib_thread_count); /* Get thread count. */
4041 
4042  if (index_status == OR_ONLINE_INDEX_BUILDING_IN_PROGRESS)
4043  {
4044  return_btid =
4045  xbtree_load_online_index (thread_p, &btid, bt_name, key_type, class_oids, n_classes, n_attrs, attr_ids,
4046  attr_prefix_lengths, hfids, unique_pk, not_null_flag, &fk_refcls_oid,
4047  &fk_refcls_pk_btid, fk_name, pred_stream, pred_stream_size, expr_stream,
4048  expr_stream_size, func_col_id, func_attr_index_start, ib_thread_count);
4049  }
4050  else
4051  {
4052  return_btid =
4053  xbtree_load_index (thread_p, &btid, bt_name, key_type, class_oids, n_classes, n_attrs, attr_ids,
4054  attr_prefix_lengths, hfids, unique_pk, not_null_flag, &fk_refcls_oid, &fk_refcls_pk_btid,
4055  fk_name, pred_stream, pred_stream_size, expr_stream, expr_stream_size, func_col_id,
4056  func_attr_index_start);
4057  }
4058 
4059  if (return_btid == NULL)
4060  {
4061  (void) return_error_to_client (thread_p, rid);
4062  }
4063 
4064 end:
4065 
4066  int err;
4067 
4068  if (return_btid == NULL)
4069  {
4070  ASSERT_ERROR_AND_SET (err);
4071  ptr = or_pack_int (reply, err);
4072  }
4073  else
4074  {
4075  err = NO_ERROR;
4076  ptr = or_pack_int (reply, err);
4077  }
4078 
4079  if (index_status == OR_ONLINE_INDEX_BUILDING_IN_PROGRESS)
4080  {
4081  // it may not be really necessary. it just help things don't go worse that client keep caching ex-lock.
4082  int tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
4083  LOCK cls_lock = lock_get_object_lock (&class_oids[0], oid_Root_class_oid);
4084 
4085  // in case of shutdown, index loader might be interrupted and got error
4086  // otherwise, it should restore SCH_M_LOCK
4087  assert ((err != NO_ERROR && css_is_shutdowning_server ()) || cls_lock == SCH_M_LOCK);
4088  ptr = or_pack_int (ptr, (int) cls_lock);
4089  }
4090  else
4091  {
4092  ptr = or_pack_int (ptr, SCH_M_LOCK); // irrelevant
4093  }
4094 
4095  ptr = or_pack_btid (ptr, &btid);
4096  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
4097 
4098  if (class_oids != NULL)
4099  {
4100  db_private_free_and_init (thread_p, class_oids);
4101  }
4102 
4103  if (attr_ids != NULL)
4104  {
4105  db_private_free_and_init (thread_p, attr_ids);
4106  }
4107 
4108  if (attr_prefix_lengths != NULL)
4109  {
4110  db_private_free_and_init (thread_p, attr_prefix_lengths);
4111  }
4112 
4113  if (hfids != NULL)
4114  {
4115  db_private_free_and_init (thread_p, hfids);
4116  }
4117 
4118  if (expr_stream != NULL)
4119  {
4120  free_and_init (expr_stream);
4121  }
4122 
4123  if (pred_stream)
4124  {
4125  free_and_init (pred_stream);
4126  }
4127 }
4128 
4129 /*
4130  * sbtree_delete_index -
4131  *
4132  * return:
4133  *
4134  * rid(in):
4135  * request(in):
4136  * reqlen(in):
4137  *
4138  * NOTE:
4139  */
4140 void
4141 sbtree_delete_index (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4142 {
4143  BTID btid;
4144  int success;
4145  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4146  char *reply = OR_ALIGNED_BUF_START (a_reply);
4147 
4148  (void) or_unpack_btid (request, &btid);
4149 
4150  success = (xbtree_delete_index (thread_p, &btid) == NO_ERROR) ? NO_ERROR : ER_FAILED;
4151  if (success != NO_ERROR)
4152  {
4153  (void) return_error_to_client (thread_p, rid);
4154  }
4155 
4156  (void) or_pack_int (reply, (int) success);
4157  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
4158 }
4159 
4160 /*
4161  * slocator_remove_class_from_index -
4162  *
4163  * return:
4164  *
4165  * rid(in):
4166  * request(in):
4167  * reqlen(in):
4168  *
4169  * NOTE:
4170  */
4171 void
4172 slocator_remove_class_from_index (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4173 {
4174  OID oid;
4175  BTID btid;
4176  HFID hfid;
4177  int success;
4178  char *ptr;
4179  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4180  char *reply = OR_ALIGNED_BUF_START (a_reply);
4181 
4182  ptr = or_unpack_oid (request, &oid);
4183  ptr = or_unpack_btid (ptr, &btid);
4184  ptr = or_unpack_hfid (ptr, &hfid);
4185 
4186  success = (xlocator_remove_class_from_index (thread_p, &oid, &btid, &hfid) == NO_ERROR) ? NO_ERROR : ER_FAILED;
4187  if (success != NO_ERROR)
4188  {
4189  (void) return_error_to_client (thread_p, rid);
4190  }
4191 
4192  (void) or_pack_int (reply, (int) success);
4193  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
4194 }
4195 
4196 /*
4197  * sbtree_find_unique -
4198  *
4199  * return:
4200  *
4201  * rid(in):
4202  * request(in):
4203  * reqlen(in):
4204  *
4205  * NOTE:
4206  */
4207 void
4208 sbtree_find_unique (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4209 {
4210  sbtree_find_unique_internal (thread_p, rid, request, reqlen);
4211 }
4212 
4213 static void
4214 sbtree_find_unique_internal (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4215 {
4216  BTID btid;
4217  OID class_oid;
4218  OID oid;
4219  DB_VALUE key;
4220  char *ptr;
4221  int success;
4223  char *reply = OR_ALIGNED_BUF_START (a_reply);
4224 
4225  ptr = request;
4226  ptr = or_unpack_value (ptr, &key);
4227  ptr = or_unpack_oid (ptr, &class_oid);
4228  ptr = or_unpack_btid (ptr, &btid);
4229 
4230  OID_SET_NULL (&oid);
4231  success = xbtree_find_unique (thread_p, &btid, S_SELECT_WITH_LOCK, &key, &class_oid, &oid, false);
4232  if (success == BTREE_ERROR_OCCURRED)
4233  {
4234  (void) return_error_to_client (thread_p, rid);
4235  }
4236 
4237  /* free storage if the key was a string */
4238  pr_clear_value (&key);
4239 
4240  ptr = or_pack_int (reply, success);
4241  ptr = or_pack_oid (ptr, &oid);
4242  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
4243 }
4244 
4245 /*
4246  * sbtree_find_multi_uniques -
4247  *
4248  * return:
4249  *
4250  * rid(in):
4251  * request(in):
4252  * reqlen(in):
4253  *
4254  * NOTE:
4255  */
4256 void
4257 sbtree_find_multi_uniques (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4258 {
4259  OID class_oid;
4260  OR_ALIGNED_BUF (2 * OR_INT_SIZE) a_reply;
4261  char *ptr = NULL, *area = NULL;
4262  BTID *btids = NULL;
4263  DB_VALUE *keys = NULL;
4264  OID *oids = NULL;
4265  int count, needs_pruning, i, found = 0, area_size = 0;
4266  SCAN_OPERATION_TYPE op_type;
4267  int error = NO_ERROR;
4268  BTREE_SEARCH result = BTREE_KEY_FOUND;
4269 
4270  ptr = or_unpack_oid (request, &class_oid);
4271  ptr = or_unpack_int (ptr, &needs_pruning);
4272  ptr = or_unpack_int (ptr, &i);
4273  op_type = (SCAN_OPERATION_TYPE) i;
4274  ptr = or_unpack_int (ptr, &count);
4275 
4276  if (count <= 0)
4277  {
4278  assert_release (count > 0);
4279  error = ER_FAILED;
4280  goto cleanup;
4281  }
4282 
4283  btids = (BTID *) db_private_alloc (thread_p, count * sizeof (BTID));
4284  if (btids == NULL)
4285  {
4286  error = ER_FAILED;
4287  goto cleanup;
4288  }
4289  for (i = 0; i < count; i++)
4290  {
4291  ptr = or_unpack_btid (ptr, &btids[i]);
4292  }
4293  keys = (DB_VALUE *) db_private_alloc (thread_p, count * sizeof (DB_VALUE));
4294  if (keys == NULL)
4295  {
4296  error = ER_FAILED;
4297  goto cleanup;
4298  }
4299  for (i = 0; i < count; i++)
4300  {
4301  ptr = or_unpack_db_value (ptr, &keys[i]);
4302  }
4303  result = xbtree_find_multi_uniques (thread_p, &class_oid, needs_pruning, btids, keys, count, op_type, &oids, &found);
4304  if (result == BTREE_ERROR_OCCURRED)
4305  {
4306  error = ER_FAILED;
4307  goto cleanup;
4308  }
4309 
4310  /* start packing result */
4311  if (found > 0)
4312  {
4313  /* area size is (int:number of OIDs) + size of packed OIDs */
4314  area_size = OR_INT_SIZE + (found * sizeof (OID));
4315  area = (char *) db_private_alloc (thread_p, area_size);
4316  if (area == NULL)
4317  {
4318  error = ER_FAILED;
4319  goto cleanup;
4320  }
4321  ptr = or_pack_int (area, found);
4322  for (i = 0; i < found; i++)
4323  {
4324  ptr = or_pack_oid (ptr, &oids[i]);
4325  }
4326  }
4327  else
4328  {
4329  area_size = 0;
4330  area = NULL;
4331  }
4332 
4333  /* pack area size */
4334  ptr = or_pack_int (OR_ALIGNED_BUF_START (a_reply), area_size);
4335  /* pack error (should be NO_ERROR here) */
4336  ptr = or_pack_int (ptr, error);
4337 
4338  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply),
4339  OR_ALIGNED_BUF_SIZE (a_reply), area, area_size);
4340 
4341 cleanup:
4342  if (btids != NULL)
4343  {
4344  db_private_free (thread_p, btids);
4345  }
4346  if (keys != NULL)
4347  {
4348  for (i = 0; i < count; i++)
4349  {
4350  pr_clear_value (&keys[i]);
4351  }
4352  db_private_free (thread_p, keys);
4353  }
4354  if (oids != NULL)
4355  {
4356  db_private_free (thread_p, oids);
4357  }
4358  if (area != NULL)
4359  {
4360  db_private_free (thread_p, area);
4361  }
4362 
4363  if (error != NO_ERROR)
4364  {
4365  (void) return_error_to_client (thread_p, rid);
4366  ptr = or_pack_int (OR_ALIGNED_BUF_START (a_reply), 0);
4367  ptr = or_pack_int (ptr, error);
4368  ptr = or_pack_int (ptr, 0);
4369  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply),
4370  OR_ALIGNED_BUF_SIZE (a_reply), NULL, 0);
4371  }
4372 }
4373 
4374 /*
4375  * sbtree_class_test_unique -
4376  *
4377  * return:
4378  *
4379  * rid(in):
4380  * request(in):
4381  * reqlen(in):
4382  *
4383  * NOTE:
4384  */
4385 void
4386 sbtree_class_test_unique (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4387 {
4388  int success;
4389  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4390  char *reply = OR_ALIGNED_BUF_START (a_reply);
4391 
4392  success = xbtree_class_test_unique (thread_p, request, reqlen);
4393 
4394  if (success != NO_ERROR)
4395  {
4396  (void) return_error_to_client (thread_p, rid);
4397  }
4398 
4399  (void) or_pack_int (reply, (int) success);
4400  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
4401 }
4402 
4403 /*
4404  * sdk_totalpgs -
4405  *
4406  * return:
4407  *
4408  * rid(in):
4409  * request(in):
4410  * reqlen(in):
4411  *
4412  * NOTE:
4413  */
4414 void
4415 sdk_totalpgs (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4416 {
4417  DKNPAGES npages;
4418  VOLID volid;
4419  int int_volid;
4420  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4421  char *reply = OR_ALIGNED_BUF_START (a_reply);
4422 
4423  (void) or_unpack_int (request, &int_volid);
4424  volid = (VOLID) int_volid;
4425 
4426  npages = xdisk_get_total_numpages (thread_p, volid);
4427  if (npages < 0)
4428  {
4429  (void) return_error_to_client (thread_p, rid);
4430  }
4431 
4432  (void) or_pack_int (reply, npages);
4433  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
4434 }
4435 
4436 /*
4437  * sdk_freepgs -
4438  *
4439  * return:
4440  *
4441  * rid(in):
4442  * request(in):
4443  * reqlen(in):
4444  *
4445  * NOTE:
4446  */
4447 void
4448 sdk_freepgs (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4449 {
4450  DKNPAGES npages;
4451  VOLID volid;
4452  int int_volid;
4453  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4454  char *reply = OR_ALIGNED_BUF_START (a_reply);
4455 
4456  (void) or_unpack_int (request, &int_volid);
4457  volid = (VOLID) int_volid;
4458 
4459  npages = xdisk_get_free_numpages (thread_p, volid);
4460  if (npages < 0)
4461  {
4462  (void) return_error_to_client (thread_p, rid);
4463  }
4464 
4465  (void) or_pack_int (reply, npages);
4466  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
4467 }
4468 
4469 /*
4470  * sdk_remarks -
4471  *
4472  * return:
4473  *
4474  * rid(in):
4475  * request(in):
4476  * reqlen(in):
4477  *
4478  * NOTE:
4479  */
4480 void
4481 sdk_remarks (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4482 {
4483  int int_volid;
4484  char *remark;
4485  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4486  char *reply = OR_ALIGNED_BUF_START (a_reply);
4487  int area_length, strlen;
4488  char *area;
4489 
4490  (void) or_unpack_int (request, &int_volid);
4491 
4492  remark = xdisk_get_remarks (thread_p, (VOLID) int_volid);
4493  if (remark == NULL)
4494  {
4495  (void) return_error_to_client (thread_p, rid);
4496  area_length = 0;
4497  area = NULL;
4498  }
4499  else
4500  {
4501  area_length = or_packed_string_length (remark, &strlen);
4502  area = (char *) db_private_alloc (thread_p, area_length);
4503  if (area == NULL)
4504  {
4505  (void) return_error_to_client (thread_p, rid);
4506  area_length = 0;
4507  }
4508  else
4509  {
4510  (void) or_pack_string_with_length (area, remark, strlen);
4511  }
4512  }
4513 
4514  (void) or_pack_int (reply, area_length);
4515  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), area,
4516  area_length);
4517  if (remark != NULL)
4518  {
4519 
4520  /* since this was copied to the client, we don't need it on the server */
4521  free_and_init (remark);
4522  }
4523  if (area)
4524  {
4525  db_private_free_and_init (thread_p, area);
4526  }
4527 }
4528 
4529 /*
4530  * sdk_vlabel -
4531  *
4532  * return:
4533  *
4534  * rid(in):
4535  * request(in):
4536  * reqlen(in):
4537  *
4538  * NOTE:
4539  */
4540 void
4541 sdk_vlabel (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4542 {
4543  OR_ALIGNED_BUF (PATH_MAX) a_vol_fullname;
4544  char *vol_fullname = OR_ALIGNED_BUF_START (a_vol_fullname);
4545  int int_volid;
4546  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
4547  char *reply = OR_ALIGNED_BUF_START (a_reply);
4548  int area_length, strlen;
4549  char *area;
4550 
4551  (void) or_unpack_int (request, &int_volid);
4552 
4553  if (xdisk_get_fullname (thread_p, (VOLID) int_volid, vol_fullname) == NULL)
4554  {
4555  (void) return_error_to_client (thread_p, rid);
4556  area_length = 0;
4557  area = NULL;
4558  }
4559  else
4560  {
4561  area_length = or_packed_string_length (vol_fullname, &strlen);
4562  area = (char *) db_private_alloc (thread_p, area_length);
4563  if (area == NULL)
4564  {
4565  (void) return_error_to_client (thread_p, rid);
4566  area_length = 0;
4567  }
4568  else
4569  {
4570  (void) or_pack_string_with_length (area, vol_fullname, strlen);
4571  }
4572  }
4573 
4574  (void) or_pack_int (reply, area_length);
4575  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), area,
4576  area_length);
4577  if (area)
4578  {
4579  db_private_free_and_init (thread_p, area);
4580  }
4581 }
4582 
4583 /*
4584  * sqfile_get_list_file_page -
4585  *
4586  * return:
4587  *
4588  * rid(in):
4589  * request(in):
4590  * reqlen(in):
4591  *
4592  * NOTE:
4593  */
4594 void
4595 sqfile_get_list_file_page (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4596 {
4597  QUERY_ID query_id;
4598  int volid, pageid;
4599  char *ptr;
4600  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
4601  char *reply = OR_ALIGNED_BUF_START (a_reply);
4602  char page_buf[IO_MAX_PAGE_SIZE + MAX_ALIGNMENT], *aligned_page_buf;
4603  int page_size;
4604  int error = NO_ERROR;
4605 
4606  aligned_page_buf = PTR_ALIGN (page_buf, MAX_ALIGNMENT);
4607 
4608  ptr = or_unpack_ptr (request, &query_id);
4609  ptr = or_unpack_int (ptr, &volid);
4610  ptr = or_unpack_int (ptr, &pageid);
4611 
4612  if (volid == NULL_VOLID && pageid == NULL_PAGEID)
4613  {
4614  goto empty_page;
4615  }
4616 
4617  error = xqfile_get_list_file_page (thread_p, query_id, volid, pageid, aligned_page_buf, &page_size);
4618  if (error != NO_ERROR)
4619  {
4620  (void) return_error_to_client (thread_p, rid);
4621  goto empty_page;
4622  }
4623 
4624  if (page_size == 0)
4625  {
4626  goto empty_page;
4627  }
4628 
4629  ptr = or_pack_int (reply, page_size);
4630  ptr = or_pack_int (ptr, error);
4631  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), aligned_page_buf,
4632  page_size);
4633  return;
4634 
4635 empty_page:
4636  /* setup empty list file page and return it */
4637  qmgr_setup_empty_list_file (aligned_page_buf);
4638  page_size = QFILE_PAGE_HEADER_SIZE;
4639  ptr = or_pack_int (reply, page_size);
4640  ptr = or_pack_int (ptr, error);
4641  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), aligned_page_buf,
4642  page_size);
4643 }
4644 
4645 /*
4646  * sqmgr_prepare_query - Process a SERVER_QM_PREPARE request
4647  *
4648  * return:
4649  *
4650  * thrd(in):
4651  * rid(in):
4652  * request(in):
4653  * reqlen(in):
4654  *
4655  * NOTE:
4656  * Receive XASL stream and return XASL file id (QFILE_LIST_ID) as a result.
4657  * If xasl_buffer == NULL, the server will look up the XASL cache and then
4658  * return the cached XASL file id if found, otherwise return NULL QFILE_LIST_ID.
4659  * This function is a counter part to qmgr_prepare_query().
4660  */
4661 void
4662 sqmgr_prepare_query (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4663 {
4664  XASL_ID xasl_id;
4665  char *ptr = NULL;
4666  char *reply = NULL, *reply_buffer = NULL;
4667  int csserror, reply_buffer_size = 0, get_xasl_header = 0;
4668  int xasl_cache_pinned = 0, recompile_xasl_cache_pinned = 0;
4669  int recompile_xasl = 0;
4670  XASL_NODE_HEADER xasl_header;
4672  int error = NO_ERROR;
4673  COMPILE_CONTEXT context = { NULL, NULL, 0, NULL, NULL, 0, false, false, false, SHA1_HASH_INITIALIZER };
4674  XASL_STREAM stream = { NULL, NULL, NULL, 0 };
4675  bool was_recompile_xasl = false;
4676  bool force_recompile = false;
4677 
4678  reply = OR_ALIGNED_BUF_START (a_reply);
4679 
4680  /* unpack query alias string from the request data */
4681  ptr = or_unpack_string_nocopy (request, &context.sql_hash_text);
4682 
4683  /* unpack query plan from the request data */
4684  ptr = or_unpack_string_nocopy (ptr, &context.sql_plan_text);
4685 
4686  /* unpack query string from the request data */
4687  ptr = or_unpack_string_nocopy (ptr, &context.sql_user_text);
4688 
4689  /* unpack size of XASL stream */
4690  ptr = or_unpack_int (ptr, &stream.buffer_size);
4691  /* unpack get XASL node header boolean */
4692  ptr = or_unpack_int (ptr, &get_xasl_header);
4693  /* unpack pinned xasl cache flag boolean */
4694  ptr = or_unpack_int (ptr, &xasl_cache_pinned);
4695  context.is_xasl_pinned_reference = (bool) xasl_cache_pinned;
4696  /* unpack recompile flag boolean */
4697  ptr = or_unpack_int (ptr, &recompile_xasl_cache_pinned);
4698  context.recompile_xasl_pinned = (bool) recompile_xasl_cache_pinned;
4699  /* unpack recompile_xasl flag boolean */
4700  ptr = or_unpack_int (ptr, &recompile_xasl);
4701  context.recompile_xasl = (bool) recompile_xasl;
4702  /* unpack sha1 */
4703  ptr = or_unpack_sha1 (ptr, &context.sha1);
4704 
4705  if (get_xasl_header)
4706  {
4707  /* need to get XASL node header */
4708  stream.xasl_header = &xasl_header;
4710  }
4711 
4712  if (stream.buffer_size > 0)
4713  {
4714  /* receive XASL stream from the client */
4715  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &stream.buffer, &stream.buffer_size);
4716  if (csserror)
4717  {
4719  css_send_abort_to_client (thread_p->conn_entry, rid);
4720  if (stream.buffer)
4721  free_and_init (stream.buffer);
4722  return;
4723  }
4724  }
4725 
4726  /* call the server routine of query prepare */
4727  stream.xasl_id = &xasl_id;
4728  XASL_ID_SET_NULL (stream.xasl_id);
4729 
4730  /* Force recompile must be set to true if client did not intend to recompile, but must reconsider. This can happen
4731  * if recompile threshold is checked and if one of the related classes suffered significant changes to justify the
4732  * recompiling.
4733  * If client already means to recompile, force_recompile is not required.
4734  * xqmgr_prepare_query will change context.recompile_xasl if force recompile is required.
4735  */
4736  was_recompile_xasl = context.recompile_xasl;
4737 
4738  error = xqmgr_prepare_query (thread_p, &context, &stream);
4739  if (stream.buffer)
4740  {
4741  free_and_init (stream.buffer);
4742  }
4743  if (error != NO_ERROR)
4744  {
4745  ASSERT_ERROR ();
4746  (void) return_error_to_client (thread_p, rid);
4747 
4748  ptr = or_pack_int (reply, 0);
4749  ptr = or_pack_int (ptr, error);
4750  }
4751  else
4752  {
4753  /* Check if we need to force client to recompile. */
4754  force_recompile = !was_recompile_xasl && context.recompile_xasl;
4755  if (stream.xasl_id != NULL && !XASL_ID_IS_NULL (stream.xasl_id) && (get_xasl_header || force_recompile))
4756  {
4757  /* pack XASL node header */
4758  reply_buffer_size = get_xasl_header ? XASL_NODE_HEADER_SIZE : 0;
4759  reply_buffer_size += force_recompile ? OR_INT_SIZE : 0;
4760  assert (reply_buffer_size > 0);
4761 
4762  reply_buffer = (char *) malloc (reply_buffer_size);
4763  if (reply_buffer == NULL)
4764  {
4765  reply_buffer_size = 0;
4766  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) reply_buffer_size);
4767  error = ER_OUT_OF_VIRTUAL_MEMORY;
4768  }
4769  else
4770  {
4771  ptr = reply_buffer;
4772  if (get_xasl_header)
4773  {
4774  OR_PACK_XASL_NODE_HEADER (ptr, stream.xasl_header);
4775  }
4776  if (force_recompile)
4777  {
4778  /* Doesn't really matter what we pack... */
4779  ptr = or_pack_int (ptr, 1);
4780  }
4781  }
4782  }
4783 
4784  ptr = or_pack_int (reply, reply_buffer_size);
4785  ptr = or_pack_int (ptr, NO_ERROR);
4786  /* pack XASL file id as a reply */
4787  OR_PACK_XASL_ID (ptr, stream.xasl_id);
4788  }
4789 
4790  /* send reply and data to the client */
4791  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), reply_buffer,
4792  reply_buffer_size);
4793 
4794  if (reply_buffer != NULL)
4795  {
4796  free_and_init (reply_buffer);
4797  }
4798 }
4799 
4800 /*
4801  * stran_can_end_after_query_execution - Check whether can end transaction after query execution.
4802  *
4803  * return:error code
4804  *
4805  * thread_p(in): thread entry
4806  * query_flag(in): query flag
4807  * list_id(in): list id
4808  * can_end_transaction(out): true, if transaction can be safely ended
4809  *
4810  */
4811 STATIC_INLINE int
4812 stran_can_end_after_query_execution (THREAD_ENTRY * thread_p, int query_flag, QFILE_LIST_ID * list_id,
4813  bool * can_end_transaction)
4814 {
4815  QFILE_LIST_SCAN_ID scan_id;
4816  QFILE_TUPLE_RECORD tuple_record = { NULL, 0 };
4817  SCAN_CODE qp_scan;
4818  OR_BUF buf;
4819  TP_DOMAIN **domains;
4820  PR_TYPE *pr_type;
4821  int i, flag, compressed_size = 0, decompressed_size = 0, diff_size, val_length;
4822  char *tuple_p;
4823  bool found_compressible_string_domain, exceed_a_page;
4824 
4825  assert (list_id != NULL && list_id->type_list.domp != NULL && can_end_transaction != NULL);
4826 
4827  *can_end_transaction = false;
4828 
4829  if (list_id->page_cnt != 1)
4830  {
4831  /* Needs fetch request. Do not allow ending transaction. */
4832  return NO_ERROR;
4833  }
4834 
4835  if (list_id->last_offset >= QEWC_MAX_DATA_SIZE)
4836  {
4837  /* Needs fetch request. Do not allow ending transaction. */
4838  return NO_ERROR;
4839  }
4840 
4841  if (query_flag & RESULT_HOLDABLE)
4842  {
4843  /* Holdable result, do not check for compression. */
4844  *can_end_transaction = true;
4845  return NO_ERROR;
4846  }
4847 
4848  domains = list_id->type_list.domp;
4849  found_compressible_string_domain = false;
4850  for (i = 0; i < list_id->type_list.type_cnt; i++)
4851  {
4852  pr_type = domains[i]->type;
4853  assert (pr_type != NULL);
4854 
4855  if (pr_type->id == DB_TYPE_VARCHAR || pr_type->id == DB_TYPE_VARNCHAR)
4856  {
4857  found_compressible_string_domain = true;
4858  break;
4859  }
4860  }
4861 
4862  if (!found_compressible_string_domain)
4863  {
4864  /* Not compressible domains, do not check for compression. */
4865  *can_end_transaction = true;
4866  return NO_ERROR;
4867  }
4868 
4869  if (qfile_open_list_scan (list_id, &scan_id) != NO_ERROR)
4870  {
4871  return ER_FAILED;
4872  }
4873 
4874  /* Estimates the data and header information. */
4875  diff_size = 0;
4876  exceed_a_page = false;
4877  while (!exceed_a_page)
4878  {
4879  qp_scan = qfile_scan_list_next (thread_p, &scan_id, &tuple_record, PEEK);
4880  if (qp_scan != S_SUCCESS)
4881  {
4882  break;
4883  }
4884 
4885  tuple_p = tuple_record.tpl;
4886  or_init (&buf, tuple_p, QFILE_GET_TUPLE_LENGTH (tuple_p));
4887  tuple_p += QFILE_TUPLE_LENGTH_SIZE;
4888  for (i = 0; i < list_id->type_list.type_cnt; i++)
4889  {
4890  flag = QFILE_GET_TUPLE_VALUE_FLAG (tuple_p);
4891  val_length = QFILE_GET_TUPLE_VALUE_LENGTH (tuple_p);
4892  tuple_p += QFILE_TUPLE_VALUE_HEADER_SIZE;
4893 
4894  pr_type = domains[i]->type;
4895  if (flag != V_UNBOUND && (pr_type->id == DB_TYPE_VARCHAR || pr_type->id == DB_TYPE_VARNCHAR))
4896  {
4897  buf.ptr = tuple_p;
4898  or_get_varchar_compression_lengths (&buf, &compressed_size, &decompressed_size);
4899  if (compressed_size != 0)
4900  {
4901  /* Compression used. */
4902  diff_size += decompressed_size - compressed_size;
4903  if (list_id->last_offset + diff_size >= QEWC_MAX_DATA_SIZE)
4904  {
4905  /* Needs fetch request. Do not allow ending transaction. */
4906  exceed_a_page = true;
4907  break;
4908  }
4909  }
4910  }
4911 
4912  tuple_p += val_length;
4913  }
4914  }
4915 
4916  qfile_close_scan (thread_p, &scan_id);
4917 
4918  if (qp_scan == S_ERROR)
4919  {
4920  // might be interrupted
4921  return ER_FAILED;
4922  }
4923 
4924  *can_end_transaction = !exceed_a_page;
4925 
4926  return NO_ERROR;
4927 }
4928 
4929 /*
4930  * sqmgr_execute_query - Process a SERVER_QM_EXECUTE request
4931  *
4932  * return:error or no error
4933  *
4934  * thrd(in):
4935  * rid(in):
4936  * request(in):
4937  * reqlen(in):
4938  *
4939  * NOTE:
4940  * Receive XASL file id and parameter values if exist and return list file id
4941  * that contains query result. If an error occurs, return NULL QFILE_LIST_ID.
4942  * This function is a counter part to qmgr_execute_query().
4943  */
4944 void
4945 sqmgr_execute_query (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
4946 {
4947  XASL_ID xasl_id;
4948  QFILE_LIST_ID *list_id;
4949  int csserror, dbval_cnt, data_size, replydata_size, page_size;
4950  QUERY_ID query_id = NULL_QUERY_ID;
4951  char *ptr, *data = NULL, *reply, *replydata = NULL;
4952  PAGE_PTR page_ptr;
4953  char page_buf[IO_MAX_PAGE_SIZE + MAX_ALIGNMENT], *aligned_page_buf;
4954  QUERY_FLAG query_flag;
4956  CACHE_TIME clt_cache_time;
4957  CACHE_TIME srv_cache_time;
4958  int query_timeout;
4959  XASL_CACHE_ENTRY *xasl_cache_entry_p = NULL;
4960  char data_buf[EXECUTE_QUERY_MAX_ARGUMENT_DATA_SIZE + MAX_ALIGNMENT], *aligned_data_buf = NULL;
4961  bool has_updated;
4962 
4963  int response_time = 0;
4964 
4965  TSC_TICKS start_tick, end_tick;
4966  TSCTIMEVAL tv_diff;
4967 
4968  int queryinfo_string_length = 0;
4969  char queryinfo_string[QUERY_INFO_BUF_SIZE];
4970 
4971  UINT64 *base_stats = NULL;
4972  UINT64 *current_stats = NULL;
4973  UINT64 *diff_stats = NULL;
4974  char *sql_id = NULL;
4975  int error_code = NO_ERROR, all_error_code = NO_ERROR;
4976  int trace_slow_msec, trace_ioreads;
4977  bool tran_abort = false, has_xasl_entry = false;
4978 
4979  EXECUTION_INFO info = { NULL, NULL, NULL };
4980  QUERY_ID net_Deferred_end_queries[NET_DEFER_END_QUERIES_MAX], *p_net_Deferred_end_queries = net_Deferred_end_queries;
4981  int n_query_ids = 0, i = 0;
4982  bool end_query_allowed, should_conn_reset;
4983  LOG_TDES *tdes;
4984  TRAN_STATE tran_state;
4985  bool is_tran_auto_commit;
4986 
4989 
4990  if (trace_slow_msec >= 0 || trace_ioreads > 0)
4991  {
4992  perfmon_start_watch (thread_p);
4993 
4994  base_stats = perfmon_allocate_values ();
4995  if (base_stats == NULL)
4996  {
4997  css_send_abort_to_client (thread_p->conn_entry, rid);
4998  return;
4999  }
5000  xperfmon_server_copy_stats (thread_p, base_stats);
5001 
5002  tsc_getticks (&start_tick);
5003 
5004  if (trace_slow_msec >= 0)
5005  {
5006  thread_p->event_stats.trace_slow_query = true;
5007  }
5008  }
5009 
5010  aligned_page_buf = PTR_ALIGN (page_buf, MAX_ALIGNMENT);
5011 
5012  reply = OR_ALIGNED_BUF_START (a_reply);
5013 
5014  /* unpack XASL file id (XASL_ID), number of parameter values, size of the recieved data, and query execution mode
5015  * flag from the request data */
5016  ptr = request;
5017  OR_UNPACK_XASL_ID (ptr, &xasl_id);
5018  ptr = or_unpack_int (ptr, &dbval_cnt);
5019  ptr = or_unpack_int (ptr, &data_size);
5020  ptr = or_unpack_int (ptr, &query_flag);
5021  OR_UNPACK_CACHE_TIME (ptr, &clt_cache_time);
5022  ptr = or_unpack_int (ptr, &query_timeout);
5023 
5024  is_tran_auto_commit = IS_TRAN_AUTO_COMMIT (query_flag);
5025  xsession_set_tran_auto_commit (thread_p, is_tran_auto_commit);
5026 
5027  if (IS_QUERY_EXECUTE_WITH_COMMIT (query_flag))
5028  {
5029  ptr = or_unpack_int (ptr, &n_query_ids);
5030  if (n_query_ids + 1 > NET_DEFER_END_QUERIES_MAX)
5031  {
5032  p_net_Deferred_end_queries = (QUERY_ID *) malloc ((n_query_ids + 1) * sizeof (QUERY_ID));
5033  if (p_net_Deferred_end_queries == NULL)
5034  {
5036  (size_t) (n_query_ids + 1) * sizeof (QUERY_ID));
5037  css_send_abort_to_client (thread_p->conn_entry, rid);
5038  return;
5039  }
5040  }
5041 
5042  for (i = 0; i < n_query_ids; i++)
5043  {
5044  ptr = or_unpack_ptr (ptr, p_net_Deferred_end_queries + i);
5045  }
5046  }
5047 
5048  if (IS_QUERY_EXECUTED_WITHOUT_DATA_BUFFERS (query_flag))
5049  {
5051  aligned_data_buf = PTR_ALIGN (data_buf, MAX_ALIGNMENT);
5052  data = aligned_data_buf;
5053  memcpy (data, ptr, data_size);
5054  }
5055  else if (0 < dbval_cnt)
5056  {
5057  /* receive parameter values (DB_VALUE) from the client */
5058  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &data, &data_size);
5059  if (csserror || data == NULL)
5060  {
5062  css_send_abort_to_client (thread_p->conn_entry, rid);
5063  if (data)
5064  {
5065  free_and_init (data);
5066  }
5067  return; /* error */
5068  }
5069  }
5070 
5071  CACHE_TIME_RESET (&srv_cache_time);
5072 
5073  /* call the server routine of query execute */
5074  list_id = xqmgr_execute_query (thread_p, &xasl_id, &query_id, dbval_cnt, data, &query_flag, &clt_cache_time,
5075  &srv_cache_time, query_timeout, &xasl_cache_entry_p);
5076 
5077  if (data != NULL && data != aligned_data_buf)
5078  {
5079  free_and_init (data);
5080  }
5081 
5082  if (xasl_cache_entry_p != NULL)
5083  {
5084  info = xasl_cache_entry_p->sql_info;
5085  }
5086 
5087  end_query_allowed = IS_QUERY_EXECUTE_WITH_COMMIT (query_flag);
5088  tdes = LOG_FIND_CURRENT_TDES (thread_p);
5089  tran_state = tdes->state;
5090  has_updated = false;
5091 
5092 null_list:
5093  if (list_id == NULL && !CACHE_TIME_EQ (&clt_cache_time, &srv_cache_time))
5094  {
5095  ASSERT_ERROR_AND_SET (error_code);
5096 
5097  if (error_code != NO_ERROR)
5098  {
5099  if (info.sql_hash_text != NULL)
5100  {
5101  if (qmgr_get_sql_id (thread_p, &sql_id, info.sql_hash_text, strlen (info.sql_hash_text)) != NO_ERROR)
5102  {
5103  sql_id = NULL;
5104  }
5105  }
5106 
5107  if (error_code != ER_QPROC_XASLNODE_RECOMPILE_REQUESTED)
5108  {
5110  sql_id ? sql_id : "(UNKNOWN SQL_ID)",
5111  info.sql_user_text ? info.sql_user_text : "(UNKNOWN USER_TEXT)");
5112  }
5113 
5114  if (sql_id != NULL)
5115  {
5116  free_and_init (sql_id);
5117  }
5118  }
5119 
5120  tran_abort = need_to_abort_tran (thread_p, &error_code);
5121  if (tran_abort)
5122  {
5123  if (xasl_cache_entry_p != NULL)
5124  {
5125  /* Remove transaction id from xasl cache entry before return_error_to_client, where current transaction
5126  * may be aborted. Otherwise, another transaction may be resumed and xasl_cache_entry_p may be removed by
5127  * that transaction, during class deletion. */
5128  has_xasl_entry = true;
5129  xcache_unfix (thread_p, xasl_cache_entry_p);
5130  xasl_cache_entry_p = NULL;
5131  }
5132  }
5133 
5134  if (IS_QUERY_EXECUTE_WITH_COMMIT (query_flag))
5135  {
5136  /* Get has update before aborting transaction. */
5137  has_updated = logtb_has_updated (thread_p);
5138  }
5139 
5140  tran_state = return_error_to_client (thread_p, rid);
5141  }
5142 
5143  page_size = 0;
5144  page_ptr = NULL;
5145  if (list_id != NULL)
5146  {
5147  /* get the first page of the list file */
5148  if (VPID_ISNULL (&(list_id->first_vpid)))
5149  {
5150  // Note that not all list files have a page, for instance, insert.
5151  page_ptr = NULL;
5152  }
5153  else
5154  {
5155  page_ptr = qmgr_get_old_page (thread_p, &(list_id->first_vpid), list_id->tfile_vfid);
5156 
5157  if (page_ptr != NULL)
5158  {
5159  /* calculate page size */
5160  if (QFILE_GET_TUPLE_COUNT (page_ptr) == -2 || QFILE_GET_OVERFLOW_PAGE_ID (page_ptr) != NULL_PAGEID)
5161  {
5162  page_size = DB_PAGESIZE;
5163  }
5164  else
5165  {
5166  int offset = QFILE_GET_LAST_TUPLE_OFFSET (page_ptr);
5167 
5168  page_size = (offset + QFILE_GET_TUPLE_LENGTH (page_ptr + offset));
5169  }
5170 
5171  memcpy (aligned_page_buf, page_ptr, page_size);
5172  qmgr_free_old_page_and_init (thread_p, page_ptr, list_id->tfile_vfid);
5173  page_ptr = aligned_page_buf;
5174 
5175  /* for now, allow end query if there is only one page and more ... */
5176  if (stran_can_end_after_query_execution (thread_p, query_flag, list_id, &end_query_allowed) != NO_ERROR)
5177  {
5178  (void) return_error_to_client (thread_p, rid);
5179  }
5180 
5181  // When !end_query_allowed, it means this execution request is followed by fetch request(s).
5182  }
5183  else
5184  {
5185  // might be interrupted to fetch query result
5186  ASSERT_ERROR ();
5187  QFILE_FREE_AND_INIT_LIST_ID (list_id);
5188 
5189  goto null_list;
5190  }
5191  }
5192  }
5193 
5194  replydata_size = list_id ? or_listid_length (list_id) : 0;
5195  if (0 < replydata_size)
5196  {
5197  /* pack list file id as a reply data */
5198  replydata = (char *) db_private_alloc (thread_p, replydata_size);
5199  if (replydata != NULL)
5200  {
5201  (void) or_pack_listid (replydata, list_id);
5202  }
5203  else
5204  {
5205  replydata_size = 0;
5206  (void) return_error_to_client (thread_p, rid);
5207  }
5208  }
5209 
5210  /* We may release the xasl cache entry when the transaction aborted. To refer the contents of the freed entry for
5211  * the case will cause defects. */
5212  if (tran_abort == false)
5213  {
5214  if (trace_slow_msec >= 0 || trace_ioreads > 0)
5215  {
5216  tsc_getticks (&end_tick);
5217  tsc_elapsed_time_usec (&tv_diff, end_tick, start_tick);
5218  response_time = (tv_diff.tv_sec * 1000) + (tv_diff.tv_usec / 1000);
5219 
5220  if (base_stats == NULL)
5221  {
5222  base_stats = perfmon_allocate_values ();
5223  if (base_stats == NULL)
5224  {
5225  css_send_abort_to_client (thread_p->conn_entry, rid);
5226  return;
5227  }
5228  }
5229 
5230  current_stats = perfmon_allocate_values ();
5231  if (current_stats == NULL)
5232  {
5233  css_send_abort_to_client (thread_p->conn_entry, rid);
5234  goto exit;
5235  }
5236  diff_stats = perfmon_allocate_values ();
5237  if (diff_stats == NULL)
5238  {
5239  css_send_abort_to_client (thread_p->conn_entry, rid);
5240  goto exit;
5241  }
5242 
5243  xperfmon_server_copy_stats (thread_p, current_stats);
5244  perfmon_calc_diff_stats (diff_stats, current_stats, base_stats);
5245 
5246  if (response_time >= trace_slow_msec)
5247  {
5248  queryinfo_string_length =
5249  er_log_slow_query (thread_p, &info, response_time, diff_stats, queryinfo_string);
5250  event_log_slow_query (thread_p, &info, response_time, diff_stats);
5251  }
5252 
5253  if (trace_ioreads > 0
5254  && diff_stats[pstat_Metadata[PSTAT_PB_NUM_IOREADS].start_offset] >= (UINT64) trace_ioreads)
5255  {
5256  event_log_many_ioreads (thread_p, &info, response_time, diff_stats);
5257  }
5258 
5259  perfmon_stop_watch (thread_p);
5260  }
5261 
5262  if (thread_p->event_stats.temp_expand_pages > 0)
5263  {
5264  event_log_temp_expand_pages (thread_p, &info);
5265  }
5266  }
5267 
5268  if (xasl_cache_entry_p != NULL)
5269  {
5270  has_xasl_entry = true;
5271  xcache_unfix (thread_p, xasl_cache_entry_p);
5272  xasl_cache_entry_p = NULL;
5273  }
5274 
5275  /* pack 'QUERY_END' as a first argument of the reply */
5276  ptr = or_pack_int (reply, QUERY_END);
5277  /* pack size of list file id to return as a second argument of the reply */
5278  ptr = or_pack_int (ptr, replydata_size);
5279  /* pack size of a page to return as a third argumnet of the reply */
5280  ptr = or_pack_int (ptr, page_size);
5281  ptr = or_pack_int (ptr, queryinfo_string_length);
5282 
5283  /* query id to return as a fourth argument of the reply */
5284  ptr = or_pack_ptr (ptr, query_id);
5285  /* result cache created time */
5286  OR_PACK_CACHE_TIME (ptr, &srv_cache_time);
5287 
5288  if (IS_QUERY_EXECUTE_WITH_COMMIT (query_flag))
5289  {
5290  /* Try to end transaction and pack the result. */
5291  p_net_Deferred_end_queries[n_query_ids++] = query_id;
5292  if (error_code != NO_ERROR)
5293  {
5294  if (error_code != ER_INTERRUPTED && has_xasl_entry)
5295  {
5296  tran_abort = true;
5297  assert (end_query_allowed == true);
5298  }
5299  else
5300  {
5301  /* Do not abort the transaction, since XASL cache does not exists, so other fetch may be requested.
5302  * Or, the execution was interrupted.
5303  */
5304  end_query_allowed = false;
5305  }
5306  }
5307 
5308  stran_server_auto_commit_or_abort (thread_p, rid, p_net_Deferred_end_queries, n_query_ids,
5309  tran_abort, has_updated, &end_query_allowed, &tran_state, &should_conn_reset);
5310  /* pack end query result */
5311  if (end_query_allowed == true)
5312  {
5313  /* query ended */
5314  ptr = or_pack_int (ptr, NO_ERROR);
5315  }
5316  else
5317  {
5318  /* query not ended */
5319  ptr = or_pack_int (ptr, !NO_ERROR);
5320  }
5321 
5322  /* pack commit/abart/active result */
5323  ptr = or_pack_int (ptr, (int) tran_state);
5324  ptr = or_pack_int (ptr, (int) should_conn_reset);
5325  }
5326 
5327 #if !defined(NDEBUG)
5328  /* suppress valgrind UMW error */
5329  memset (ptr, 0, OR_ALIGNED_BUF_SIZE (a_reply) - (ptr - reply));
5330 #endif
5331 
5332  css_send_reply_and_3_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), replydata,
5333  replydata_size, page_ptr, page_size, queryinfo_string, queryinfo_string_length);
5334 
5335  /* free QFILE_LIST_ID duplicated by xqmgr_execute_query() */
5336  if (replydata != NULL)
5337  {
5338  db_private_free_and_init (thread_p, replydata);
5339  }
5340  if (list_id != NULL)
5341  {
5342  QFILE_FREE_AND_INIT_LIST_ID (list_id);
5343  }
5344 
5345 exit:
5346  if (p_net_Deferred_end_queries != net_Deferred_end_queries)
5347  {
5348  free_and_init (p_net_Deferred_end_queries);
5349  }
5350  if (base_stats != NULL)
5351  {
5352  free_and_init (base_stats);
5353  }
5354  if (current_stats != NULL)
5355  {
5356  free_and_init (current_stats);
5357  }
5358  if (diff_stats != NULL)
5359  {
5360  free_and_init (diff_stats);
5361  }
5362 }
5363 
5364 /*
5365  * er_log_slow_query - log slow query to error log file
5366  * return:
5367  * thread_p(in):
5368  * info(in):
5369  * time(in):
5370  * diff_stats(in):
5371  * queryinfo_string(out):
5372  */
5373 static int
5374 er_log_slow_query (THREAD_ENTRY * thread_p, EXECUTION_INFO * info, int time, UINT64 * diff_stats,
5375  char *queryinfo_string)
5376 {
5377  char stat_buf[STATDUMP_BUF_SIZE];
5378  char *sql_id;
5379  int queryinfo_string_length;
5380  const char *line = "--------------------------------------------------------------------------------";
5381  const char *title = "Operation";
5382 
5384  {
5386  }
5387  else
5388  {
5389  info->sql_plan_text = NULL;
5390  stat_buf[0] = '\0';
5391  }
5392 
5393  if (info->sql_hash_text == NULL
5394  || qmgr_get_sql_id (thread_p, &sql_id, info->sql_hash_text, strlen (info->sql_hash_text)) != NO_ERROR)
5395  {
5396  sql_id = NULL;
5397  }
5398 
5399  queryinfo_string_length =
5400  snprintf (queryinfo_string, QUERY_INFO_BUF_SIZE, "%s\n%s\n%s\n %s\n\n /* SQL_ID: %s */ %s%s \n\n%s\n%s\n", line,
5401  title, line, info->sql_user_text ? info->sql_user_text : "(UNKNOWN USER_TEXT)",
5402  sql_id ? sql_id : "(UNKNOWN SQL_ID)", info->sql_hash_text ? info->sql_hash_text : "(UNKNOWN HASH_TEXT)",
5403  info->sql_plan_text ? info->sql_plan_text : "", stat_buf, line);
5404 
5405  if (sql_id != NULL)
5406  {
5407  free (sql_id);
5408  }
5409 
5410  if (queryinfo_string_length >= QUERY_INFO_BUF_SIZE)
5411  {
5412  /* string is truncated */
5413  queryinfo_string_length = QUERY_INFO_BUF_SIZE - 1;
5414  queryinfo_string[queryinfo_string_length] = '\0';
5415  }
5416 
5417  er_set (ER_NOTIFICATION_SEVERITY, ARG_FILE_LINE, ER_SLOW_QUERY, 2, time, queryinfo_string);
5418 
5419  return queryinfo_string_length;
5420 }
5421 
5422 /*
5423  * event_log_slow_query - log slow query to event log file
5424  * return:
5425  * thread_p(in):
5426  * info(in):
5427  * time(in):
5428  * diff_stats(in):
5429  * num_bind_vals(in):
5430  * bind_vals(in):
5431  */
5432 static void
5433 event_log_slow_query (THREAD_ENTRY * thread_p, EXECUTION_INFO * info, int time, UINT64 * diff_stats)
5434 {
5435  FILE *log_fp;
5436  int indent = 2;
5437  LOG_TDES *tdes;
5438  int tran_index;
5439 
5440  tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
5441  tdes = LOG_FIND_TDES (tran_index);
5442  log_fp = event_log_start (thread_p, "SLOW_QUERY");
5443 
5444  if (tdes == NULL || log_fp == NULL)
5445  {
5446  return;
5447  }
5448 
5449  event_log_print_client_info (tran_index, indent);
5450  fprintf (log_fp, "%*csql: %s\n", indent, ' ', info->sql_hash_text ? info->sql_hash_text : "(UNKNOWN HASH_TEXT)");
5451 
5453  {
5454  event_log_bind_values (thread_p, log_fp, tran_index, tdes->num_exec_queries - 1);
5455  }
5456 
5457  fprintf (log_fp, "%*ctime: %d\n", indent, ' ', time);
5458  fprintf (log_fp, "%*cbuffer: fetch=%lld, ioread=%lld, iowrite=%lld\n", indent, ' ',
5459  (long long int) diff_stats[pstat_Metadata[PSTAT_PB_NUM_FETCHES].start_offset],
5460  (long long int) diff_stats[pstat_Metadata[PSTAT_PB_NUM_IOREADS].start_offset],
5461  (long long int) diff_stats[pstat_Metadata[PSTAT_PB_NUM_IOWRITES].start_offset]);
5462  fprintf (log_fp, "%*cwait: cs=%d, lock=%d, latch=%d\n\n", indent, ' ', TO_MSEC (thread_p->event_stats.cs_waits),
5463  TO_MSEC (thread_p->event_stats.lock_waits), TO_MSEC (thread_p->event_stats.latch_waits));
5464 
5465  event_log_end (thread_p);
5466 }
5467 
5468 /*
5469  * event_log_many_ioreads - log many ioreads to event log file
5470  * return:
5471  * thread_p(in):
5472  * info(in):
5473  * time(in):
5474  * diff_stats(in):
5475  * num_bind_vals(in):
5476  * bind_vals(in):
5477  */
5478 static void
5479 event_log_many_ioreads (THREAD_ENTRY * thread_p, EXECUTION_INFO * info, int time, UINT64 * diff_stats)
5480 {
5481  FILE *log_fp;
5482  int indent = 2;
5483  LOG_TDES *tdes;
5484  int tran_index;
5485 
5486  tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
5487  tdes = LOG_FIND_TDES (tran_index);
5488  log_fp = event_log_start (thread_p, "MANY_IOREADS");
5489 
5490  if (tdes == NULL || log_fp == NULL)
5491  {
5492  return;
5493  }
5494 
5495  event_log_print_client_info (tran_index, indent);
5496  fprintf (log_fp, "%*csql: %s\n", indent, ' ', info->sql_hash_text ? info->sql_hash_text : "(UNKNOWN HASH_TEXT)");
5497 
5499  {
5500  event_log_bind_values (thread_p, log_fp, tran_index, tdes->num_exec_queries - 1);
5501  }
5502 
5503  fprintf (log_fp, "%*ctime: %d\n", indent, ' ', time);
5504  fprintf (log_fp, "%*cioreads: %lld\n\n", indent, ' ',
5505  (long long int) diff_stats[pstat_Metadata[PSTAT_PB_NUM_IOREADS].start_offset]);
5506 
5507  event_log_end (thread_p);
5508 }
5509 
5510 /*
5511  * event_log_temp_expand_pages - log temp volume expand pages to event log file
5512  * return:
5513  * thread_p(in):
5514  * info(in):
5515  * num_bind_vals(in):
5516  * bind_vals(in):
5517  */
5518 static void
5520 {
5521  FILE *log_fp;
5522  int indent = 2;
5523  LOG_TDES *tdes;
5524  int tran_index;
5525 
5526  tran_index = LOG_FIND_THREAD_TRAN_INDEX (thread_p);
5527  tdes = LOG_FIND_TDES (tran_index);
5528  log_fp = event_log_start (thread_p, "TEMP_VOLUME_EXPAND");
5529 
5530  if (tdes == NULL || log_fp == NULL)
5531  {
5532  return;
5533  }
5534 
5535  event_log_print_client_info (tran_index, indent);
5536  fprintf (log_fp, "%*csql: %s\n", indent, ' ', info->sql_hash_text ? info->sql_hash_text : "(UNKNOWN HASH_TEXT)");
5537 
5539  {
5540  event_log_bind_values (thread_p, log_fp, tran_index, tdes->num_exec_queries - 1);
5541  }
5542 
5543  fprintf (log_fp, "%*ctime: %d\n", indent, ' ', TO_MSEC (thread_p->event_stats.temp_expand_time));
5544  fprintf (log_fp, "%*cpages: %d\n\n", indent, ' ', thread_p->event_stats.temp_expand_pages);
5545 
5546  event_log_end (thread_p);
5547 }
5548 
5549 /*
5550  * sqmgr_prepare_and_execute_query -
5551  *
5552  * return:
5553  *
5554  * thrd(in):
5555  * rid(in):
5556  * request(in):
5557  * reqlen(in):
5558  *
5559  * NOTE:
5560  */
5561 void
5562 sqmgr_prepare_and_execute_query (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
5563 {
5564  int var_count, var_datasize, var_actual_datasize;
5565  QUERY_ID query_id;
5566  QFILE_LIST_ID *q_result;
5567  int csserror, listid_length;
5568  char *xasl_stream;
5569  int xasl_stream_size;
5570  char *ptr, *var_data, *list_data;
5572  char *reply = OR_ALIGNED_BUF_START (a_reply);
5573  PAGE_PTR page_ptr;
5574  int page_size;
5575  int dummy_plan_size = 0;
5576  char page_buf[IO_MAX_PAGE_SIZE + MAX_ALIGNMENT], *aligned_page_buf;
5577  QUERY_FLAG flag;
5578  int query_timeout;
5579  bool is_tran_auto_commit;
5580 
5581  aligned_page_buf = PTR_ALIGN (page_buf, MAX_ALIGNMENT);
5582 
5583  xasl_stream = NULL;
5584  xasl_stream_size = 0;
5585 
5586  var_data = NULL;
5587  var_datasize = 0;
5588  list_data = NULL;
5589  page_ptr = NULL;
5590  page_size = 0;
5591  q_result = NULL;
5592 
5593  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &xasl_stream, (int *) &xasl_stream_size);
5594  if (csserror)
5595  {
5597  css_send_abort_to_client (thread_p->conn_entry, rid);
5598  goto cleanup;
5599  }
5600 
5601  ptr = or_unpack_int (request, &var_count);
5602  ptr = or_unpack_int (ptr, &var_datasize);
5603  ptr = or_unpack_int (ptr, &flag);
5604  ptr = or_unpack_int (ptr, &query_timeout);
5605 
5606  if (var_count && var_datasize)
5607  {
5608  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, &var_data, (int *) &var_actual_datasize);
5609  if (csserror)
5610  {
5612  css_send_abort_to_client (thread_p->conn_entry, rid);
5613  goto cleanup;
5614  }
5615  }
5616 
5617  is_tran_auto_commit = IS_TRAN_AUTO_COMMIT (flag);
5618  xsession_set_tran_auto_commit (thread_p, is_tran_auto_commit);
5619 
5620  /*
5621  * After this point, xqmgr_prepare_and_execute_query has assumed
5622  * responsibility for freeing xasl_stream...
5623  */
5624  q_result =
5625  xqmgr_prepare_and_execute_query (thread_p, xasl_stream, xasl_stream_size, &query_id, var_count, var_data, &flag,
5626  query_timeout);
5627  if (var_data)
5628  {
5629  free_and_init (var_data);
5630  }
5631 
5632  if (xasl_stream)
5633  {
5634  free_and_init (xasl_stream); /* allocated at css_receive_data_from_client() */
5635  }
5636 
5637  if (q_result == NULL)
5638  {
5639  (void) return_error_to_client (thread_p, rid);
5640  listid_length = 0;
5641  }
5642  else
5643  {
5644  listid_length = or_listid_length (q_result);
5645  }
5646 
5647  /* listid_length can be reset after pb_fetch() return move this after reset statement ptr = or_pack_int(ptr,
5648  * listid_length); */
5649 
5650  if (listid_length)
5651  {
5652  if (VPID_ISNULL (&q_result->first_vpid))
5653  {
5654  page_ptr = NULL;
5655  }
5656  else
5657  {
5658  page_ptr = qmgr_get_old_page (thread_p, &q_result->first_vpid, q_result->tfile_vfid);
5659  }
5660 
5661  if (page_ptr)
5662  {
5663  if ((QFILE_GET_TUPLE_COUNT (page_ptr) == -2) || (QFILE_GET_OVERFLOW_PAGE_ID (page_ptr) != NULL_PAGEID))
5664  {
5665  page_size = DB_PAGESIZE;
5666  }
5667  else
5668  {
5669  int offset = QFILE_GET_LAST_TUPLE_OFFSET (page_ptr);
5670 
5671  page_size = (offset + QFILE_GET_TUPLE_LENGTH (page_ptr + offset));
5672  }
5673 
5674  /* to free page_ptr early */
5675  memcpy (aligned_page_buf, page_ptr, page_size);
5676  qmgr_free_old_page_and_init (thread_p, page_ptr, q_result->tfile_vfid);
5677  }
5678  else
5679  {
5680  /*
5681  * During query execution, ER_LK_UNILATERALLY_ABORTED may have
5682  * occurred.
5683  * xqmgr_sync_query() had set this error
5684  * so that the transaction will be rolled back.
5685  */
5686  if (er_errid () < 0)
5687  {
5688  (void) return_error_to_client (thread_p, rid);
5689  listid_length = 0;
5690  }
5691  /* if query type is not select, page ptr can be null */
5692  }
5693 
5694  if ((page_size > DB_PAGESIZE) || (page_size < 0))
5695  {
5696  page_size = 0;
5697  }
5698 
5699  if (listid_length > 0)
5700  {
5701  list_data = (char *) db_private_alloc (thread_p, listid_length);
5702  if (list_data == NULL)
5703  {
5704  listid_length = 0;
5705  }
5706  }
5707 
5708  if (list_data)
5709  {
5710  or_pack_listid (list_data, q_result);
5711  }
5712  }
5713  else
5714  {
5715  /* pack a couple of zeros for page_size and query_id since the client will unpack them. */
5716  listid_length = 0;
5717  page_size = 0;
5718  query_id = 0;
5719  }
5720 
5721  ptr = or_pack_int (reply, (int) QUERY_END);
5722  ptr = or_pack_int (ptr, listid_length);
5723  ptr = or_pack_int (ptr, page_size);
5724  ptr = or_pack_int (ptr, dummy_plan_size);
5725  ptr = or_pack_ptr (ptr, query_id);
5726 
5727 #if !defined(NDEBUG)
5728  /* suppress valgrind UMW error */
5729  memset (ptr, 0, OR_ALIGNED_BUF_SIZE (a_reply) - (ptr - reply));
5730 #endif
5731 
5732  css_send_reply_and_3_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), list_data,
5733  listid_length, aligned_page_buf, page_size, NULL, dummy_plan_size);
5734 
5735 cleanup:
5736  if (xasl_stream)
5737  {
5738  free_and_init (xasl_stream); /* allocated at css_receive_data_from_client() */
5739  }
5740 
5741  if (var_data)
5742  {
5743  free_and_init (var_data);
5744  }
5745  if (list_data)
5746  {
5747  db_private_free_and_init (thread_p, list_data);
5748  }
5749 
5750  /* since the listid was copied over to the client, we don't need this one on the server */
5751  if (q_result)
5752  {
5753  QFILE_FREE_AND_INIT_LIST_ID (q_result);
5754  }
5755 }
5756 
5757 /*
5758  * sqmgr_end_query -
5759  *
5760  * return:
5761  *
5762  * thrd(in):
5763  * rid(in):
5764  * request(in):
5765  * reqlen(in):
5766  *
5767  * NOTE:
5768  */
5769 void
5770 sqmgr_end_query (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
5771 {
5772  QUERY_ID query_id;
5773  int error_code = NO_ERROR;
5774  int all_error_code = NO_ERROR;
5775  int n_query_ids = 0, i = 0;
5776  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5777  char *reply = OR_ALIGNED_BUF_START (a_reply);
5778 
5779  request = or_unpack_int (request, &n_query_ids);
5780  for (i = 0; i < n_query_ids; i++)
5781  {
5782  request = or_unpack_ptr (request, &query_id);
5783  if (query_id > 0)
5784  {
5785  error_code = xqmgr_end_query (thread_p, query_id);
5786  if (error_code != NO_ERROR)
5787  {
5788  all_error_code = error_code;
5789  /* Continue to try to close as many queries as possible. */
5790  }
5791  }
5792  }
5793  if (all_error_code != NO_ERROR)
5794  {
5795  (void) return_error_to_client (thread_p, rid);
5796  }
5797 
5798  (void) or_pack_int (reply, all_error_code);
5799  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
5800 }
5801 
5802 /*
5803  * sqmgr_drop_all_query_plans - Process a SERVER_QM_DROP_ALL_PLANS request
5804  *
5805  * return:
5806  *
5807  * rid(in):
5808  * request(in):
5809  * reqlen(in):
5810  *
5811  * NOTE:
5812  * Clear all XASL cache entires out upon request of the client.
5813  * This function is a counter part to qmgr_drop_all_query_plans().
5814  */
5815 void
5816 sqmgr_drop_all_query_plans (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
5817 {
5818  int status;
5819  char *reply;
5820  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5821 
5822  reply = OR_ALIGNED_BUF_START (a_reply);
5823 
5824  /* call the server routine of query drop plan */
5825  status = xqmgr_drop_all_query_plans (thread_p);
5826  if (status != NO_ERROR)
5827  {
5828  (void) return_error_to_client (thread_p, rid);
5829  }
5830 
5831  /* pack status (DB_IN32) as a reply */
5832  (void) or_pack_int (reply, status);
5833 
5834  /* send reply and data to the client */
5835  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
5836 }
5837 
5838 /*
5839  * sqmgr_dump_query_plans -
5840  *
5841  * return:
5842  *
5843  * rid(in):
5844  * request(in):
5845  * reqlen(in):
5846  *
5847  * NOTE:
5848  */
5849 void
5850 sqmgr_dump_query_plans (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
5851 {
5852  FILE *outfp;
5853  int file_size;
5854  char *buffer;
5855  int buffer_size;
5856  int send_size;
5857  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5858  char *reply = OR_ALIGNED_BUF_START (a_reply);
5859 
5860  (void) or_unpack_int (request, &buffer_size);
5861 
5862  buffer = (char *) db_private_alloc (thread_p, buffer_size);
5863  if (buffer == NULL)
5864  {
5865  css_send_abort_to_client (thread_p->conn_entry, rid);
5866  return;
5867  }
5868 
5869  outfp = tmpfile ();
5870  if (outfp == NULL)
5871  {
5873  css_send_abort_to_client (thread_p->conn_entry, rid);
5874  db_private_free_and_init (thread_p, buffer);
5875  return;
5876  }
5877 
5878  xqmgr_dump_query_plans (thread_p, outfp);
5879  file_size = ftell (outfp);
5880 
5881  /*
5882  * Send the file in pieces
5883  */
5884  rewind (outfp);
5885 
5886  (void) or_pack_int (reply, (int) file_size);
5887  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
5888 
5889  while (file_size > 0)
5890  {
5891  if (file_size > buffer_size)
5892  {
5893  send_size = buffer_size;
5894  }
5895  else
5896  {
5897  send_size = file_size;
5898  }
5899 
5900  file_size -= send_size;
5901  if (fread (buffer, 1, send_size, outfp) == 0)
5902  {
5904  css_send_abort_to_client (thread_p->conn_entry, rid);
5905  /*
5906  * Continue sending the stuff that was prmoised to client. In this case
5907  * junk (i.e., whatever it is in the buffers) is sent.
5908  */
5909  }
5910  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
5911  }
5912 
5913  fclose (outfp);
5914  db_private_free_and_init (thread_p, buffer);
5915 }
5916 
5917 /*
5918  * sqmgr_dump_query_cache -
5919  *
5920  * return:
5921  *
5922  * rid(in):
5923  * request(in):
5924  * reqlen(in):
5925  *
5926  * NOTE:
5927  */
5928 void
5929 sqmgr_dump_query_cache (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
5930 {
5931  FILE *outfp;
5932  int file_size;
5933  char *buffer;
5934  int buffer_size;
5935  int send_size;
5936  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
5937  char *reply = OR_ALIGNED_BUF_START (a_reply);
5938 
5939  (void) or_unpack_int (request, &buffer_size);
5940 
5941  buffer = (char *) db_private_alloc (thread_p, buffer_size);
5942  if (buffer == NULL)
5943  {
5944  css_send_abort_to_client (thread_p->conn_entry, rid);
5945  return;
5946  }
5947 
5948  outfp = tmpfile ();
5949  if (outfp == NULL)
5950  {
5952  css_send_abort_to_client (thread_p->conn_entry, rid);
5953  db_private_free_and_init (thread_p, buffer);
5954  return;
5955  }
5956 
5957  xqmgr_dump_query_cache (thread_p, outfp);
5958  file_size = ftell (outfp);
5959 
5960  /*
5961  * Send the file in pieces
5962  */
5963  rewind (outfp);
5964 
5965  (void) or_pack_int (reply, (int) file_size);
5966  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
5967 
5968  while (file_size > 0)
5969  {
5970  if (file_size > buffer_size)
5971  {
5972  send_size = buffer_size;
5973  }
5974  else
5975  {
5976  send_size = file_size;
5977  }
5978 
5979  file_size -= send_size;
5980  if (fread (buffer, 1, send_size, outfp) == 0)
5981  {
5983  css_send_abort_to_client (thread_p->conn_entry, rid);
5984  /*
5985  * Continue sending the stuff that was prmoised to client. In this case
5986  * junk (i.e., whatever it is in the buffers) is sent.
5987  */
5988  }
5989  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
5990  }
5991  fclose (outfp);
5992  db_private_free_and_init (thread_p, buffer);
5993 }
5994 
5995 /*
5996  * sqp_get_sys_timestamp -
5997  *
5998  * return:
5999  *
6000  * rid(in):
6001  *
6002  * NOTE:
6003  */
6004 void
6005 sqp_get_sys_timestamp (THREAD_ENTRY * thread_p, unsigned int rid, char *request_ignore, int reqlen_ignore)
6006 {
6007 #if defined(ENABLE_UNUSED_FUNCTION)
6008  OR_ALIGNED_BUF (OR_UTIME_SIZE) a_reply;
6009  char *reply = OR_ALIGNED_BUF_START (a_reply);
6010 
6011  DB_VALUE sys_timestamp;
6012 
6013  db_sys_timestamp (&sys_timestamp);
6014  (void) or_pack_utime (reply, *(DB_TIMESTAMP *) db_get_timestamp (&sys_timestamp));
6015  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6016 #endif /* ENABLE_UNUSED_FUNCTION */
6017 }
6018 
6019 /*
6020  * sserial_get_current_value -
6021  *
6022  * return:
6023  *
6024  * rid(in):
6025  * request(in):
6026  * reqlen(in):
6027  *
6028  * NOTE:
6029  */
6030 void
6031 sserial_get_current_value (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6032 {
6033  int error_status = NO_ERROR;
6034  DB_VALUE cur_val;
6035  OID oid;
6036  int cached_num;
6037  int buffer_length;
6038  char *buffer;
6040  char *reply = OR_ALIGNED_BUF_START (a_reply);
6041  char *p;
6042 
6043  p = or_unpack_oid (request, &oid);
6044  p = or_unpack_int (p, &cached_num);
6045 
6046  error_status = xserial_get_current_value (thread_p, &cur_val, &oid, cached_num);
6047  if (error_status != NO_ERROR)
6048  {
6049  assert (er_errid () != NO_ERROR);
6050  error_status = er_errid ();
6051  buffer_length = 0;
6052  buffer = NULL;
6053  }
6054  else
6055  {
6056  buffer_length = or_db_value_size (&cur_val);
6057  buffer = (char *) db_private_alloc (thread_p, buffer_length);
6058  if (buffer == NULL)
6059  {
6060  error_status = ER_OUT_OF_VIRTUAL_MEMORY;
6061  buffer_length = 0;
6062  }
6063  }
6064  p = or_pack_int (reply, buffer_length);
6065  p = or_pack_int (p, error_status);
6066 
6067  if (buffer == NULL)
6068  {
6069  (void) return_error_to_client (thread_p, rid);
6070  buffer_length = 0;
6071  }
6072  else
6073  {
6074  (void) or_pack_value (buffer, &cur_val);
6075  db_value_clear (&cur_val);
6076  }
6077 
6078  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), buffer,
6079  buffer_length);
6080  if (buffer != NULL)
6081  {
6082  /* since this was copied to the client, we don't need it on the server */
6083  db_private_free_and_init (thread_p, buffer);
6084  }
6085 }
6086 
6087 /*
6088  * sserial_get_next_value -
6089  *
6090  * return:
6091  *
6092  * rid(in):
6093  * request(in):
6094  * reqlen(in):
6095  *
6096  * NOTE:
6097  */
6098 void
6099 sserial_get_next_value (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6100 {
6101  DB_VALUE next_val;
6102  OID oid;
6103  char *buffer;
6104  int cached_num, num_alloc, is_auto_increment;
6105  int buffer_length, errid;
6107  char *reply = OR_ALIGNED_BUF_START (a_reply);
6108  char *p;
6109 
6110  p = or_unpack_oid (request, &oid);
6111  p = or_unpack_int (p, &cached_num);
6112  p = or_unpack_int (p, &num_alloc);
6113  p = or_unpack_int (p, &is_auto_increment);
6114 
6115  /*
6116  * If a client wants to generate AUTO_INCREMENT value during client-side
6117  * insertion, a server should update LAST_INSERT_ID on a session.
6118  */
6119  errid = xserial_get_next_value (thread_p, &next_val, &oid, cached_num, num_alloc, is_auto_increment, true);
6120 
6121  if (errid != NO_ERROR)
6122  {
6123  buffer_length = 0;
6124  buffer = NULL;
6125  }
6126  else
6127  {
6128  buffer_length = or_db_value_size (&next_val);
6129  buffer = (char *) db_private_alloc (thread_p, buffer_length);
6130  if (buffer == NULL)
6131  {
6132  buffer_length = 0;
6133  errid = ER_OUT_OF_VIRTUAL_MEMORY;
6134  }
6135  }
6136  p = or_pack_int (reply, buffer_length);
6137  p = or_pack_int (p, errid);
6138 
6139  if (buffer == NULL)
6140  {
6141  (void) return_error_to_client (thread_p, rid);
6142  }
6143  else
6144  {
6145  (void) or_pack_value (buffer, &next_val);
6146  db_value_clear (&next_val);
6147  }
6148 
6149  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), buffer,
6150  buffer_length);
6151  if (buffer != NULL)
6152  {
6153  /* since this was copied to the client, we don't need it on the server */
6154  db_private_free_and_init (thread_p, buffer);
6155  }
6156 }
6157 
6158 /*
6159  * sserial_decache -
6160  *
6161  * return:
6162  *
6163  * rid(in):
6164  * request(in):
6165  * reqlen(in):
6166  *
6167  * NOTE:
6168  */
6169 void
6170 sserial_decache (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6171 {
6172  OID oid;
6173  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6174  char *reply = OR_ALIGNED_BUF_START (a_reply);
6175 
6176  (void) or_unpack_oid (request, &oid);
6177  xserial_decache (thread_p, &oid);
6178 
6179  (void) or_pack_int (reply, NO_ERROR);
6180  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6181 }
6182 
6183 /*
6184  * smnt_server_start_stats -
6185  *
6186  * return:
6187  *
6188  * rid(in):
6189  * request(in):
6190  * reqlen(in):
6191  *
6192  * NOTE:
6193  */
6194 void
6195 smnt_server_start_stats (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6196 {
6197  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6198  char *reply = OR_ALIGNED_BUF_START (a_reply);
6199 
6200  perfmon_start_watch (thread_p);
6201 
6202  (void) or_pack_int (reply, NO_ERROR);
6203  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6204 }
6205 
6206 /*
6207  * smnt_server_stop_stats -
6208  *
6209  * return:
6210  *
6211  * rid(in):
6212  * request(in):
6213  * reqlen(in):
6214  *
6215  * NOTE:
6216  */
6217 void
6218 smnt_server_stop_stats (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6219 {
6220  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6221  char *reply = OR_ALIGNED_BUF_START (a_reply);
6222 
6223  perfmon_stop_watch (thread_p);
6224  /* dummy reply message */
6225  (void) or_pack_int (reply, 1);
6226  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6227 }
6228 
6229 /*
6230  * smnt_server_copy_stats -
6231  *
6232  * return:
6233  *
6234  * rid(in):
6235  * request(in):
6236  * reqlen(in):
6237  *
6238  * NOTE:
6239  */
6240 void
6241 smnt_server_copy_stats (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6242 {
6243  char *reply = NULL;
6244  int nr_statistic_values;
6245  UINT64 *stats = NULL;
6246 
6247  nr_statistic_values = perfmon_get_number_of_statistic_values ();
6248  stats = perfmon_allocate_values ();
6249 
6250  if (stats == NULL)
6251  {
6252  ASSERT_ERROR ();
6253  css_send_abort_to_client (thread_p->conn_entry, rid);
6254  return;
6255  }
6256 
6258  if (reply == NULL)
6259  {
6260  ASSERT_ERROR ();
6261  free_and_init (stats);
6262  css_send_abort_to_client (thread_p->conn_entry, rid);
6263  return;
6264  }
6265 
6266  xperfmon_server_copy_stats (thread_p, stats);
6267  perfmon_pack_stats (reply, stats);
6268  css_send_data_to_client (thread_p->conn_entry, rid, reply, nr_statistic_values * sizeof (UINT64));
6269  free_and_init (stats);
6270  free_and_init (reply);
6271 }
6272 
6273 /*
6274  * smnt_server_copy_global_stats -
6275  *
6276  * return:
6277  *
6278  * rid(in):
6279  * request(in):
6280  * reqlen(in):
6281  *
6282  * NOTE:
6283  */
6284 void
6285 smnt_server_copy_global_stats (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6286 {
6287  char *reply = NULL;
6288  int nr_statistic_values;
6289  UINT64 *stats = NULL;
6290 
6291  nr_statistic_values = perfmon_get_number_of_statistic_values ();
6292  stats = perfmon_allocate_values ();
6293  if (stats == NULL)
6294  {
6295  ASSERT_ERROR ();
6296  css_send_abort_to_client (thread_p->conn_entry, rid);
6297  return;
6298  }
6299 
6301  if (reply == NULL)
6302  {
6303  ASSERT_ERROR ();
6304  free_and_init (stats);
6305  css_send_abort_to_client (thread_p->conn_entry, rid);
6306  return;
6307  }
6308 
6310  perfmon_pack_stats (reply, stats);
6311  css_send_data_to_client (thread_p->conn_entry, rid, reply, nr_statistic_values * sizeof (UINT64));
6312  free_and_init (stats);
6313  free_and_init (reply);
6314 }
6315 
6316 /*
6317  * sct_check_rep_dir -
6318  *
6319  * return:
6320  *
6321  * rid(in):
6322  * request(in):
6323  * reqlen(in):
6324  *
6325  * NOTE:
6326  */
6327 void
6328 sct_check_rep_dir (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6329 {
6330  OID classoid;
6331  OID rep_dir;
6332  int success;
6334  char *reply = OR_ALIGNED_BUF_START (a_reply);
6335  char *ptr;
6336 
6337  ptr = or_unpack_oid (request, &classoid);
6338  OID_SET_NULL (&rep_dir); /* init */
6339 
6340  success = xcatalog_check_rep_dir (thread_p, &classoid, &rep_dir);
6341  if (success != NO_ERROR)
6342  {
6343  (void) return_error_to_client (thread_p, rid);
6344  }
6345 
6346  assert (success != NO_ERROR || !OID_ISNULL (&rep_dir));
6347 
6348  ptr = or_pack_int (reply, (int) success);
6349  ptr = or_pack_oid (ptr, &rep_dir);
6350 
6351  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6352 }
6353 
6354 /*
6355  * xs_send_method_call_info_to_client -
6356  *
6357  * return:
6358  *
6359  * list_id(in):
6360  * method_sig_list(in):
6361  *
6362  * NOTE:
6363  */
6364 int
6366 {
6367  int length = 0;
6368  char *databuf;
6369  char *ptr;
6370  unsigned int rid;
6371  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
6372  char *reply = OR_ALIGNED_BUF_START (a_reply);
6373 
6374  rid = css_get_comm_request_id (thread_p);
6375  length = or_listid_length ((void *) list_id);
6376  length += or_method_sig_list_length ((void *) methsg_list);
6377  ptr = or_pack_int (reply, (int) METHOD_CALL);
6378  ptr = or_pack_int (ptr, length);
6379 
6380 #if !defined(NDEBUG)
6381  /* suppress valgrind UMW error */
6382  memset (ptr, 0, OR_ALIGNED_BUF_SIZE (a_reply) - (ptr - reply));
6383 #endif
6384 
6385  databuf = (char *) db_private_alloc (thread_p, length);
6386  if (databuf == NULL)
6387  {
6388  return ER_FAILED;
6389  }
6390 
6391  ptr = or_pack_listid (databuf, (void *) list_id);
6392  ptr = or_pack_method_sig_list (ptr, (void *) methsg_list);
6393  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), databuf, length);
6394  db_private_free_and_init (thread_p, databuf);
6395  return NO_ERROR;
6396 }
6397 
6398 /*
6399  * xs_receive_data_from_client -
6400  *
6401  * return:
6402  *
6403  * area(in):
6404  * datasize(in):
6405  *
6406  * NOTE:
6407  */
6408 int
6409 xs_receive_data_from_client (THREAD_ENTRY * thread_p, char **area, int *datasize)
6410 {
6411  return xs_receive_data_from_client_with_timeout (thread_p, area, datasize, -1);
6412 }
6413 
6414 /*
6415  * xs_receive_data_from_client_with_timeout -
6416  *
6417  * return:
6418  *
6419  * area(in):
6420  * datasize(in):
6421  * timeout (in):
6422  *
6423  * NOTE:
6424  */
6425 int
6426 xs_receive_data_from_client_with_timeout (THREAD_ENTRY * thread_p, char **area, int *datasize, int timeout)
6427 {
6428  unsigned int rid;
6429  int rc = 0;
6430  bool continue_checking = true;
6431 
6432  if (*area)
6433  {
6434  free_and_init (*area);
6435  }
6436  rid = css_get_comm_request_id (thread_p);
6437 
6438  rc = css_receive_data_from_client_with_timeout (thread_p->conn_entry, rid, area, (int *) datasize, timeout);
6439 
6440  if (rc == TIMEDOUT_ON_QUEUE)
6441  {
6444  }
6445  else if (rc != 0)
6446  {
6448  return ER_FAILED;
6449  }
6450 
6451  if (logtb_is_interrupted (thread_p, false, &continue_checking))
6452  {
6454  return ER_FAILED;
6455  }
6456 
6457  return NO_ERROR;
6458 }
6459 
6460 /*
6461  * xs_send_action_to_client -
6462  *
6463  * return:
6464  *
6465  * action(in):
6466  *
6467  * NOTE:
6468  */
6469 int
6471 {
6472  unsigned int rid;
6473  bool continue_checking = true;
6474  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6475  char *reply = OR_ALIGNED_BUF_START (a_reply);
6476 
6477  if (logtb_is_interrupted (thread_p, false, &continue_checking))
6478  {
6480  return ER_FAILED;
6481  }
6482 
6483  rid = css_get_comm_request_id (thread_p);
6484  (void) or_pack_int (reply, (int) action);
6485  if (css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_INT_SIZE))
6486  {
6487  return ER_FAILED;
6488  }
6489 
6490  return NO_ERROR;
6491 }
6492 
6493 /*
6494  * slocator_assign_oid_batch -
6495  *
6496  * return:
6497  *
6498  * rid(in):
6499  * request(in):
6500  * reqlen(in):
6501  *
6502  * NOTE:
6503  */
6504 void
6505 slocator_assign_oid_batch (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6506 {
6507  int success;
6508  LC_OIDSET *oidset = NULL;
6509 
6510  /* skip over the word at the front reserved for the return code */
6511  oidset = locator_unpack_oid_set_to_new (thread_p, request + OR_INT_SIZE);
6512  if (oidset == NULL)
6513  {
6514  (void) return_error_to_client (thread_p, rid);
6515  return;
6516  }
6517 
6518  success = xlocator_assign_oid_batch (thread_p, oidset);
6519 
6520  /* the buffer we send back is identical in size to the buffer that was received so we can reuse it. */
6521 
6522  /* first word is reserved for return code */
6523  or_pack_int (request, success);
6524  if (success == NO_ERROR)
6525  {
6526  if (locator_pack_oid_set (request + OR_INT_SIZE, oidset) == NULL)
6527  {
6528  /* trouble packing oidset for the return trip, severe error */
6529  success = ER_FAILED;
6530  or_pack_int (request, success);
6531  }
6532  }
6533 
6534  if (success != NO_ERROR)
6535  {
6536  (void) return_error_to_client (thread_p, rid);
6537  }
6538 
6539  css_send_data_to_client (thread_p->conn_entry, rid, request, reqlen);
6540 
6541  locator_free_oid_set (thread_p, oidset);
6542 }
6543 
6544 /*
6545  * slocator_find_lockhint_class_oids -
6546  *
6547  * return:
6548  *
6549  * rid(in):
6550  * request(in):
6551  * reqlen(in):
6552  *
6553  * NOTE:
6554  */
6555 void
6556 slocator_find_lockhint_class_oids (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6557 {
6558  int num_classes;
6559  char **many_classnames;
6560  LOCK *many_locks = NULL;
6561  int *many_need_subclasses = NULL;
6562  OID *guessed_class_oids = NULL;
6563  int *guessed_class_chns = NULL;
6564  LC_PREFETCH_FLAGS *many_flags = NULL;
6565  int quit_on_errors, lock_rr_tran;
6567  LC_LOCKHINT *found_lockhint;
6568  LC_COPYAREA *copy_area;
6569  char *desc_ptr = NULL;
6570  int desc_size;
6571  char *content_ptr;
6572  int content_size;
6573  char *ptr;
6574  int num_objs = 0;
6575  char *packed = NULL;
6576  int packed_size;
6577  int send_size = 0;
6578  int i;
6579  int malloc_size;
6580  char *malloc_area;
6582  char *reply = OR_ALIGNED_BUF_START (a_reply);
6583 
6584  found_lockhint = NULL;
6585  copy_area = NULL;
6586 
6587  ptr = or_unpack_int (request, &num_classes);
6588  ptr = or_unpack_int (ptr, &quit_on_errors);
6589  ptr = or_unpack_int (ptr, &lock_rr_tran);
6590 
6591  malloc_size = ((sizeof (char *) + sizeof (LOCK) + sizeof (int) + sizeof (int) + sizeof (OID) + sizeof (int))
6592  * num_classes);
6593 
6594  malloc_area = (char *) db_private_alloc (thread_p, malloc_size);
6595  if (malloc_area != NULL)
6596  {
6597  many_classnames = (char **) malloc_area;
6598  many_locks = (LOCK *) ((char *) malloc_area + (sizeof (char *) * num_classes));
6599  many_need_subclasses = (int *) ((char *) many_locks + (sizeof (LOCK) * num_classes));
6600  many_flags = (LC_PREFETCH_FLAGS *) ((char *) many_need_subclasses + (sizeof (int) * num_classes));
6601  guessed_class_oids = (OID *) ((char *) many_flags + (sizeof (int) * num_classes));
6602  guessed_class_chns = (int *) ((char *) guessed_class_oids + (sizeof (OID) * num_classes));
6603 
6604  for (i = 0; i < num_classes; i++)
6605  {
6606  ptr = or_unpack_string_nocopy (ptr, &many_classnames[i]);
6607  ptr = or_unpack_lock (ptr, &many_locks[i]);
6608  ptr = or_unpack_int (ptr, &many_need_subclasses[i]);
6609  ptr = or_unpack_int (ptr, (int *) &many_flags[i]);
6610  ptr = or_unpack_oid (ptr, &guessed_class_oids[i]);
6611  ptr = or_unpack_int (ptr, &guessed_class_chns[i]);
6612  }
6613 
6614  allfind =
6615  xlocator_find_lockhint_class_oids (thread_p, num_classes, (const char **) many_classnames, many_locks,
6616  many_need_subclasses, many_flags, guessed_class_oids, guessed_class_chns,
6617  quit_on_errors, &found_lockhint, &copy_area);
6618  }
6619  if (allfind != LC_CLASSNAME_EXIST)
6620  {
6621  (void) return_error_to_client (thread_p, rid);
6622  }
6623 
6624  if ((LOCK) lock_rr_tran != NULL_LOCK)
6625  {
6626  /* lock the object common for RR transactions. This is used in ALTER TABLE ADD COLUMN NOT NULL scenarios */
6627  if (xtran_lock_rep_read (thread_p, (LOCK) lock_rr_tran) != NO_ERROR)
6628  {
6629  allfind = LC_CLASSNAME_ERROR;
6631  (void) return_error_to_client (thread_p, rid);
6632  }
6633  }
6634 
6635  if (found_lockhint != NULL && found_lockhint->length > 0)
6636  {
6637  send_size = locator_pack_lockhint (found_lockhint, true);
6638 
6639  packed = found_lockhint->packed;
6640  packed_size = found_lockhint->packed_size;
6641 
6642  if (!packed)
6643  {
6644  (void) return_error_to_client (thread_p, rid);
6645  allfind = LC_CLASSNAME_ERROR;
6646  }
6647  }
6648 
6649  if (copy_area != NULL)
6650  {
6651  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
6652  }
6653  else
6654  {
6655  desc_ptr = NULL;
6656  desc_size = 0;
6657  content_ptr = NULL;
6658  content_size = 0;
6659  }
6660 
6661  /* Send sizes of databuffer and copy area (descriptor + content) */
6662 
6663  ptr = or_pack_int (reply, send_size);
6664  ptr = or_pack_int (ptr, num_objs);
6665  ptr = or_pack_int (ptr, desc_size);
6666  ptr = or_pack_int (ptr, content_size);
6667 
6668  ptr = or_pack_int (ptr, allfind);
6669 
6670  if (copy_area == NULL && found_lockhint == NULL)
6671  {
6672  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6673  }
6674  else
6675  {
6676  css_send_reply_and_3_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), packed,
6677  send_size, desc_ptr, desc_size, content_ptr, content_size);
6678  if (copy_area != NULL)
6679  {
6680  locator_free_copy_area (copy_area);
6681  }
6682 
6683  if (found_lockhint != NULL)
6684  {
6685  locator_free_lockhint (found_lockhint);
6686  }
6687 
6688  if (desc_ptr)
6689  {
6690  free_and_init (desc_ptr);
6691  }
6692  }
6693 
6694  if (malloc_area)
6695  {
6696  db_private_free_and_init (thread_p, malloc_area);
6697  }
6698 }
6699 
6700 /*
6701  * slocator_fetch_lockhint_classes -
6702  *
6703  * return:
6704  *
6705  * rid(in):
6706  * request(in):
6707  * reqlen(in):
6708  *
6709  * NOTE:
6710  */
6711 void
6712 slocator_fetch_lockhint_classes (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6713 {
6714  int success;
6715  LC_COPYAREA *copy_area;
6716  LC_LOCKHINT *lockhint;
6718  char *reply = OR_ALIGNED_BUF_START (a_reply);
6719  char *desc_ptr;
6720  int desc_size;
6721  char *content_ptr;
6722  int content_size;
6723  char *ptr;
6724  bool first_call;
6725  int num_objs;
6726  char *packed = NULL;
6727  int packed_size;
6728  int send_size;
6729 
6730  ptr = or_unpack_int (request, &packed_size);
6731 
6732  if (packed_size == 0 || css_receive_data_from_client (thread_p->conn_entry, rid, &packed, (int *) &packed_size))
6733  {
6735  css_send_abort_to_client (thread_p->conn_entry, rid);
6736  if (packed)
6737  {
6738  free_and_init (packed);
6739  }
6740  return;
6741  }
6742 
6743  lockhint = locator_allocate_and_unpack_lockhint (packed, packed_size, true, false);
6744  free_and_init (packed);
6745 
6746  if ((lockhint == NULL) || (lockhint->length <= 0))
6747  {
6748  (void) return_error_to_client (thread_p, rid);
6749  ptr = or_pack_int (reply, 0);
6750  ptr = or_pack_int (ptr, 0);
6751  ptr = or_pack_int (ptr, 0);
6752  ptr = or_pack_int (ptr, 0);
6753  ptr = or_pack_int (ptr, ER_FAILED);
6754  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6755  return;
6756  }
6757 
6758  first_call = true;
6759  do
6760  {
6761  desc_ptr = NULL;
6762  num_objs = 0;
6763 
6764  copy_area = NULL;
6765  success = xlocator_fetch_lockhint_classes (thread_p, lockhint, &copy_area);
6766  if (success != NO_ERROR)
6767  {
6768  (void) return_error_to_client (thread_p, rid);
6769  }
6770 
6771  if (copy_area != NULL)
6772  {
6773  num_objs = locator_send_copy_area (copy_area, &content_ptr, &content_size, &desc_ptr, &desc_size);
6774  }
6775  else
6776  {
6777  desc_ptr = NULL;
6778  desc_size = 0;
6779  content_ptr = NULL;
6780  content_size = 0;
6781  }
6782 
6783  /* Send sizes of databuffer and copy area (descriptor + content) */
6784 
6785  send_size = locator_pack_lockhint (lockhint, first_call);
6786 
6787  packed = lockhint->packed;
6788  packed_size = lockhint->packed_size;
6789 
6790  ptr = or_pack_int (reply, send_size);
6791  ptr = or_pack_int (ptr, num_objs);
6792  ptr = or_pack_int (ptr, desc_size);
6793  ptr = or_pack_int (ptr, content_size);
6794 
6795  ptr = or_pack_int (ptr, success);
6796 
6797  if (copy_area == NULL && lockhint == NULL)
6798  {
6799  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6800  }
6801  else
6802  {
6803  css_send_reply_and_3_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), packed,
6804  send_size, desc_ptr, desc_size, content_ptr, content_size);
6805  }
6806  if (copy_area != NULL)
6807  {
6808  locator_free_copy_area (copy_area);
6809  }
6810  if (desc_ptr)
6811  {
6812  free_and_init (desc_ptr);
6813  }
6814 
6815  first_call = false;
6816  }
6817  while (copy_area && lockhint && ((lockhint->num_classes > lockhint->num_classes_processed)));
6818 
6819  if (lockhint)
6820  {
6821  locator_free_lockhint (lockhint);
6822  }
6823 }
6824 
6825 /*
6826  * sthread_kill_tran_index -
6827  *
6828  * return:
6829  *
6830  * rid(in):
6831  * request(in):
6832  * reqlen(in):
6833  *
6834  * NOTE:
6835  */
6836 void
6837 sthread_kill_tran_index (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6838 {
6839  int success;
6840  int kill_tran_index;
6841  int kill_pid;
6842  char *kill_user;
6843  char *kill_host;
6844  char *ptr;
6845  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6846  char *reply = OR_ALIGNED_BUF_START (a_reply);
6847 
6848  ptr = or_unpack_int (request, &kill_tran_index);
6849  ptr = or_unpack_string_nocopy (ptr, &kill_user);
6850  ptr = or_unpack_string_nocopy (ptr, &kill_host);
6851  ptr = or_unpack_int (ptr, &kill_pid);
6852 
6853  success = (xlogtb_kill_tran_index (thread_p, kill_tran_index, kill_user, kill_host, kill_pid)
6854  == NO_ERROR) ? NO_ERROR : ER_FAILED;
6855  if (success != NO_ERROR)
6856  {
6857  (void) return_error_to_client (thread_p, rid);
6858  }
6859 
6860  ptr = or_pack_int (reply, success);
6861  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6862 }
6863 
6864 /*
6865  * sthread_kill_or_interrupt_tran -
6866  *
6867  * return:
6868  *
6869  * rid(in):
6870  * request(in):
6871  * reqlen(in):
6872  *
6873  * NOTE:
6874  */
6875 void
6876 sthread_kill_or_interrupt_tran (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6877 {
6878  int success = NO_ERROR;
6879  char *ptr;
6881  char *reply = OR_ALIGNED_BUF_START (a_reply);
6882  int i = 0;
6883  int *tran_index_list;
6884  int num_tran_index, interrupt_only;
6885  int num_killed_tran = 0;
6886  int is_dba_group_member = 0;
6887 
6888  ptr = or_unpack_int (request, &is_dba_group_member);
6889  ptr = or_unpack_int (ptr, &num_tran_index);
6890  ptr = or_unpack_int_array (ptr, num_tran_index, &tran_index_list);
6891  ptr = or_unpack_int (ptr, &interrupt_only);
6892 
6893  for (i = 0; i < num_tran_index; i++)
6894  {
6895  success =
6896  xlogtb_kill_or_interrupt_tran (thread_p, tran_index_list[i], (bool) is_dba_group_member, (bool) interrupt_only);
6897  if (success == NO_ERROR)
6898  {
6899  num_killed_tran++;
6900  }
6901  else if (success == ER_KILL_TR_NOT_ALLOWED)
6902  {
6903  (void) return_error_to_client (thread_p, rid);
6904  break;
6905  }
6906  else
6907  {
6908  /* error not related with authorization is ignored and keep running */
6909  success = NO_ERROR;
6910  }
6911  }
6912 
6913  ptr = or_pack_int (reply, success);
6914  ptr = or_pack_int (ptr, num_killed_tran);
6915  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6916 
6917  if (tran_index_list)
6918  {
6919  db_private_free (NULL, tran_index_list);
6920  }
6921 }
6922 
6923 /*
6924  * sthread_dump_cs_stat -
6925  *
6926  * return:
6927  *
6928  * rid(in):
6929  * request(in):
6930  * reqlen(in):
6931  *
6932  * NOTE:
6933  */
6934 void
6935 sthread_dump_cs_stat (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
6936 {
6937  FILE *outfp;
6938  int file_size;
6939  char *buffer;
6940  int buffer_size;
6941  int send_size;
6942  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
6943  char *reply = OR_ALIGNED_BUF_START (a_reply);
6944 
6945  (void) or_unpack_int (request, &buffer_size);
6946 
6947  buffer = (char *) db_private_alloc (NULL, buffer_size);
6948  if (buffer == NULL)
6949  {
6950  css_send_abort_to_client (thread_p->conn_entry, rid);
6951  return;
6952  }
6953 
6954  outfp = tmpfile ();
6955  if (outfp == NULL)
6956  {
6958  css_send_abort_to_client (thread_p->conn_entry, rid);
6959  db_private_free_and_init (NULL, buffer);
6960  return;
6961  }
6962 
6964 
6965  file_size = ftell (outfp);
6966 
6967  /*
6968  * Send the file in pieces
6969  */
6970  rewind (outfp);
6971 
6972  (void) or_pack_int (reply, (int) file_size);
6973  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
6974 
6975  while (file_size > 0)
6976  {
6977  if (file_size > buffer_size)
6978  {
6979  send_size = buffer_size;
6980  }
6981  else
6982  {
6983  send_size = file_size;
6984  }
6985 
6986  file_size -= send_size;
6987  if (fread (buffer, 1, send_size, outfp) == 0)
6988  {
6990  css_send_abort_to_client (thread_p->conn_entry, rid);
6991  /*
6992  * Continue sending the stuff that was prmoised to client. In this case
6993  * junk (i.e., whatever it is in the buffers) is sent.
6994  */
6995  }
6996  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
6997  }
6998  fclose (outfp);
6999  db_private_free_and_init (NULL, buffer);
7000 }
7001 
7002 /*
7003  * slogtb_get_pack_tran_table -
7004  *
7005  * return:
7006  *
7007  * rid(in):
7008  * request(in):
7009  * reqlen(in):
7010  */
7011 void
7012 slogtb_get_pack_tran_table (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7013 {
7014  char *buffer, *ptr;
7015  int size;
7017  char *reply = OR_ALIGNED_BUF_START (a_reply);
7018  int error;
7019  int include_query_exec_info;
7020 
7021  (void) or_unpack_int (request, &include_query_exec_info);
7022 
7023  error = xlogtb_get_pack_tran_table (thread_p, &buffer, &size, include_query_exec_info);
7024 
7025  if (error != NO_ERROR)
7026  {
7027  ptr = or_pack_int (reply, 0);
7028  ptr = or_pack_int (ptr, error);
7029  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7030  }
7031  else
7032  {
7033  ptr = or_pack_int (reply, size);
7034  ptr = or_pack_int (ptr, error);
7035  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7036  css_send_data_to_client (thread_p->conn_entry, rid, buffer, size);
7037  free_and_init (buffer);
7038  }
7039 }
7040 
7041 /*
7042  * slogtb_dump_trantable -
7043  *
7044  * return:
7045  *
7046  * rid(in):
7047  * request(in):
7048  * reqlen(in):
7049  */
7050 void
7051 slogtb_dump_trantable (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7052 {
7053  FILE *outfp;
7054  int file_size;
7055  char *buffer;
7056  int buffer_size;
7057  int send_size;
7058  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7059  char *reply = OR_ALIGNED_BUF_START (a_reply);
7060 
7061  (void) or_unpack_int (request, &buffer_size);
7062 
7063  buffer = (char *) db_private_alloc (thread_p, buffer_size);
7064  if (buffer == NULL)
7065  {
7066  css_send_abort_to_client (thread_p->conn_entry, rid);
7067  return;
7068  }
7069 
7070  outfp = tmpfile ();
7071  if (outfp == NULL)
7072  {
7074  css_send_abort_to_client (thread_p->conn_entry, rid);
7075  db_private_free_and_init (thread_p, buffer);
7076  return;
7077  }
7078 
7079  xlogtb_dump_trantable (thread_p, outfp);
7080  file_size = ftell (outfp);
7081 
7082  /*
7083  * Send the file in pieces
7084  */
7085  rewind (outfp);
7086 
7087  (void) or_pack_int (reply, (int) file_size);
7088  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7089 
7090  while (file_size > 0)
7091  {
7092  if (file_size > buffer_size)
7093  {
7094  send_size = buffer_size;
7095  }
7096  else
7097  {
7098  send_size = file_size;
7099  }
7100 
7101  file_size -= send_size;
7102  if (fread (buffer, 1, send_size, outfp) == 0)
7103  {
7105  css_send_abort_to_client (thread_p->conn_entry, rid);
7106  /*
7107  * Continue sending the stuff that was prmoised to client. In this case
7108  * junk (i.e., whatever it is in the buffers) is sent.
7109  */
7110  }
7111  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
7112  }
7113  fclose (outfp);
7114  db_private_free_and_init (thread_p, buffer);
7115 }
7116 
7117 /*
7118  * xcallback_console_print -
7119  *
7120  * return:
7121  *
7122  * print_str(in):
7123  */
7124 int
7125 xcallback_console_print (THREAD_ENTRY * thread_p, char *print_str)
7126 {
7127  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
7128  char *reply = OR_ALIGNED_BUF_START (a_reply);
7129  unsigned int rid, rc;
7130  int data_len, print_len;
7131  char *ptr;
7132  char *databuf;
7133 
7134  rid = css_get_comm_request_id (thread_p);
7135  data_len = or_packed_string_length (print_str, &print_len);
7136 
7137  ptr = or_pack_int (reply, (int) CONSOLE_OUTPUT);
7138  ptr = or_pack_int (ptr, NO_ERROR);
7139  ptr = or_pack_int (ptr, data_len);
7140 
7141  databuf = (char *) db_private_alloc (thread_p, data_len);
7142  if (databuf == NULL)
7143  {
7145  return ER_FAILED;
7146  }
7147  ptr = or_pack_string_with_length (databuf, print_str, print_len);
7148  rc =
7149  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), databuf,
7150  data_len);
7151  db_private_free_and_init (thread_p, databuf);
7152 
7153  if (rc)
7154  {
7155  return ER_FAILED;
7156  }
7157 
7158  return NO_ERROR;
7159 }
7160 
7161 /*
7162  * xio_send_user_prompt_to_client -
7163  *
7164  * return:
7165  *
7166  * prompt_id(in):
7167  * prompt(in):
7168  * failure_prompt(in):
7169  * range_low(in):
7170  * range_high(in):
7171  * secondary_prompt(in):
7172  * reprompt_value(in):
7173  *
7174  * NOTE:
7175  * can be called only in the context of a net_client_callback
7176  * that is waiting for the size of 3 integers to be returned.
7177  * presently, on the client side that is bo_backup.
7178  */
7179 int
7180 xio_send_user_prompt_to_client (THREAD_ENTRY * thread_p, FILEIO_REMOTE_PROMPT_TYPE prompt_id, const char *prompt,
7181  const char *failure_prompt, int range_low, int range_high, const char *secondary_prompt,
7182  int reprompt_value)
7183 {
7184  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
7185  char *reply = OR_ALIGNED_BUF_START (a_reply);
7186  int prompt_length, strlen1, strlen2, strlen3;
7187  unsigned int rid, rc;
7188  char *ptr;
7189  char *databuf;
7190 
7191  rid = css_get_comm_request_id (thread_p);
7192  /* need to know length of prompt string we are sending */
7193  prompt_length = (or_packed_string_length (prompt, &strlen1) + or_packed_string_length (failure_prompt, &strlen2)
7194  + OR_INT_SIZE * 2 + or_packed_string_length (secondary_prompt, &strlen3) + OR_INT_SIZE);
7195 
7196  /*
7197  * Client side caller must be expecting a reply/callback followed
7198  * by 2 ints, otherwise client will abort due to protocol error
7199  * Prompt_length tells the receiver how big the followon message is.
7200  */
7201  ptr = or_pack_int (reply, (int) ASYNC_OBTAIN_USER_INPUT);
7202  ptr = or_pack_int (ptr, (int) prompt_id);
7203  ptr = or_pack_int (ptr, prompt_length);
7204 
7205  databuf = (char *) db_private_alloc (thread_p, prompt_length);
7206  if (databuf == NULL)
7207  {
7208  return ER_FAILED;
7209  }
7210 
7211  ptr = or_pack_string_with_length (databuf, prompt, strlen1);
7212  ptr = or_pack_string_with_length (ptr, failure_prompt, strlen2);
7213  ptr = or_pack_int (ptr, range_low);
7214  ptr = or_pack_int (ptr, range_high);
7215  ptr = or_pack_string_with_length (ptr, secondary_prompt, strlen3);
7216  ptr = or_pack_int (ptr, reprompt_value);
7217 
7218  rc =
7219  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), databuf,
7220  prompt_length);
7221  db_private_free_and_init (thread_p, databuf);
7222 
7223  if (rc)
7224  {
7225  return ER_FAILED;
7226  }
7227 
7228  return NO_ERROR;
7229 }
7230 
7231 /*
7232  * xlog_send_log_pages_to_client -
7233  *
7234  * return:
7235  * NOTE:
7236  */
7237 int
7238 xlog_send_log_pages_to_client (THREAD_ENTRY * thread_p, char *logpg_area, int area_size, LOGWR_MODE mode)
7239 {
7240  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
7241  char *reply = OR_ALIGNED_BUF_START (a_reply);
7242  unsigned int rid, rc;
7243  char *ptr;
7244 
7245  rid = css_get_comm_request_id (thread_p);
7246 
7247  /*
7248  * Client side caller must be expecting a reply/callback followed
7249  * by 2 ints, otherwise client will abort due to protocol error
7250  * Prompt_length tells the receiver how big the followon message is.
7251  */
7252  ptr = or_pack_int (reply, (int) GET_NEXT_LOG_PAGES);
7253  ptr = or_pack_int (ptr, (int) area_size);
7254 
7255  rc =
7256  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), logpg_area,
7257  area_size);
7258  if (rc)
7259  {
7260  return ER_FAILED;
7261  }
7262 
7263  er_log_debug (ARG_FILE_LINE, "xlog_send_log_pages_to_client\n");
7264 
7265  return NO_ERROR;
7266 }
7267 
7268 /*
7269  * xlog_get_page_request_with_reply
7270  *
7271  * return:
7272  * NOTE:
7273  */
7274 int
7275 xlog_get_page_request_with_reply (THREAD_ENTRY * thread_p, LOG_PAGEID * fpageid_ptr, LOGWR_MODE * mode_ptr, int timeout)
7276 {
7277  char *reply = NULL;
7278  int reply_size;
7279  LOG_PAGEID first_pageid;
7280  int mode;
7281  char *ptr;
7282  int error;
7283  int remote_error;
7284 
7285  /* Obtain success message from the client, without blocking the server. */
7286  error = xs_receive_data_from_client_with_timeout (thread_p, &reply, &reply_size, timeout);
7287  if (error != NO_ERROR)
7288  {
7289  if (reply)
7290  {
7291  free_and_init (reply);
7292  }
7293 
7294  return error;
7295  }
7296 
7297  assert (reply != NULL);
7298  ptr = or_unpack_int64 (reply, &first_pageid);
7299  ptr = or_unpack_int (ptr, &mode);
7300  ptr = or_unpack_int (ptr, &remote_error);
7301  free_and_init (reply);
7302 
7303  *fpageid_ptr = first_pageid;
7304  *mode_ptr = (LOGWR_MODE) mode;
7305 
7306  er_log_debug (ARG_FILE_LINE, "xlog_get_page_request_with_reply, " "fpageid(%lld), mode(%s)\n", first_pageid,
7307  mode == LOGWR_MODE_SYNC ? "sync" : (mode == LOGWR_MODE_ASYNC ? "async" : "semisync"));
7308  return (remote_error != NO_ERROR) ? remote_error : error;
7309 }
7310 
7311 /*
7312  * shf_get_class_num_objs_and_pages -
7313  *
7314  * return:
7315  *
7316  * rid(in):
7317  * request(in):
7318  * reqlen(in):
7319  *
7320  * NOTE:
7321  */
7322 void
7323 shf_get_class_num_objs_and_pages (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7324 {
7325  HFID hfid;
7326  int success, approximation, nobjs, npages;
7327  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
7328  char *reply = OR_ALIGNED_BUF_START (a_reply);
7329  char *ptr;
7330 
7331  ptr = or_unpack_hfid (request, &hfid);
7332  ptr = or_unpack_int (ptr, &approximation);
7333 
7334  success = ((xheap_get_class_num_objects_pages (thread_p, &hfid, approximation, &nobjs, &npages) == NO_ERROR)
7335  ? NO_ERROR : ER_FAILED);
7336 
7337  if (success != NO_ERROR)
7338  {
7339  (void) return_error_to_client (thread_p, rid);
7340  }
7341 
7342  ptr = or_pack_int (reply, (int) success);
7343  ptr = or_pack_int (ptr, (int) nobjs);
7344  ptr = or_pack_int (ptr, (int) npages);
7345 
7346  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7347 }
7348 
7349 /*
7350  * sbtree_get_statistics -
7351  *
7352  * return:
7353  *
7354  * rid(in):
7355  * request(in):
7356  * reqlen(in):
7357  *
7358  * NOTE:
7359  */
7360 void
7361 sbtree_get_statistics (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7362 {
7363  BTREE_STATS stat_info;
7364  int success;
7365  OR_ALIGNED_BUF (OR_INT_SIZE * 5) a_reply;
7366  char *reply = OR_ALIGNED_BUF_START (a_reply);
7367  char *ptr;
7368 
7369  ptr = or_unpack_btid (request, &stat_info.btid);
7370  assert_release (!BTID_IS_NULL (&stat_info.btid));
7371 
7372  stat_info.keys = 0;
7373  stat_info.pkeys_size = 0; /* do not request pkeys info */
7374  stat_info.pkeys = NULL;
7375 
7376  success = btree_get_stats (thread_p, &stat_info, STATS_WITH_SAMPLING);
7377  if (success != NO_ERROR)
7378  {
7379  (void) return_error_to_client (thread_p, rid);
7380  }
7381 
7382  ptr = or_pack_int (reply, success);
7383  ptr = or_pack_int (ptr, stat_info.leafs);
7384  ptr = or_pack_int (ptr, stat_info.pages);
7385  ptr = or_pack_int (ptr, stat_info.height);
7386  ptr = or_pack_int (ptr, stat_info.keys);
7387 
7388  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7389 }
7390 
7391 /*
7392  * sbtree_get_key_type () - Obtains key type from index b-tree.
7393  *
7394  * return :
7395  * thread_p (in) :
7396  * rid (in) :
7397  * request (in) :
7398  * int reqlen (in) :
7399  */
7400 void
7401 sbtree_get_key_type (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7402 {
7403  BTID btid;
7404  int error;
7405  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
7406  char *reply = OR_ALIGNED_BUF_START (a_reply);
7407  char *reply_data = NULL;
7408  char *ptr;
7409  int reply_data_size;
7410  TP_DOMAIN *key_type = NULL;
7411 
7412  /* Unpack BTID */
7413  ptr = or_unpack_btid (request, &btid);
7414  assert_release (!BTID_IS_NULL (&btid));
7415 
7416  /* Get key type */
7417  error = xbtree_get_key_type (thread_p, btid, &key_type);
7418  if (error != NO_ERROR && er_errid () != NO_ERROR)
7419  {
7420  (void) return_error_to_client (thread_p, rid);
7421  }
7422 
7423  if (key_type != NULL)
7424  {
7425  /* Send key type to client */
7426  reply_data_size = or_packed_domain_size (key_type, 0);
7427  reply_data = (char *) malloc (reply_data_size);
7428  if (reply_data == NULL)
7429  {
7430  error = ER_OUT_OF_VIRTUAL_MEMORY;
7431  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error, 1, (size_t) reply_data_size);
7432  reply_data_size = 0;
7433  }
7434  else
7435  {
7436  (void) or_pack_domain (reply_data, key_type, 0, 0);
7437  }
7438  }
7439  else
7440  {
7441  reply_data_size = 0;
7442  reply_data = NULL;
7443  error = (error == NO_ERROR) ? ER_FAILED : error;
7444  }
7445 
7446  ptr = or_pack_int (reply, reply_data_size);
7447  ptr = or_pack_int (ptr, error);
7448 
7449  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), reply_data,
7450  reply_data_size);
7451 
7452  if (reply_data != NULL)
7453  {
7454  free_and_init (reply_data);
7455  }
7456 }
7457 
7458 /*
7459  * sqp_get_server_info -
7460  *
7461  * return:
7462  *
7463  * rid(in):
7464  * request(in):
7465  * reqlen(in):
7466  *
7467  * NOTE:
7468  */
7469 void
7470 sqp_get_server_info (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7471 {
7472  int success = NO_ERROR;
7474  char *reply = OR_ALIGNED_BUF_START (a_reply);
7475  char *ptr, *buffer = NULL;
7476  int buffer_length;
7477  int server_info_bits;
7478 
7479  DB_VALUE dt_dbval, ts_dbval; /* SI_SYS_DATETIME */
7480  DB_VALUE lt_dbval; /* SI_LOCAL_TRANSACTION_ID */
7481 
7482  ptr = or_unpack_int (request, &server_info_bits);
7483 
7484  buffer_length = 0;
7485 
7486  if (server_info_bits & SI_SYS_DATETIME)
7487  {
7488  success = db_sys_date_and_epoch_time (&dt_dbval, &ts_dbval);
7489  if (success != NO_ERROR)
7490  {
7491  goto error_exit;
7492  }
7493  buffer_length += OR_VALUE_ALIGNED_SIZE (&dt_dbval);
7494  buffer_length += OR_VALUE_ALIGNED_SIZE (&ts_dbval);
7495  }
7496 
7497  if (server_info_bits & SI_LOCAL_TRANSACTION_ID)
7498  {
7499  success = xtran_get_local_transaction_id (thread_p, &lt_dbval);
7500  if (success != NO_ERROR)
7501  {
7502  goto error_exit;
7503  }
7504  buffer_length += OR_VALUE_ALIGNED_SIZE (&lt_dbval);
7505  }
7506 
7507  buffer = (char *) db_private_alloc (thread_p, buffer_length);
7508  if (buffer == NULL)
7509  {
7510  success = ER_OUT_OF_VIRTUAL_MEMORY;
7511  goto error_exit;
7512  }
7513 
7514  ptr = buffer;
7515 
7516  if (server_info_bits & SI_SYS_DATETIME)
7517  {
7518  ptr = or_pack_value (ptr, &dt_dbval);
7519  ptr = or_pack_value (ptr, &ts_dbval);
7520  }
7521 
7522  if (server_info_bits & SI_LOCAL_TRANSACTION_ID)
7523  {
7524  ptr = or_pack_value (ptr, &lt_dbval);
7525  }
7526 
7527 #if !defined(NDEBUG)
7528  /* suppress valgrind UMW error */
7529  memset (ptr, 0, buffer_length - (ptr - buffer));
7530 #endif
7531 
7532 exit:
7533  ptr = or_pack_int (reply, buffer_length);
7534  ptr = or_pack_int (ptr, success);
7535 
7536  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), buffer,
7537  buffer_length);
7538  if (buffer != NULL)
7539  {
7540  db_private_free_and_init (thread_p, buffer);
7541  }
7542 
7543  return;
7544 
7545 error_exit:
7546  buffer_length = 0;
7547  (void) return_error_to_client (thread_p, rid);
7548 
7549  goto exit;
7550 }
7551 
7552 /*
7553  * sprm_server_change_parameters () - Changes server's system parameter
7554  * values.
7555  *
7556  * return :
7557  * thread_p (in) :
7558  * rid (in) :
7559  * request (in) :
7560  * reqlen (in) :
7561  */
7562 void
7563 sprm_server_change_parameters (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7564 {
7565  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7566  char *reply = OR_ALIGNED_BUF_START (a_reply);
7567  SYSPRM_ASSIGN_VALUE *assignments = NULL;
7568 
7569  (void) sysprm_unpack_assign_values (request, &assignments);
7570 
7571  xsysprm_change_server_parameters (assignments);
7572 
7573  (void) or_pack_int (reply, PRM_ERR_NO_ERROR);
7574  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7575 
7576  sysprm_free_assign_values (&assignments);
7577 }
7578 
7579 /*
7580  * sprm_server_get_force_parameters () - Obtains values for server's system
7581  * parameters that are marked with
7582  * PRM_FORCE_SERVER flag.
7583  *
7584  * return :
7585  * thread_p (in) :
7586  * rid (in) :
7587  * request (in) :
7588  * reqlen (in) :
7589  */
7590 void
7591 sprm_server_get_force_parameters (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7592 {
7593  SYSPRM_ASSIGN_VALUE *change_values;
7594  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
7595  char *reply = OR_ALIGNED_BUF_START (a_reply);
7596  int area_size;
7597  char *area = NULL, *ptr = NULL;
7598 
7599  change_values = xsysprm_get_force_server_parameters ();
7600  if (change_values == NULL)
7601  {
7602  (void) return_error_to_client (thread_p, rid);
7603  }
7604 
7605  area_size = sysprm_packed_assign_values_length (change_values, 0);
7606  area = (char *) malloc (area_size);
7607  if (area == NULL)
7608  {
7610  (void) return_error_to_client (thread_p, rid);
7611  area_size = 0;
7612  }
7613  ptr = or_pack_int (reply, area_size);
7614  ptr = or_pack_int (ptr, er_errid ());
7615 
7616  (void) sysprm_pack_assign_values (area, change_values);
7617  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), area, area_size);
7618 
7619  if (area != NULL)
7620  {
7621  free_and_init (area);
7622  }
7623  sysprm_free_assign_values (&change_values);
7624 }
7625 
7626 /*
7627  * sprm_server_obtain_parameters () - Obtains server's system parameter values
7628  * for the requested parameters.
7629  *
7630  * return :
7631  * thread_p (in) :
7632  * rid (in) :
7633  * request (in) :
7634  * reqlen (in) :
7635  */
7636 void
7637 sprm_server_obtain_parameters (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7638 {
7640  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
7641  char *reply = OR_ALIGNED_BUF_START (a_reply);
7642  char *ptr = NULL, *reply_data = NULL;
7643  int reply_data_size;
7644  SYSPRM_ASSIGN_VALUE *prm_values = NULL;
7645 
7646  (void) sysprm_unpack_assign_values (request, &prm_values);
7647  xsysprm_obtain_server_parameters (prm_values);
7648  reply_data_size = sysprm_packed_assign_values_length (prm_values, 0);
7649  reply_data = (char *) malloc (reply_data_size);
7650  if (reply_data == NULL)
7651  {
7652  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) reply_data_size);
7654  reply_data_size = 0;
7655  }
7656  else
7657  {
7658  (void) sysprm_pack_assign_values (reply_data, prm_values);
7659  }
7660  ptr = or_pack_int (reply, reply_data_size);
7661  ptr = or_pack_int (ptr, rc);
7662  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), reply_data,
7663  reply_data_size);
7664  if (reply_data != NULL)
7665  {
7666  free_and_init (reply_data);
7667  }
7668  if (prm_values != NULL)
7669  {
7670  sysprm_free_assign_values (&prm_values);
7671  }
7672 }
7673 
7674 /*
7675  * sprm_server_dump_parameters -
7676  *
7677  * return:
7678  *
7679  * rid(in):
7680  * request(in):
7681  * reqlen(in):
7682  */
7683 void
7684 sprm_server_dump_parameters (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7685 {
7686  FILE *outfp;
7687  int file_size;
7688  char *buffer;
7689  int buffer_size;
7690  int send_size;
7691  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7692  char *reply = OR_ALIGNED_BUF_START (a_reply);
7693 
7694  (void) or_unpack_int (request, &buffer_size);
7695 
7696  buffer = (char *) db_private_alloc (thread_p, buffer_size);
7697  if (buffer == NULL)
7698  {
7699  css_send_abort_to_client (thread_p->conn_entry, rid);
7700  return;
7701  }
7702 
7703  outfp = tmpfile ();
7704  if (outfp == NULL)
7705  {
7707  css_send_abort_to_client (thread_p->conn_entry, rid);
7708  db_private_free_and_init (thread_p, buffer);
7709  return;
7710  }
7711 
7713  file_size = ftell (outfp);
7714 
7715  /*
7716  * Send the file in pieces
7717  */
7718  rewind (outfp);
7719 
7720  (void) or_pack_int (reply, (int) file_size);
7721  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7722 
7723  while (file_size > 0)
7724  {
7725  if (file_size > buffer_size)
7726  {
7727  send_size = buffer_size;
7728  }
7729  else
7730  {
7731  send_size = file_size;
7732  }
7733 
7734  file_size -= send_size;
7735  if (fread (buffer, 1, send_size, outfp) == 0)
7736  {
7738  css_send_abort_to_client (thread_p->conn_entry, rid);
7739  /*
7740  * Continue sending the stuff that was prmoised to client. In this case
7741  * junk (i.e., whatever it is in the buffers) is sent.
7742  */
7743  }
7744  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
7745  }
7746 
7747  fclose (outfp);
7748  db_private_free_and_init (thread_p, buffer);
7749 }
7750 
7751 /*
7752  * shf_has_instance -
7753  *
7754  * return:
7755  *
7756  * rid(in):
7757  * request(in):
7758  * reqlen(in):
7759  *
7760  * NOTE:
7761  */
7762 void
7763 shf_has_instance (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7764 {
7765  HFID hfid;
7766  OID class_oid;
7767  int r;
7768  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7769  char *reply = OR_ALIGNED_BUF_START (a_reply);
7770  char *ptr;
7771  int has_visible_instance;
7772 
7773  ptr = or_unpack_hfid (request, &hfid);
7774  ptr = or_unpack_oid (ptr, &class_oid);
7775  ptr = or_unpack_int (ptr, &has_visible_instance);
7776 
7777  r = xheap_has_instance (thread_p, &hfid, &class_oid, has_visible_instance);
7778 
7779  if (r == -1)
7780  {
7781  (void) return_error_to_client (thread_p, rid);
7782  }
7783 
7784  ptr = or_pack_int (reply, (int) r);
7785 
7786  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7787 }
7788 
7789 /*
7790  * stran_get_local_transaction_id -
7791  *
7792  * return:
7793  *
7794  * rid(in):
7795  * request(in):
7796  * reqlen(in):
7797  *
7798  * NOTE:
7799  */
7800 void
7801 stran_get_local_transaction_id (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7802 {
7804  char *reply = OR_ALIGNED_BUF_START (a_reply);
7805  char *ptr;
7806  DB_VALUE val;
7807  int success, trid;
7808 
7809  success = (xtran_get_local_transaction_id (thread_p, &val) == NO_ERROR) ? NO_ERROR : ER_FAILED;
7810  trid = db_get_int (&val);
7811  ptr = or_pack_int (reply, success);
7812  ptr = or_pack_int (ptr, trid);
7813  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7814 }
7815 
7816 /*
7817  * sjsp_get_server_port -
7818  *
7819  * return:
7820  *
7821  * rid(in):
7822  *
7823  * NOTE:
7824  */
7825 void
7826 sjsp_get_server_port (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7827 {
7828  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7829  char *reply = OR_ALIGNED_BUF_START (a_reply);
7830 
7831  (void) or_pack_int (reply, jsp_server_port ());
7832  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7833 }
7834 
7835 /*
7836  * srepl_set_info -
7837  *
7838  * return:
7839  *
7840  * rid(in):
7841  * request(in):
7842  * reqlen(in):
7843  *
7844  * NOTE:
7845  */
7846 void
7847 srepl_set_info (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7848 {
7849  int success = NO_ERROR;
7850  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7851  char *reply = OR_ALIGNED_BUF_START (a_reply);
7852  char *ptr;
7853  REPL_INFO repl_info = { NULL, 0, false };
7854  REPL_INFO_SBR repl_schema = { 0, NULL, NULL, NULL, NULL };
7855 
7856  if (!LOG_CHECK_LOG_APPLIER (thread_p) && log_does_allow_replication () == true)
7857  {
7858  ptr = or_unpack_int (request, &repl_info.repl_info_type);
7859  switch (repl_info.repl_info_type)
7860  {
7861  case REPL_INFO_TYPE_SBR:
7862  {
7863  ptr = or_unpack_int (ptr, &repl_schema.statement_type);
7864  ptr = or_unpack_string_nocopy (ptr, &repl_schema.name);
7865  ptr = or_unpack_string_nocopy (ptr, &repl_schema.stmt_text);
7866  ptr = or_unpack_string_nocopy (ptr, &repl_schema.db_user);
7867  ptr = or_unpack_string_nocopy (ptr, &repl_schema.sys_prm_context);
7868 
7869  repl_info.info = (char *) &repl_schema;
7870  break;
7871  }
7872  default:
7873  success = ER_FAILED;
7874  break;
7875  }
7876 
7877  if (success == NO_ERROR)
7878  {
7879  success = xrepl_set_info (thread_p, &repl_info);
7880  }
7881  }
7882 
7883  (void) or_pack_int (reply, success);
7884  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7885 }
7886 
7887 /*
7888  * srepl_log_get_append_lsa -
7889  *
7890  * return:
7891  *
7892  * rid(in):
7893  * request(in):
7894  * reqlen(in):
7895  *
7896  * NOTE:
7897  */
7898 void
7899 srepl_log_get_append_lsa (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7900 {
7902  char *reply = OR_ALIGNED_BUF_START (a_reply);
7903  LOG_LSA *lsa;
7904 
7905  lsa = xrepl_log_get_append_lsa ();
7906 
7907  reply = OR_ALIGNED_BUF_START (a_reply);
7908  (void) or_pack_log_lsa (reply, lsa);
7909 
7910  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7911 }
7912 
7913 /*
7914  * slocator_check_fk_validity -
7915  *
7916  * return:
7917  *
7918  * rid(in):
7919  * request(in):
7920  * reqlen(in):
7921  *
7922  * NOTE:
7923  */
7924 void
7925 slocator_check_fk_validity (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7926 {
7927  OID class_oid;
7928  HFID hfid;
7929  OID pk_cls_oid;
7930  BTID pk_btid;
7931  int n_attrs, *attr_ids = NULL;
7932  TP_DOMAIN *key_type;
7933  char *fk_name = NULL;
7934  char *ptr;
7935  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
7936  char *reply = OR_ALIGNED_BUF_START (a_reply);
7937 
7938  ptr = or_unpack_oid (request, &class_oid);
7939  ptr = or_unpack_hfid (ptr, &hfid);
7940  ptr = or_unpack_domain (ptr, &key_type, 0);
7941  ptr = or_unpack_int (ptr, &n_attrs);
7942  ptr = or_unpack_int_array (ptr, n_attrs, &attr_ids);
7943  if (ptr == NULL)
7944  {
7945  (void) return_error_to_client (thread_p, rid);
7946  goto end;
7947  }
7948 
7949  ptr = or_unpack_oid (ptr, &pk_cls_oid);
7950  ptr = or_unpack_btid (ptr, &pk_btid);
7951  ptr = or_unpack_string (ptr, &fk_name);
7952 
7953  if (xlocator_check_fk_validity (thread_p, &class_oid, &hfid, key_type, n_attrs, attr_ids, &pk_cls_oid, &pk_btid,
7954  fk_name) != NO_ERROR)
7955  {
7956  (void) return_error_to_client (thread_p, rid);
7957  }
7958 
7959 end:
7960 
7961  ptr = or_pack_int (reply, er_errid ());
7962  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
7963 
7964  if (attr_ids != NULL)
7965  {
7966  db_private_free_and_init (thread_p, attr_ids);
7967  }
7968 
7969  if (fk_name != NULL)
7970  {
7971  db_private_free_and_init (thread_p, fk_name);
7972  }
7973 }
7974 
7975 /*
7976  * slogwr_get_log_pages -
7977  *
7978  * return:
7979  *
7980  * thread_p(in):
7981  * rid(in):
7982  * request(in):
7983  * reqlen(in):
7984  *
7985  * Note:
7986  */
7987 void
7988 slogwr_get_log_pages (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
7989 {
7990  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
7991  char *reply = OR_ALIGNED_BUF_START (a_reply);
7992  char *ptr;
7993  LOG_PAGEID first_pageid;
7994  LOGWR_MODE mode;
7995  int m, error, remote_error;
7996 
7997  ptr = or_unpack_int64 (request, &first_pageid);
7998  ptr = or_unpack_int (ptr, &m);
7999  mode = (LOGWR_MODE) m;
8000  ptr = or_unpack_int (ptr, &remote_error);
8001 
8002  error = xlogwr_get_log_pages (thread_p, first_pageid, mode);
8003  if (error == ER_INTERRUPTED)
8004  {
8005  (void) return_error_to_client (thread_p, rid);
8006  }
8007 
8008  if (error == ER_NET_DATA_RECEIVE_TIMEDOUT)
8009  {
8010  css_end_server_request (thread_p->conn_entry);
8011  }
8012  else
8013  {
8014  ptr = or_pack_int (reply, (int) END_CALLBACK);
8015  ptr = or_pack_int (ptr, error);
8016  (void) css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8017  }
8018 
8019  return;
8020 }
8021 
8022 /*
8023  * sboot_compact_db -
8024  *
8025  * return:
8026  *
8027  * rid(in):
8028  * request(in):
8029  * reqlen(in):
8030  *
8031  * NOTE:
8032  */
8033 void
8034 sboot_compact_db (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8035 {
8036  int success, n_classes, reply_size, i;
8037  char *reply = NULL;
8038  OID *class_oids = NULL;
8039  int *ids_repr = NULL;
8040  char *ptr = NULL;
8041  int space_to_process = 0, instance_lock_timeout = 0, delete_old_repr = 0;
8042  int class_lock_timeout = 0;
8043  OID last_processed_class_oid, last_processed_oid;
8045  int *modified_objects = NULL, *big_objects = NULL;
8046 
8047  ptr = or_unpack_int (request, &n_classes);
8048  if (ptr == NULL)
8049  {
8050  (void) return_error_to_client (thread_p, rid);
8051  return;
8052  }
8053 
8054  ptr = or_unpack_oid_array (ptr, n_classes, &class_oids);
8055  if (ptr == NULL)
8056  {
8057  (void) return_error_to_client (thread_p, rid);
8058  return;
8059  }
8060 
8061  ptr = or_unpack_int (ptr, &space_to_process);
8062  if (ptr == NULL)
8063  {
8064  (void) return_error_to_client (thread_p, rid);
8065  return;
8066  }
8067 
8068  ptr = or_unpack_int (ptr, &instance_lock_timeout);
8069  if (ptr == NULL)
8070  {
8071  (void) return_error_to_client (thread_p, rid);
8072  return;
8073  }
8074 
8075  ptr = or_unpack_int (ptr, &class_lock_timeout);
8076  if (ptr == NULL)
8077  {
8078  (void) return_error_to_client (thread_p, rid);
8079  return;
8080  }
8081 
8082  ptr = or_unpack_int (ptr, &delete_old_repr);
8083  if (ptr == NULL)
8084  {
8085  (void) return_error_to_client (thread_p, rid);
8086  return;
8087  }
8088 
8089  ptr = or_unpack_oid (ptr, &last_processed_class_oid);
8090  if (ptr == NULL)
8091  {
8092  (void) return_error_to_client (thread_p, rid);
8093  return;
8094  }
8095 
8096  ptr = or_unpack_oid (ptr, &last_processed_oid);
8097  if (ptr == NULL)
8098  {
8099  (void) return_error_to_client (thread_p, rid);
8100  return;
8101  }
8102 
8103  ptr = or_unpack_int_array (ptr, n_classes, &total_objects);
8104  if (ptr == NULL)
8105  {
8106  (void) return_error_to_client (thread_p, rid);
8107  return;
8108  }
8109 
8110  ptr = or_unpack_int_array (ptr, n_classes, &failed_objects);
8111  if (ptr == NULL)
8112  {
8113  (void) return_error_to_client (thread_p, rid);
8114  return;
8115  }
8116 
8117  ptr = or_unpack_int_array (ptr, n_classes, &modified_objects);
8118  if (ptr == NULL)
8119  {
8120  (void) return_error_to_client (thread_p, rid);
8121  return;
8122  }
8123 
8124  ptr = or_unpack_int_array (ptr, n_classes, &big_objects);
8125  if (ptr == NULL)
8126  {
8127  (void) return_error_to_client (thread_p, rid);
8128  return;
8129  }
8130 
8131  ptr = or_unpack_int_array (ptr, n_classes, &ids_repr);
8132  if (ptr == NULL)
8133  {
8134  (void) return_error_to_client (thread_p, rid);
8135  return;
8136  }
8137 
8138  success =
8139  xboot_compact_db (thread_p, class_oids, n_classes, space_to_process, instance_lock_timeout, class_lock_timeout,
8140  (bool) delete_old_repr, &last_processed_class_oid, &last_processed_oid, total_objects,
8141  failed_objects, modified_objects, big_objects, ids_repr);
8142 
8143  if (success != NO_ERROR)
8144  {
8145  (void) return_error_to_client (thread_p, rid);
8146  }
8147 
8148  reply_size = OR_OID_SIZE * 2 + OR_INT_SIZE * (5 * n_classes + 1);
8149  reply = (char *) db_private_alloc (thread_p, reply_size);
8150  if (reply == NULL)
8151  {
8152  css_send_abort_to_client (thread_p->conn_entry, rid);
8153  db_private_free_and_init (thread_p, class_oids);
8154  db_private_free_and_init (thread_p, ids_repr);
8155  db_private_free_and_init (thread_p, failed_objects);
8156  db_private_free_and_init (thread_p, modified_objects);
8157  db_private_free_and_init (thread_p, big_objects);
8158  db_private_free_and_init (thread_p, total_objects);
8159  return;
8160  }
8161 
8162  ptr = or_pack_int (reply, success);
8163  ptr = or_pack_oid (ptr, &last_processed_class_oid);
8164  ptr = or_pack_oid (ptr, &last_processed_oid);
8165 
8166  for (i = 0; i < n_classes; i++)
8167  {
8168  ptr = or_pack_int (ptr, total_objects[i]);
8169  }
8170 
8171  for (i = 0; i < n_classes; i++)
8172  {
8173  ptr = or_pack_int (ptr, failed_objects[i]);
8174  }
8175 
8176  for (i = 0; i < n_classes; i++)
8177  {
8178  ptr = or_pack_int (ptr, modified_objects[i]);
8179  }
8180 
8181  for (i = 0; i < n_classes; i++)
8182  {
8183  ptr = or_pack_int (ptr, big_objects[i]);
8184  }
8185 
8186  for (i = 0; i < n_classes; i++)
8187  {
8188  ptr = or_pack_int (ptr, ids_repr[i]);
8189  }
8190 
8191  if (css_send_data_to_client (thread_p->conn_entry, rid, reply, reply_size) != NO_ERROR)
8192  {
8193  boot_compact_stop (thread_p);
8194  }
8195 
8196  db_private_free_and_init (thread_p, class_oids);
8197  db_private_free_and_init (thread_p, ids_repr);
8198  db_private_free_and_init (thread_p, failed_objects);
8199  db_private_free_and_init (thread_p, modified_objects);
8200  db_private_free_and_init (thread_p, big_objects);
8201  db_private_free_and_init (thread_p, total_objects);
8202 
8203  db_private_free_and_init (thread_p, reply);
8204 }
8205 
8206 /*
8207  * sboot_heap_compact -
8208  *
8209  * return:
8210  *
8211  * rid(in):
8212  * request(in):
8213  * reqlen(in):
8214  *
8215  * NOTE:
8216  */
8217 void
8218 sboot_heap_compact (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8219 {
8220  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8221  char *reply = OR_ALIGNED_BUF_START (a_reply);
8222  char *ptr;
8223  int success;
8224  OID class_oid;
8225 
8226  ptr = or_unpack_oid (request, &class_oid);
8227  if (ptr == NULL)
8228  {
8229  (void) return_error_to_client (thread_p, rid);
8230  return;
8231  }
8232 
8233  success = xboot_heap_compact (thread_p, &class_oid);
8234  if (success != NO_ERROR)
8235  {
8236  (void) return_error_to_client (thread_p, rid);
8237  }
8238 
8239  or_pack_int (reply, success);
8240 
8241  if (css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply)) != NO_ERROR)
8242  {
8243  boot_compact_stop (thread_p);
8244  }
8245 }
8246 
8247 /*
8248  * sboot_compact_start -
8249  *
8250  * return:
8251  *
8252  * rid(in):
8253  * request(in):
8254  * reqlen(in):
8255  *
8256  * NOTE:
8257  */
8258 void
8259 sboot_compact_start (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8260 {
8261  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8262  char *reply = OR_ALIGNED_BUF_START (a_reply);
8263  int success;
8264 
8265  success = xboot_compact_start (thread_p);
8266  if (success != NO_ERROR)
8267  {
8268  (void) return_error_to_client (thread_p, rid);
8269  }
8270 
8271  or_pack_int (reply, success);
8272 
8273  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8274 }
8275 
8276 /*
8277  * sboot_compact_stop -
8278  *
8279  * return:
8280  *
8281  * rid(in):
8282  * request(in):
8283  * reqlen(in):
8284  *
8285  * NOTE:
8286  */
8287 void
8288 sboot_compact_stop (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8289 {
8290  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8291  char *reply = OR_ALIGNED_BUF_START (a_reply);
8292  int success;
8293 
8294  success = xboot_compact_stop (thread_p);
8295  if (success != NO_ERROR)
8296  {
8297  (void) return_error_to_client (thread_p, rid);
8298  }
8299 
8300  or_pack_int (reply, success);
8301 
8302  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8303 }
8304 
8305 /*
8306  * ses_posix_create_file -
8307  *
8308  * return:
8309  *
8310  * rid(in):
8311  * request(in):
8312  * reqlen(in):
8313  *
8314  * NOTE:
8315  */
8316 void
8317 ses_posix_create_file (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8318 {
8319  char new_path[PATH_MAX];
8320  int path_size = 0, ret;
8321  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
8322  char *reply = OR_ALIGNED_BUF_START (a_reply);
8323  char *ptr;
8324 
8325  ret = xes_posix_create_file (new_path);
8326  if (ret != NO_ERROR)
8327  {
8328  (void) return_error_to_client (thread_p, rid);
8329  }
8330  else
8331  {
8332  path_size = strlen (new_path) + 1;
8333  }
8334 
8335  ptr = or_pack_int (reply, path_size);
8336  ptr = or_pack_int (ptr, ret);
8337  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), new_path,
8338  path_size);
8339 }
8340 
8341 /*
8342  * ses_posix_write_file -
8343  *
8344  * return:
8345  *
8346  * rid(in):
8347  * request(in):
8348  * reqlen(in):
8349  *
8350  * NOTE:
8351  */
8352 void
8353 ses_posix_write_file (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8354 {
8355  char *path;
8356  void *buf = NULL;
8357  off_t offset;
8358  size_t count;
8359  INT64 ret, tmp_int64;
8360  int csserror, buf_size;
8361  OR_ALIGNED_BUF (OR_INT64_SIZE) a_reply;
8362  char *reply = OR_ALIGNED_BUF_START (a_reply);
8363  char *ptr;
8364 
8365  ptr = or_unpack_string_nocopy (request, &path);
8366  ptr = or_unpack_int64 (ptr, &tmp_int64);
8367  offset = (off_t) tmp_int64;
8368  ptr = or_unpack_int64 (ptr, &tmp_int64);
8369  count = (size_t) tmp_int64;
8370 
8371  csserror = css_receive_data_from_client (thread_p->conn_entry, rid, (char **) &buf, &buf_size);
8372  if (csserror)
8373  {
8375  css_send_abort_to_client (thread_p->conn_entry, rid);
8376  }
8377  else
8378  {
8379  ret = xes_posix_write_file (path, buf, count, offset);
8380  if (ret != NO_ERROR)
8381  {
8382  (void) return_error_to_client (thread_p, rid);
8383  }
8384 
8385  ptr = or_pack_int64 (reply, (INT64) ret);
8386  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8387  }
8388  if (buf != NULL)
8389  {
8390  free_and_init (buf);
8391  }
8392 }
8393 
8394 /*
8395  * ses_posix_read_file -
8396  *
8397  * return:
8398  *
8399  * rid(in):
8400  * request(in):
8401  * reqlen(in):
8402  *
8403  * NOTE:
8404  */
8405 void
8406 ses_posix_read_file (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8407 {
8408  char *path;
8409  void *buf;
8410  off_t offset;
8411  size_t count;
8412  INT64 ret, tmp_int64;
8413  OR_ALIGNED_BUF (OR_INT64_SIZE) a_reply;
8414  char *reply = OR_ALIGNED_BUF_START (a_reply);
8415  char *ptr;
8416 
8417  ptr = or_unpack_string_nocopy (request, &path);
8418  ptr = or_unpack_int64 (ptr, &tmp_int64);
8419  offset = (off_t) tmp_int64;
8420  ptr = or_unpack_int64 (ptr, &tmp_int64);
8421  count = (size_t) tmp_int64;
8422 
8423  buf = db_private_alloc (thread_p, count);
8424  if (buf == NULL)
8425  {
8426  css_send_abort_to_client (thread_p->conn_entry, rid);
8427  }
8428  else
8429  {
8430  ret = xes_posix_read_file (path, buf, count, offset);
8431  if (ret != NO_ERROR)
8432  {
8433  (void) return_error_to_client (thread_p, rid);
8434  }
8435 
8436  ptr = or_pack_int64 (reply, (INT64) ret);
8437  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), (char *) buf,
8438  (int) count);
8439  db_private_free_and_init (thread_p, buf);
8440  }
8441 }
8442 
8443 /*
8444  * ses_posix_delete_file -
8445  *
8446  * return:
8447  *
8448  * rid(in):
8449  * request(in):
8450  * reqlen(in):
8451  *
8452  * NOTE:
8453  */
8454 void
8455 ses_posix_delete_file (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8456 {
8457  char *path;
8458  int ret;
8459  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8460  char *reply = OR_ALIGNED_BUF_START (a_reply);
8461  char *ptr;
8462 
8463  ptr = or_unpack_string_nocopy (request, &path);
8464 
8465  ret = xes_posix_delete_file (path);
8466  if (ret != NO_ERROR)
8467  {
8468  (void) return_error_to_client (thread_p, rid);
8469  }
8470 
8471  ptr = or_pack_int (reply, ret);
8472  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8473 }
8474 
8475 /*
8476  * ses_posix_copy_file -
8477  *
8478  * return:
8479  *
8480  * rid(in):
8481  * request(in):
8482  * reqlen(in):
8483  *
8484  * NOTE:
8485  */
8486 void
8487 ses_posix_copy_file (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8488 {
8489  char *src_path, *metaname, new_path[PATH_MAX];
8490  int path_size = 0, ret;
8491  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
8492  char *reply = OR_ALIGNED_BUF_START (a_reply);
8493  char *ptr;
8494 
8495  ptr = or_unpack_string_nocopy (request, &src_path);
8496  ptr = or_unpack_string_nocopy (ptr, &metaname);
8497 
8498  ret = xes_posix_copy_file (src_path, metaname, new_path);
8499  if (ret != NO_ERROR)
8500  {
8501  (void) return_error_to_client (thread_p, rid);
8502  }
8503  else
8504  {
8505  path_size = strlen (new_path) + 1;
8506  }
8507 
8508  ptr = or_pack_int (reply, path_size);
8509  ptr = or_pack_int (ptr, ret);
8510  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), new_path,
8511  path_size);
8512 }
8513 
8514 /*
8515  * ses_posix_rename_file -
8516  *
8517  * return:
8518  *
8519  * rid(in):
8520  * request(in):
8521  * reqlen(in):
8522  *
8523  * NOTE:
8524  */
8525 void
8526 ses_posix_rename_file (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8527 {
8528  char *src_path, *metaname, new_path[PATH_MAX];
8529  int path_size = 0, ret;
8530  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
8531  char *reply = OR_ALIGNED_BUF_START (a_reply);
8532  char *ptr;
8533 
8534  ptr = or_unpack_string_nocopy (request, &src_path);
8535  ptr = or_unpack_string_nocopy (ptr, &metaname);
8536 
8537  ret = xes_posix_rename_file (src_path, metaname, new_path);
8538  if (ret != NO_ERROR)
8539  {
8540  (void) return_error_to_client (thread_p, rid);
8541  }
8542  else
8543  {
8544  path_size = strlen (new_path) + 1;
8545  }
8546 
8547  ptr = or_pack_int (reply, path_size);
8548  ptr = or_pack_int (ptr, ret);
8549  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), new_path,
8550  path_size);
8551 }
8552 
8553 /*
8554  * ses_posix_read_file -
8555  *
8556  * return:
8557  *
8558  * rid(in):
8559  * request(in):
8560  * reqlen(in):
8561  *
8562  * NOTE:
8563  */
8564 void
8565 ses_posix_get_file_size (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8566 {
8567  char *path;
8568  off_t file_size;
8569  OR_ALIGNED_BUF (OR_INT64_SIZE) a_reply;
8570  char *reply = OR_ALIGNED_BUF_START (a_reply);
8571  char *ptr;
8572 
8573  ptr = or_unpack_string_nocopy (request, &path);
8574 
8575  file_size = xes_posix_get_file_size (path);
8576  if (file_size < 0)
8577  {
8578  (void) return_error_to_client (thread_p, rid);
8579  }
8580 
8581  ptr = or_pack_int64 (reply, (INT64) file_size);
8582  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8583 }
8584 
8585 /*
8586  * slocator_upgrade_instances_domain -
8587  *
8588  * return:
8589  *
8590  * rid(in):
8591  * request(in):
8592  * reqlen(in):
8593  *
8594  * NOTE:
8595  */
8596 void
8597 slocator_upgrade_instances_domain (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8598 {
8599  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8600  char *reply = OR_ALIGNED_BUF_START (a_reply);
8601  char *ptr;
8602  OID class_oid;
8603  int attr_id;
8604  int success;
8605 
8606  ptr = request;
8607  ptr = or_unpack_oid (ptr, &class_oid);
8608  ptr = or_unpack_int (ptr, &attr_id);
8609 
8610  success = xlocator_upgrade_instances_domain (thread_p, &class_oid, attr_id);
8611 
8612  if (success != NO_ERROR)
8613  {
8614  (void) return_error_to_client (thread_p, rid);
8615  }
8616 
8617  ptr = or_pack_int (reply, success);
8618  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8619 }
8620 
8621 /*
8622  * ssession_find_or_create_session -
8623  *
8624  * return: void
8625  *
8626  * rid(in):
8627  * request(in):
8628  * reqlen(in):
8629  *
8630  * NOTE: This function checks if a session is still active and creates a new
8631  * one if needed
8632  */
8633 void
8634 ssession_find_or_create_session (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8635 {
8637  int row_count = -1, area_size;
8639  char *reply = OR_ALIGNED_BUF_START (a_reply);
8640  char *ptr = NULL, *area = NULL;
8641  char *db_user = NULL, *host = NULL, *program_name = NULL;
8642  char db_user_upper[DB_MAX_USER_LENGTH] = { '\0' };
8643  char server_session_key[SERVER_SESSION_KEY_SIZE];
8644  SESSION_PARAM *session_params = NULL;
8645  int error = NO_ERROR, update_parameter_values = 0;
8646 
8647  ptr = or_unpack_int (request, (int *) &id);
8648  ptr = or_unpack_stream (ptr, server_session_key, SERVER_SESSION_KEY_SIZE);
8649  ptr = sysprm_unpack_session_parameters (ptr, &session_params);
8650  ptr = or_unpack_string_alloc (ptr, &db_user);
8651  ptr = or_unpack_string_alloc (ptr, &host);
8652  ptr = or_unpack_string_alloc (ptr, &program_name);
8653 
8654  if (id == DB_EMPTY_SESSION
8655  || memcmp (server_session_key, xboot_get_server_session_key (), SERVER_SESSION_KEY_SIZE) != 0
8656  || xsession_check_session (thread_p, id) != NO_ERROR)
8657  {
8658  /* not an error yet */
8659  er_clear ();
8660  /* create new session */
8661  error = xsession_create_new (thread_p, &id);
8662  if (error != NO_ERROR)
8663  {
8664  (void) return_error_to_client (thread_p, rid);
8665  }
8666  }
8667 
8668  /* get row count */
8669  xsession_get_row_count (thread_p, &row_count);
8670 
8671  if (error == NO_ERROR)
8672  {
8673  error = sysprm_session_init_session_parameters (&session_params, &update_parameter_values);
8674  if (error != NO_ERROR)
8675  {
8676  error = sysprm_set_error ((SYSPRM_ERR) error, NULL);
8677  (void) return_error_to_client (thread_p, rid);
8678  }
8679  }
8680 
8681  area_size = 0;
8682  if (error == NO_ERROR)
8683  {
8684  /* key.id */
8685  area_size = OR_INT_SIZE;
8686 
8687  /* row_count */
8688  area_size += OR_INT_SIZE;
8689 
8690  /* server session key */
8692 
8693  /* update_parameter_values */
8694  area_size += OR_INT_SIZE;
8695 
8696  if (update_parameter_values)
8697  {
8698  /* session params */
8699  area_size += sysprm_packed_session_parameters_length (session_params, area_size);
8700  }
8701 
8702  area = (char *) malloc (area_size);
8703  if (area != NULL)
8704  {
8705  ptr = or_pack_int (area, id);
8706  ptr = or_pack_int (ptr, row_count);
8708  ptr = or_pack_int (ptr, update_parameter_values);
8709  if (update_parameter_values)
8710  {
8711  ptr = sysprm_pack_session_parameters (ptr, session_params);
8712  }
8713  }
8714  else
8715  {
8717  error = ER_OUT_OF_VIRTUAL_MEMORY;
8718  area_size = 0;
8719  (void) return_error_to_client (thread_p, rid);
8720  }
8721  }
8722 
8723  if (db_user != NULL)
8724  {
8725  assert (host != NULL);
8726  assert (program_name != NULL);
8727 
8728  intl_identifier_upper (db_user, db_user_upper);
8729  css_set_user_access_status (db_user_upper, host, program_name);
8730 
8731  logtb_set_current_user_name (thread_p, db_user_upper);
8732  }
8733 
8734  free_and_init (db_user);
8735  free_and_init (host);
8736  free_and_init (program_name);
8737 
8738  ptr = or_pack_int (reply, area_size);
8739  ptr = or_pack_int (ptr, error);
8740  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), area, area_size);
8741  if (area != NULL)
8742  {
8743  free_and_init (area);
8744  }
8745 }
8746 
8747 /*
8748  * ssession_end_session -
8749  *
8750  * return: void
8751  *
8752  * rid(in):
8753  * request(in):
8754  * reqlen(in):
8755  *
8756  * NOTE: This function ends the session with the id contained in the request
8757  */
8758 void
8759 ssession_end_session (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8760 {
8761  int err = NO_ERROR;
8762  SESSION_ID id;
8763  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8764  char *reply = OR_ALIGNED_BUF_START (a_reply);
8765  char *ptr = NULL;
8766 
8767  (void) or_unpack_int (request, (int *) &id);
8768 
8769  err = xsession_end_session (thread_p, id);
8770 
8771  ptr = or_pack_int (reply, err);
8772  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8773 }
8774 
8775 /*
8776  * ssession_set_row_count - set the count of affected rows for a session
8777  *
8778  * return: void
8779  *
8780  * rid(in):
8781  * request(in):
8782  * reqlen(in):
8783  *
8784  * NOTE:
8785  */
8786 void
8787 ssession_set_row_count (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8788 {
8789  int err = NO_ERROR;
8790  int row_count = 0;
8791  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8792  char *reply = OR_ALIGNED_BUF_START (a_reply);
8793  char *ptr = NULL;
8794 
8795  (void) or_unpack_int (request, &row_count);
8796 
8797  err = xsession_set_row_count (thread_p, row_count);
8798  if (err != NO_ERROR)
8799  {
8800  (void) return_error_to_client (thread_p, rid);
8801  }
8802 
8803  ptr = or_pack_int (reply, err);
8804  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8805 }
8806 
8807 /*
8808  * ssession_get_row_count - get the count of affected rows for a session
8809  * return: void
8810  * rid(in):
8811  * request(in):
8812  * reqlen(in):
8813  * NOTE:
8814  */
8815 void
8816 ssession_get_row_count (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8817 {
8818  int err = NO_ERROR;
8819  int row_count = 0;
8820  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8821  char *reply = OR_ALIGNED_BUF_START (a_reply);
8822  char *ptr = NULL;
8823 
8824  err = xsession_get_row_count (thread_p, &row_count);
8825  if (err != NO_ERROR)
8826  {
8827  (void) return_error_to_client (thread_p, rid);
8828  }
8829 
8830  ptr = or_pack_int (reply, row_count);
8831  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8832 }
8833 
8834 /*
8835  * ssession_get_last_insert_id - get the value of the last update serial
8836  * return: error code or NO_ERROR
8837  * rid(in):
8838  * request(in):
8839  * reqlen(in):
8840  * NOTE:
8841  */
8842 void
8843 ssession_get_last_insert_id (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8844 {
8845  int err = NO_ERROR;
8846  DB_VALUE lid;
8848  char *reply = OR_ALIGNED_BUF_START (a_reply);
8849  char *data_reply = NULL;
8850  int data_size = 0;
8851  char *ptr = NULL;
8852  int update_last_insert_id;
8853 
8854  (void) or_unpack_int (request, &update_last_insert_id);
8855 
8856  err = xsession_get_last_insert_id (thread_p, &lid, (bool) update_last_insert_id);
8857  if (err != NO_ERROR)
8858  {
8859  (void) return_error_to_client (thread_p, rid);
8860  data_size = 0;
8861  goto end;
8862  }
8863 
8864  data_size = OR_VALUE_ALIGNED_SIZE (&lid);
8865 
8866  data_reply = (char *) db_private_alloc (thread_p, data_size);
8867  if (data_reply == NULL)
8868  {
8869  (void) return_error_to_client (thread_p, rid);
8870  err = ER_FAILED;
8871  data_size = 0;
8872  goto end;
8873  }
8874  or_pack_value (data_reply, &lid);
8875 
8876 end:
8877  ptr = or_pack_int (reply, data_size);
8878  ptr = or_pack_int (ptr, err);
8879 
8880  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply),
8881  OR_ALIGNED_BUF_SIZE (a_reply), data_reply, data_size);
8882 
8883  if (data_reply != NULL)
8884  {
8885  db_private_free (thread_p, data_reply);
8886  }
8887 }
8888 
8889 /*
8890  * ssession_reset_cur_insert_id - reset the current insert id as NULL
8891  * return: error code or NO_ERROR
8892  * rid(in):
8893  * request(in):
8894  * reqlen(in):
8895  * NOTE:
8896  */
8897 void
8898 ssession_reset_cur_insert_id (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8899 {
8900  int err = NO_ERROR;
8901  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8902  char *reply = OR_ALIGNED_BUF_START (a_reply);
8903  char *ptr = NULL;
8904 
8905  err = xsession_reset_cur_insert_id (thread_p);
8906  if (err != NO_ERROR)
8907  {
8908  (void) return_error_to_client (thread_p, rid);
8909  }
8910 
8911  ptr = or_pack_int (reply, err);
8912  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8913 }
8914 
8915 /*
8916  * ssession_create_prepared_statement - create a prepared statement
8917  * return: error code or NO_ERROR
8918  * rid(in):
8919  * request(in):
8920  * reqlen(in):
8921  * NOTE:
8922  */
8923 void
8924 ssession_create_prepared_statement (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
8925 {
8926  /* request data */
8927  char *name = NULL, *alias_print = NULL;
8928  char *reply = NULL, *ptr = NULL;
8929  char *data_request = NULL;
8930  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
8931  int data_size = 0, err = 0;
8932  char *info = NULL;
8933  SHA1Hash alias_sha1 = SHA1_HASH_INITIALIZER;
8934 
8935  reply = OR_ALIGNED_BUF_START (a_reply);
8936 
8937  /* name */
8938  ptr = or_unpack_string_alloc (request, &name);
8939  /* alias_print */
8940  ptr = or_unpack_string_alloc (ptr, &alias_print);
8941  /* data_size */
8942  ptr = or_unpack_int (ptr, &data_size);
8943  if (data_size <= 0)
8944  {
8946  css_send_abort_to_client (thread_p->conn_entry, rid);
8947  goto error;
8948  }
8949  if (alias_print != NULL)
8950  {
8951  /* alias_sha1 */
8952  ptr = or_unpack_sha1 (ptr, &alias_sha1);
8953  }
8954 
8955  err = css_receive_data_from_client (thread_p->conn_entry, rid, &data_request, &data_size);
8956  if (err != NO_ERROR)
8957  {
8959  css_send_abort_to_client (thread_p->conn_entry, rid);
8960  goto error;
8961  }
8962 
8963  /* For prepared statements, on the server side, we only use the user OID, the statement name and the alias print.
8964  * User OID and alias_print are needed as XASL cache key and the statement name is the identifier for the statement.
8965  * The rest of the information will be kept unpacked and sent back to the client when requested */
8966  info = (char *) malloc (data_size);
8967  if (info == NULL)
8968  {
8970  goto error;
8971  }
8972  memcpy (info, data_request, data_size);
8973 
8974  err = xsession_create_prepared_statement (thread_p, name, alias_print, &alias_sha1, info, data_size);
8975 
8976  if (err != NO_ERROR)
8977  {
8978  goto error;
8979  }
8980 
8981  or_pack_int (reply, err);
8982  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8983 
8984  if (data_request != NULL)
8985  {
8986  free_and_init (data_request);
8987  }
8988 
8989  return;
8990 
8991 error:
8992  (void) return_error_to_client (thread_p, rid);
8993  or_pack_int (reply, err);
8994  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
8995 
8996  /* free data */
8997  if (data_request != NULL)
8998  {
8999  free_and_init (data_request);
9000  }
9001  if (name != NULL)
9002  {
9003  free_and_init (name);
9004  }
9005  if (alias_print != NULL)
9006  {
9007  free_and_init (alias_print);
9008  }
9009  if (info != NULL)
9010  {
9011  free_and_init (info);
9012  }
9013 }
9014 
9015 /*
9016  * ssession_get_prepared_statement - create a prepared statement
9017  * return: error code or NO_ERROR
9018  * rid(in):
9019  * request(in):
9020  * reqlen(in):
9021  * NOTE:
9022  */
9023 void
9024 ssession_get_prepared_statement (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9025 {
9026  char *name = NULL, *stmt_info = NULL;
9027  int info_len = 0;
9028  char *reply = NULL, *ptr = NULL, *data_reply = NULL;
9029  int err = NO_ERROR, reply_size = 0;
9030  XASL_ID xasl_id;
9031  /* return code + data length */
9032  OR_ALIGNED_BUF (OR_INT_SIZE * 2 + OR_XASL_ID_SIZE) a_reply;
9033  int get_xasl_header = 0;
9034  XASL_NODE_HEADER xasl_header, *xasl_header_p = NULL;
9035 
9036  /* unpack prepared statement name */
9037  ptr = or_unpack_string (request, &name);
9038  /* unpack get XASL node header boolean */
9039  ptr = or_unpack_int (ptr, &get_xasl_header);
9040  if (get_xasl_header)
9041  {
9042  /* need to get XASL node header too */
9043  xasl_header_p = &xasl_header;
9044  INIT_XASL_NODE_HEADER (xasl_header_p);
9045  }
9046 
9047  err = xsession_get_prepared_statement (thread_p, name, &stmt_info, &info_len, &xasl_id, xasl_header_p);
9048  if (err != NO_ERROR)
9049  {
9050  goto error;
9051  }
9052 
9053  /* pack reply buffer */
9054  reply_size = or_packed_stream_length (info_len); /* smt_info */
9055  if (get_xasl_header)
9056  {
9057  reply_size += XASL_NODE_HEADER_SIZE; /* xasl node header */
9058  }
9059  data_reply = (char *) malloc (reply_size);
9060  if (data_reply == NULL)
9061  {
9062  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) reply_size);
9063  err = ER_FAILED;
9064  goto error;
9065  }
9066 
9067  ptr = or_pack_stream (data_reply, stmt_info, info_len);
9068  if (get_xasl_header)
9069  {
9070  /* pack XASL node header */
9071  OR_PACK_XASL_NODE_HEADER (ptr, xasl_header_p);
9072  }
9073 
9074  reply = OR_ALIGNED_BUF_START (a_reply);
9075 
9076  ptr = or_pack_int (reply, reply_size);
9077  ptr = or_pack_int (ptr, err);
9078  OR_PACK_XASL_ID (ptr, &xasl_id);
9079 
9080  err =
9081  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply),
9082  OR_ALIGNED_BUF_SIZE (a_reply), data_reply, reply_size);
9083  goto cleanup;
9084 
9085 error:
9086  reply_size = 0;
9087  if (data_reply != NULL)
9088  {
9089  free_and_init (data_reply);
9090  }
9091  ptr = OR_ALIGNED_BUF_START (a_reply);
9092  ptr = or_pack_int (ptr, 0);
9093  or_pack_int (ptr, err);
9094 
9095  (void) return_error_to_client (thread_p, rid);
9096 
9097  err =
9098  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply),
9099  OR_ALIGNED_BUF_SIZE (a_reply), data_reply, reply_size);
9100  goto cleanup;
9101 
9102 cleanup:
9103  if (data_reply != NULL)
9104  {
9105  free_and_init (data_reply);
9106  }
9107  if (stmt_info != NULL)
9108  {
9109  free_and_init (stmt_info);
9110  }
9111  if (name != NULL)
9112  {
9113  db_private_free_and_init (thread_p, name);
9114  }
9115 }
9116 
9117 /*
9118  * ssession_delete_prepared_statement - get prepared statement info
9119  * return: error code or NO_ERROR
9120  * rid(in):
9121  * request(in):
9122  * reqlen(in):
9123  * NOTE:
9124  */
9125 void
9126 ssession_delete_prepared_statement (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9127 {
9128  int err = NO_ERROR;
9129  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9130  char *reply = OR_ALIGNED_BUF_START (a_reply);
9131  char *name = NULL;
9132 
9133  or_unpack_string_nocopy (request, &name);
9134  if (name == NULL)
9135  {
9136  (void) return_error_to_client (thread_p, rid);
9137  err = ER_FAILED;
9138  }
9139  else
9140  {
9141  err = xsession_delete_prepared_statement (thread_p, name);
9142  if (err != NO_ERROR)
9143  {
9144  (void) return_error_to_client (thread_p, rid);
9145  }
9146  }
9147 
9148  or_pack_int (reply, err);
9149 
9150  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
9151 }
9152 
9153 /*
9154  * slogin_user - login user
9155  * return: error code or NO_ERROR
9156  * rid(in):
9157  * request(in):
9158  * reqlen(in):
9159  */
9160 void
9161 slogin_user (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9162 {
9163  int err = NO_ERROR;
9164  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9165  char *reply = OR_ALIGNED_BUF_START (a_reply);
9166  char *username = NULL;
9167 
9168  or_unpack_string_nocopy (request, &username);
9169  if (username == NULL)
9170  {
9171  (void) return_error_to_client (thread_p, rid);
9172  err = ER_FAILED;
9173  }
9174  else
9175  {
9176  err = xlogin_user (thread_p, username);
9177  if (err != NO_ERROR)
9178  {
9179  (void) return_error_to_client (thread_p, rid);
9180  }
9181  }
9182 
9183  or_pack_int (reply, err);
9184 
9185  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
9186 }
9187 
9188 /*
9189  * ssession_set_session_variables () - set session variables
9190  * return :void
9191  * thread_p (in) :
9192  * rid (in) :
9193  * request (in) :
9194  * reqlen (in) :
9195  */
9196 void
9197 ssession_set_session_variables (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9198 {
9199  int count = 0, err = NO_ERROR, data_size = 0, i = 0;
9200  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9201  char *reply = NULL, *ptr = NULL, *data_request = NULL;
9202  DB_VALUE *values = NULL;
9203 
9204  /* Unpack count of variables from request */
9205  ptr = or_unpack_int (request, &count);
9206  if (count <= 0)
9207  {
9208  goto cleanup;
9209  }
9210 
9211  /* fetch the values */
9212  err = css_receive_data_from_client (thread_p->conn_entry, rid, &data_request, &data_size);
9213  if (err != NO_ERROR)
9214  {
9216  css_send_abort_to_client (thread_p->conn_entry, rid);
9217  goto cleanup;
9218  }
9219 
9220  values = (DB_VALUE *) malloc (count * sizeof (DB_VALUE));
9221  if (values == NULL)
9222  {
9224  err = ER_FAILED;
9225  goto cleanup;
9226  }
9227 
9228  ptr = data_request;
9229 
9230  /* session variables are packed into an array containing DB_VALUE objects of the form name1, value1, name2, value2,
9231  * name3, value 3... */
9232  for (i = 0; i < count; i++)
9233  {
9234  ptr = or_unpack_db_value (ptr, &values[i]);
9235  }
9236 
9237  err = xsession_set_session_variables (thread_p, values, count);
9238 
9239 cleanup:
9240  if (values != NULL)
9241  {
9242  for (i = 0; i < count; i++)
9243  {
9244  pr_clear_value (&values[i]);
9245  }
9246  free_and_init (values);
9247  }
9248 
9249  if (data_request != NULL)
9250  {
9251  free_and_init (data_request);
9252  }
9253 
9254  reply = OR_ALIGNED_BUF_START (a_reply);
9255 
9256  or_pack_int (reply, err);
9257 
9258  if (err != NO_ERROR)
9259  {
9260  (void) return_error_to_client (thread_p, rid);
9261  }
9262 
9263  css_send_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply), OR_ALIGNED_BUF_SIZE (a_reply));
9264 }
9265 
9266 /*
9267  * ssession_get_session_variable () - get the value of a session variable
9268  * return : void
9269  * thread_p (in) :
9270  * rid (in) :
9271  * request (in) :
9272  * reqlen (in) :
9273  */
9274 void
9275 ssession_get_session_variable (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9276 {
9277  int err = NO_ERROR;
9278  OR_ALIGNED_BUF (OR_INT_SIZE * 2) a_reply;
9279  char *reply = NULL, *ptr = NULL, *data_reply = NULL;
9280  DB_VALUE result, name;
9281  int size = 0;
9282 
9283  db_make_null (&result);
9284  db_make_null (&name);
9285 
9286  reply = OR_ALIGNED_BUF_START (a_reply);
9287 
9288  or_unpack_db_value (request, &name);
9289 
9290  err = xsession_get_session_variable (thread_p, &name, &result);
9291  if (err != NO_ERROR)
9292  {
9293  (void) return_error_to_client (thread_p, rid);
9294  }
9295 
9296  size = or_db_value_size (&result);
9297  data_reply = (char *) malloc (size);
9298  if (data_reply != NULL)
9299  {
9300  or_pack_db_value (data_reply, &result);
9301  }
9302  else
9303  {
9305  (void) return_error_to_client (thread_p, rid);
9306  size = 0;
9307  err = ER_FAILED;
9308  }
9309 
9310  ptr = or_pack_int (reply, size);
9311  ptr = or_pack_int (ptr, err);
9312 
9313  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), data_reply, size);
9314 
9315  pr_clear_value (&result);
9316  pr_clear_value (&name);
9317 
9318  if (data_reply != NULL)
9319  {
9320  free_and_init (data_reply);
9321  }
9322 }
9323 
9324 /*
9325  * svacuum () - Calls vacuum function.
9326  *
9327  * return :
9328  * thread_p (in) :
9329  * rid (in) :
9330  * request (in) :
9331  * reqlen (in) :
9332  */
9333 void
9334 svacuum (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9335 {
9336  int err = NO_ERROR;
9337  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9338  char *reply = NULL;
9339 
9340  reply = OR_ALIGNED_BUF_START (a_reply);
9341 
9342  /* Call vacuum */
9343  err = xvacuum (thread_p);
9344 
9345  if (err != NO_ERROR)
9346  {
9347  (void) return_error_to_client (thread_p, rid);
9348  }
9349 
9350  /* Send error code as reply */
9351  (void) or_pack_int (reply, err);
9352 
9353  /* For now no results are required, just fail/success */
9354  css_send_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply), OR_ALIGNED_BUF_SIZE (a_reply));
9355 }
9356 
9357 /*
9358  * svacuum_dump -
9359  *
9360  * return:
9361  *
9362  * rid(in):
9363  * request(in):
9364  * reqlen(in):
9365  *
9366  * NOTE:
9367  */
9368 void
9369 svacuum_dump (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9370 {
9371  FILE *outfp;
9372  int file_size;
9373  char *buffer;
9374  int buffer_size;
9375  int send_size;
9376  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9377  char *reply = OR_ALIGNED_BUF_START (a_reply);
9378 
9379  (void) or_unpack_int (request, &buffer_size);
9380 
9381  buffer = (char *) db_private_alloc (thread_p, buffer_size);
9382  if (buffer == NULL)
9383  {
9384  css_send_abort_to_client (thread_p->conn_entry, rid);
9385  return;
9386  }
9387 
9388  outfp = tmpfile ();
9389  if (outfp == NULL)
9390  {
9392  css_send_abort_to_client (thread_p->conn_entry, rid);
9393  db_private_free_and_init (thread_p, buffer);
9394  return;
9395  }
9396 
9397  xvacuum_dump (thread_p, outfp);
9398  file_size = ftell (outfp);
9399 
9400  /*
9401  * Send the file in pieces
9402  */
9403  rewind (outfp);
9404 
9405  (void) or_pack_int (reply, (int) file_size);
9406  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
9407 
9408  while (file_size > 0)
9409  {
9410  if (file_size > buffer_size)
9411  {
9412  send_size = buffer_size;
9413  }
9414  else
9415  {
9416  send_size = file_size;
9417  }
9418 
9419  file_size -= send_size;
9420  if (fread (buffer, 1, send_size, outfp) == 0)
9421  {
9423  css_send_abort_to_client (thread_p->conn_entry, rid);
9424  /*
9425  * Continue sending the stuff that was prmoised to client. In this case
9426  * junk (i.e., whatever it is in the buffers) is sent.
9427  */
9428  }
9429  css_send_data_to_client (thread_p->conn_entry, rid, buffer, send_size);
9430  }
9431  fclose (outfp);
9432  db_private_free_and_init (thread_p, buffer);
9433 }
9434 
9435 /*
9436  * slogtb_get_mvcc_snapshot () - Get MVCC Snapshot.
9437  *
9438  * return :
9439  * thread_p (in) :
9440  * rid (in) :
9441  * request (in) :
9442  * reqlen (in) :
9443  */
9444 void
9445 slogtb_get_mvcc_snapshot (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9446 {
9447  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9448  char *reply = NULL;
9449  int err;
9450 
9451  err = xlogtb_get_mvcc_snapshot (thread_p);
9452 
9453  reply = OR_ALIGNED_BUF_START (a_reply);
9454 
9455  (void) or_pack_int (reply, err);
9456 
9457  if (err != NO_ERROR)
9458  {
9459  (void) return_error_to_client (thread_p, rid);
9460  }
9461 
9462  css_send_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply), OR_ALIGNED_BUF_SIZE (a_reply));
9463 }
9464 
9465 /*
9466  * ssession_drop_session_variables () - drop session variables
9467  * return : void
9468  * thread_p (in) :
9469  * rid (in) :
9470  * request (in) :
9471  * reqlen (in) :
9472  */
9473 void
9474 ssession_drop_session_variables (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9475 {
9476  int count = 0, err = NO_ERROR, data_size = 0, i = 0;
9477  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9478  char *reply = NULL, *ptr = NULL, *data_request = NULL;
9479  DB_VALUE *values = NULL;
9480 
9481  /* Unpack count of variables from request */
9482  ptr = or_unpack_int (request, &count);
9483  if (count <= 0)
9484  {
9485  goto cleanup;
9486  }
9487 
9488  /* fetch the values */
9489  err = css_receive_data_from_client (thread_p->conn_entry, rid, &data_request, &data_size);
9490  if (err != NO_ERROR)
9491  {
9493  css_send_abort_to_client (thread_p->conn_entry, rid);
9494  goto cleanup;
9495  }
9496 
9497  values = (DB_VALUE *) malloc (count * sizeof (DB_VALUE));
9498  if (values == NULL)
9499  {
9501  err = ER_FAILED;
9502  goto cleanup;
9503  }
9504 
9505  ptr = data_request;
9506  for (i = 0; i < count; i++)
9507  {
9508  ptr = or_unpack_db_value (ptr, &values[i]);
9509  }
9510 
9511  err = xsession_drop_session_variables (thread_p, values, count);
9512 
9513 cleanup:
9514  if (values != NULL)
9515  {
9516  for (i = 0; i < count; i++)
9517  {
9518  pr_clear_value (&values[i]);
9519  }
9520  free_and_init (values);
9521  }
9522 
9523  if (data_request != NULL)
9524  {
9525  free_and_init (data_request);
9526  }
9527 
9528  reply = OR_ALIGNED_BUF_START (a_reply);
9529 
9530  or_pack_int (reply, err);
9531 
9532  if (err != NO_ERROR)
9533  {
9534  (void) return_error_to_client (thread_p, rid);
9535  }
9536 
9537  css_send_data_to_client (thread_p->conn_entry, rid, OR_ALIGNED_BUF_START (a_reply), OR_ALIGNED_BUF_SIZE (a_reply));
9538 }
9539 
9540 /*
9541  * sboot_get_locales_info () - get info about locales
9542  * return : void
9543  * thread_p (in) :
9544  * rid (in) :
9545  * request (in) :
9546  * reqlen (in) :
9547  */
9548 void
9549 sboot_get_locales_info (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9550 {
9551  int err = NO_ERROR;
9552  OR_ALIGNED_BUF (2 * OR_INT_SIZE) a_reply;
9553  char *reply = NULL, *ptr = NULL, *data_reply = NULL;
9554  int size = 0, i;
9555  int len_str;
9556  const int collation_cnt = lang_collation_count ();
9557  const int lang_cnt = lang_locales_count (false);
9558  const int locales_cnt = lang_locales_count (true);
9559  int found_coll = 0;
9560 
9561  reply = OR_ALIGNED_BUF_START (a_reply);
9562 
9563  /* compute size of packed information */
9564  for (i = 0; i < LANG_MAX_COLLATIONS; i++)
9565  {
9567 
9568  assert (lc != NULL);
9569  if (i != 0 && lc->coll.coll_id == LANG_COLL_DEFAULT)
9570  {
9571  /* iso88591 binary collation added only once */
9572  continue;
9573  }
9574  found_coll++;
9575 
9576  size += 2 * OR_INT_SIZE; /* collation id , codeset */
9577  size += or_packed_string_length (lc->coll.coll_name, &len_str);
9578  size += or_packed_string_length (lc->coll.checksum, &len_str);
9579  }
9580 
9581  assert (found_coll == collation_cnt);
9582 
9583  for (i = 0; i < lang_cnt; i++)
9584  {
9586 
9587  assert (lld != NULL);
9588 
9589  do
9590  {
9591  size += or_packed_string_length (lld->lang_name, &len_str);
9592  size += OR_INT_SIZE; /* codeset */
9593  size += or_packed_string_length (lld->checksum, &len_str);
9594 
9595  lld = lld->next_lld;
9596  }
9597  while (lld != NULL);
9598  }
9599 
9600  size += 2 * OR_INT_SIZE; /* collation_cnt, locales_cnt */
9601 
9602  data_reply = (char *) malloc (size);
9603  if (data_reply != NULL)
9604  {
9605  ptr = or_pack_int (data_reply, collation_cnt);
9606  ptr = or_pack_int (ptr, locales_cnt);
9607  found_coll = 0;
9608 
9609  /* pack collation information : */
9610  for (i = 0; i < LANG_MAX_COLLATIONS; i++)
9611  {
9613 
9614  assert (lc != NULL);
9615 
9616  if (i != 0 && lc->coll.coll_id == LANG_COLL_DEFAULT)
9617  {
9618  continue;
9619  }
9620 
9621  found_coll++;
9622 
9623  ptr = or_pack_int (ptr, lc->coll.coll_id);
9624 
9625  len_str = strlen (lc->coll.coll_name);
9626  ptr = or_pack_string_with_length (ptr, lc->coll.coll_name, len_str);
9627 
9628  ptr = or_pack_int (ptr, (int) lc->codeset);
9629 
9630  len_str = strlen (lc->coll.checksum);
9631  ptr = or_pack_string_with_length (ptr, lc->coll.checksum, len_str);
9632  }
9633  assert (found_coll == collation_cnt);
9634 
9635  /* pack locale information : */
9636  for (i = 0; i < lang_cnt; i++)
9637  {
9639 
9640  assert (lld != NULL);
9641 
9642  do
9643  {
9644  len_str = strlen (lld->lang_name);
9645  ptr = or_pack_string_with_length (ptr, lld->lang_name, len_str);
9646 
9647  ptr = or_pack_int (ptr, lld->codeset);
9648 
9649  len_str = strlen (lld->checksum);
9650  ptr = or_pack_string_with_length (ptr, lld->checksum, len_str);
9651 
9652  lld = lld->next_lld;
9653  }
9654  while (lld != NULL);
9655  }
9656  }
9657  else
9658  {
9660  (void) return_error_to_client (thread_p, rid);
9661  size = 0;
9662  err = ER_FAILED;
9663  }
9664 
9665  ptr = or_pack_int (reply, size);
9666  ptr = or_pack_int (ptr, err);
9667 
9668  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), data_reply, size);
9669 
9670  if (data_reply != NULL)
9671  {
9672  free_and_init (data_reply);
9673  }
9674 }
9675 
9676 /*
9677  * sboot_get_timezone_checksum () - get the timezone library checksum
9678  * return : void
9679  * thread_p (in) :
9680  * rid (in) :
9681  * request (in) :
9682  * reqlen (in) :
9683  */
9684 void
9685 sboot_get_timezone_checksum (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9686 {
9687  int err = NO_ERROR;
9688  OR_ALIGNED_BUF (2 * OR_INT_SIZE) a_reply;
9689  char *reply = NULL, *ptr = NULL, *data_reply = NULL;
9690  int size = 0;
9691  int len_str;
9692  const TZ_DATA *tzd;
9693 
9694  tzd = tz_get_data ();
9695 
9696  assert (tzd != NULL);
9697  reply = OR_ALIGNED_BUF_START (a_reply);
9698 
9699  size += or_packed_string_length (tzd->checksum, &len_str);
9700 
9701  data_reply = (char *) malloc (size);
9702 
9703  if (data_reply != NULL)
9704  {
9705  len_str = strlen (tzd->checksum);
9706  ptr = or_pack_string_with_length (data_reply, tzd->checksum, len_str);
9707  }
9708  else
9709  {
9711  (void) return_error_to_client (thread_p, rid);
9712  size = 0;
9713  err = ER_FAILED;
9714  }
9715 
9716  ptr = or_pack_int (reply, size);
9717  ptr = or_pack_int (ptr, err);
9718 
9719  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), data_reply, size);
9720 
9721  if (data_reply != NULL)
9722  {
9723  free_and_init (data_reply);
9724  }
9725 }
9726 
9727 /*
9728  * schksum_insert_repl_log_and_demote_table_lock -
9729  *
9730  * return: error code
9731  *
9732  * NOTE: insert replication log and demote the read lock of the table
9733  */
9734 void
9735 schksum_insert_repl_log_and_demote_table_lock (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9736 {
9737  int success = NO_ERROR;
9738  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9739  char *reply = OR_ALIGNED_BUF_START (a_reply);
9740  char *ptr;
9741  OID class_oid;
9742  REPL_INFO repl_info = { NULL, 0, false };
9743  REPL_INFO_SBR repl_stmt = { 0, NULL, NULL, NULL, NULL };
9744 
9745  ptr = or_unpack_oid (request, &class_oid);
9746  ptr = or_unpack_int (ptr, &repl_info.repl_info_type);
9747  switch (repl_info.repl_info_type)
9748  {
9749  case REPL_INFO_TYPE_SBR:
9750  {
9751  ptr = or_unpack_int (ptr, &repl_stmt.statement_type);
9752  ptr = or_unpack_string_nocopy (ptr, &repl_stmt.name);
9753  ptr = or_unpack_string_nocopy (ptr, &repl_stmt.stmt_text);
9754  ptr = or_unpack_string_nocopy (ptr, &repl_stmt.db_user);
9755  ptr = or_unpack_string_nocopy (ptr, &repl_stmt.sys_prm_context);
9756 
9757  repl_info.info = (char *) &repl_stmt;
9758  break;
9759  }
9760  default:
9761  success = ER_FAILED;
9762  break;
9763  }
9764 
9765  if (success == NO_ERROR)
9766  {
9767  success = xchksum_insert_repl_log_and_demote_table_lock (thread_p, &repl_info, &class_oid);
9768  }
9769 
9770  (void) or_pack_int (reply, success);
9771  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
9772 }
9773 
9774 /*
9775  * slogtb_does_active_user_exist -
9776  *
9777  * return:
9778  *
9779  * rid(in):
9780  * request(in):
9781  * reqlen(in):
9782  *
9783  * NOTE:
9784  */
9785 void
9786 slogtb_does_active_user_exist (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9787 {
9788  char *user_name;
9789  bool existed;
9790  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9791  char *reply = OR_ALIGNED_BUF_START (a_reply);
9792 
9793  (void) or_unpack_string_nocopy (request, &user_name);
9794  existed = xlogtb_does_active_user_exist (thread_p, user_name);
9795 
9796  (void) or_pack_int (reply, (int) existed);
9797  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
9798 }
9799 
9800 /*
9801  * slocator_redistribute_partition_data () -
9802  *
9803  * return:
9804  *
9805  * rid(in):
9806  * request(in):
9807  * reqlen(in):
9808  *
9809  * NOTE:
9810  */
9811 void
9812 slocator_redistribute_partition_data (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9813 {
9814  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
9815  char *reply = OR_ALIGNED_BUF_START (a_reply);
9816  char *ptr;
9817  OID *oid_list;
9818  int nr_oids;
9819  int success = NO_ERROR;
9820  int i;
9821  OID class_oid;
9822 
9823  ptr = request;
9824  ptr = or_unpack_oid (ptr, &class_oid);
9825  ptr = or_unpack_int (ptr, &nr_oids);
9826 
9827  if (nr_oids < 1)
9828  {
9830  (void) return_error_to_client (thread_p, rid);
9831  success = ER_INVALID_PARTITION_REQUEST;
9832  goto end;
9833  }
9834 
9835  oid_list = (OID *) malloc (nr_oids * sizeof (OID));
9836  if (oid_list == NULL)
9837  {
9839  (void) return_error_to_client (thread_p, rid);
9840  success = ER_OUT_OF_VIRTUAL_MEMORY;
9841  goto end;
9842  }
9843 
9844  for (i = 0; i < nr_oids; i++)
9845  {
9846  ptr = or_unpack_oid (ptr, &oid_list[i]);
9847  }
9848 
9849  success = xlocator_redistribute_partition_data (thread_p, &class_oid, nr_oids, oid_list);
9850 
9851  if (oid_list != NULL)
9852  {
9853  free_and_init (oid_list);
9854  }
9855 
9856  if (success != NO_ERROR)
9857  {
9858  (void) return_error_to_client (thread_p, rid);
9859  }
9860 
9861 end:
9862  ptr = or_pack_int (reply, success);
9863  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
9864 }
9865 
9866 /*
9867  * netsr_spacedb () - server-side function to get database space info
9868  *
9869  * return : void
9870  * thread_p (in) : thread entry
9871  * rid (in) : request ID
9872  * request (in) : request data
9873  * reqlen (in) : request data length
9874  */
9875 void
9876 netsr_spacedb (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9877 {
9879  SPACEDB_ONEVOL *vols = NULL;
9881 
9882  int get_vols = 0;
9883  int get_files = 0;
9884  SPACEDB_ONEVOL **volsp = NULL;
9885  SPACEDB_FILES *filesp = NULL;
9886 
9887  OR_ALIGNED_BUF (2 * OR_INT_SIZE) a_reply;
9888  char *reply = OR_ALIGNED_BUF_START (a_reply);
9889  char *data_reply = NULL;
9890  int data_reply_length = 0;
9891 
9892  char *ptr;
9893 
9894  int error_code = NO_ERROR;
9895 
9896  /* do we need space information on all volumes? */
9897  ptr = or_unpack_int (request, &get_vols);
9898  if (get_vols)
9899  {
9900  volsp = &vols;
9901  }
9902  /* do we need detailed file information? */
9903  ptr = or_unpack_int (ptr, &get_files);
9904  if (get_files)
9905  {
9906  filesp = files;
9907  }
9908 
9909  /* get info from disk manager */
9910  error_code = disk_spacedb (thread_p, all, volsp);
9911  if (error_code != NO_ERROR)
9912  {
9913  ASSERT_ERROR ();
9914  }
9915  else if (get_files)
9916  {
9917  /* get info from file manager */
9918  error_code = file_spacedb (thread_p, filesp);
9919  if (error_code != NO_ERROR)
9920  {
9921  ASSERT_ERROR ();
9922  }
9923  }
9924 
9925  if (error_code == NO_ERROR)
9926  {
9927  /* success. pack space info */
9928  data_reply_length = or_packed_spacedb_size (all, vols, filesp);
9929  data_reply = (char *) db_private_alloc (thread_p, data_reply_length);
9930  ptr = or_pack_spacedb (data_reply, all, vols, filesp);
9931  assert (ptr - data_reply == data_reply_length);
9932  }
9933  else
9934  {
9935  /* error */
9936  (void) return_error_to_client (thread_p, rid);
9937  }
9938 
9939  /* send result to client */
9940  ptr = or_pack_int (reply, data_reply_length);
9941  ptr = or_pack_int (ptr, error_code);
9942 
9943  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), data_reply,
9944  data_reply_length);
9945 
9946  if (vols != NULL)
9947  {
9948  free_and_init (vols);
9949  }
9950  if (data_reply != NULL)
9951  {
9952  db_private_free_and_init (thread_p, data_reply);
9953  }
9954 }
9955 
9956 void
9957 slocator_demote_class_lock (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9958 {
9959  int error;
9960  OID class_oid;
9961  LOCK lock, ex_lock;
9962  char *ptr;
9964  char *reply = OR_ALIGNED_BUF_START (a_reply);
9965 
9966  ptr = or_unpack_oid (request, &class_oid);
9967  ptr = or_unpack_lock (ptr, &lock);
9968 
9969  error = xlocator_demote_class_lock (thread_p, &class_oid, lock, &ex_lock);
9970 
9971  if (error != NO_ERROR)
9972  {
9973  return_error_to_client (thread_p, rid);
9974  }
9975 
9976  ptr = or_pack_int (reply, error);
9977  ptr = or_pack_lock (ptr, ex_lock);
9978  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
9979 }
9980 
9981 void
9982 sloaddb_init (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
9983 {
9984  packing_unpacker unpacker (request, (size_t) reqlen);
9985 
9986  /* *INDENT-OFF* */
9987  cubload::load_args args;
9988  /* *INDENT-ON* */
9989 
9990  args.unpack (unpacker);
9991 
9992  load_session *session = new load_session (args);
9993 
9994  int error_code = session_set_load_session (thread_p, session);
9995  if (error_code != NO_ERROR)
9996  {
9997  delete session;
9998  }
9999 
10000  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10001  char *reply = OR_ALIGNED_BUF_START (a_reply);
10002 
10003  or_pack_int (reply, error_code);
10004  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
10005 }
10006 
10007 void
10008 sloaddb_install_class (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
10009 {
10010  packing_unpacker unpacker (request, (size_t) reqlen);
10011  bool is_ignored = false;
10012 
10013  /* *INDENT-OFF* */
10014  cubload::batch batch;
10015  /* *INDENT-ON* */
10016 
10017  batch.unpack (unpacker);
10018 
10019  load_session *session = NULL;
10020  int error_code = session_get_load_session (thread_p, session);
10021  std::string cls_name;
10022  if (error_code == NO_ERROR)
10023  {
10024  assert (session != NULL);
10025  error_code = session->install_class (*thread_p, batch, is_ignored, cls_name);
10026  }
10027  else
10028  {
10029  if (er_errid () == NO_ERROR || !er_has_error ())
10030  {
10031  error_code = ER_LDR_INVALID_STATE;
10032  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
10033  }
10034 
10035  return_error_to_client (thread_p, rid);
10036  }
10037 
10038  // Error code and is_ignored.
10039  OR_ALIGNED_BUF (3 * OR_INT_SIZE) a_reply;
10040  char *reply = OR_ALIGNED_BUF_START (a_reply);
10041  char *ptr;
10042  int buf_sz = (int) cls_name.length ();
10043  ptr = or_pack_int (reply, buf_sz);
10044  ptr = or_pack_int (ptr, error_code);
10045  ptr = or_pack_int (ptr, (is_ignored ? 1 : 0));
10046 
10047  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply),
10048  (char *) cls_name.c_str (), buf_sz);
10049 }
10050 
10051 void
10052 sloaddb_load_batch (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
10053 {
10054  packing_unpacker unpacker (request, (size_t) reqlen);
10055 
10056  /* *INDENT-OFF* */
10057  cubload::batch *batch = NULL;
10058  load_status status;
10059  packing_packer packer;
10061  /* *INDENT-ON* */
10062 
10063  char *reply_data = NULL;
10064  int reply_data_size = 0;
10065 
10066  bool use_temp_batch = false;
10067  unpacker.unpack_bool (use_temp_batch);
10068  if (!use_temp_batch)
10069  {
10070  batch = new cubload::batch ();
10071  batch->unpack (unpacker);
10072  }
10073 
10074  bool is_batch_accepted = false;
10075  load_session *session = NULL;
10076 
10077  session_get_load_session (thread_p, session);
10078  int error_code = session_get_load_session (thread_p, session);
10079  if (error_code == NO_ERROR)
10080  {
10081  assert (session != NULL);
10082  error_code = session->load_batch (*thread_p, batch, use_temp_batch, is_batch_accepted, status);
10083 
10084  packer.set_buffer_and_pack_all (eb, status);
10085 
10086  reply_data = eb.get_ptr ();
10087  reply_data_size = (int) packer.get_current_size ();
10088  }
10089  else
10090  {
10091  if (er_errid () == NO_ERROR || !er_has_error ())
10092  {
10093  error_code = ER_LDR_INVALID_STATE;
10094  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, error_code, 0);
10095  }
10096 
10097  return_error_to_client (thread_p, rid);
10098  }
10099 
10100  OR_ALIGNED_BUF (OR_INT_SIZE * 3) a_reply;
10101  char *reply = OR_ALIGNED_BUF_START (a_reply);
10102 
10103  char *ptr = or_pack_int (reply, reply_data_size);
10104  ptr = or_pack_int (ptr, error_code);
10105  or_pack_int (ptr, (is_batch_accepted ? 1 : 0));
10106 
10107 
10108  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), reply_data,
10109  reply_data_size);
10110 }
10111 
10112 void
10113 sloaddb_fetch_status (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
10114 {
10115  packing_packer packer;
10117 
10118  char *buffer = NULL;
10119  int buffer_size = 0;
10120 
10121  load_session *session = NULL;
10122  int error_code = session_get_load_session (thread_p, session);
10123  if (error_code == NO_ERROR)
10124  {
10125  assert (session != NULL);
10126  load_status status;
10127  session->fetch_status (status, false);
10128  packer.set_buffer_and_pack_all (eb, status);
10129 
10130  buffer = eb.get_ptr ();
10131  buffer_size = (int) packer.get_current_size ();
10132  }
10133  else
10134  {
10135  if (er_errid () == NO_ERROR || !er_has_error ())
10136  {
10138  }
10139 
10140  return_error_to_client (thread_p, rid);
10141  }
10142 
10143  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10144  char *reply = OR_ALIGNED_BUF_START (a_reply);
10145 
10146  or_pack_int (reply, buffer_size);
10147  css_send_reply_and_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply), buffer,
10148  buffer_size);
10149 }
10150 
10151 void
10152 sloaddb_destroy (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
10153 {
10154  load_session *session = NULL;
10155  int error_code = session_get_load_session (thread_p, session);
10156  if (error_code == NO_ERROR)
10157  {
10158  assert (session != NULL);
10159 
10160  session->wait_for_completion ();
10161  delete session;
10162  session_set_load_session (thread_p, NULL);
10163  }
10164 
10165  if (er_errid () != NO_ERROR || er_has_error ())
10166  {
10167  return_error_to_client (thread_p, rid);
10168  }
10169 
10170  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10171  char *reply = OR_ALIGNED_BUF_START (a_reply);
10172 
10173  or_pack_int (reply, error_code);
10174  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
10175 }
10176 
10177 void
10178 sloaddb_interrupt (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
10179 {
10180  load_session *session = NULL;
10181  int error_code = session_get_load_session (thread_p, session);
10182  if (error_code == NO_ERROR)
10183  {
10184  assert (session != NULL);
10185 
10186  session->interrupt ();
10187  }
10188  else
10189  {
10190  // what to do, what to do...
10191  }
10192 }
10193 
10194 void
10195 sloaddb_update_stats (THREAD_ENTRY * thread_p, unsigned int rid, char *request, int reqlen)
10196 {
10197  char *buffer = NULL;
10198  int buffer_size = 0;
10199 
10200  load_session *session = NULL;
10201  int error_code = session_get_load_session (thread_p, session);
10202  if (error_code == NO_ERROR)
10203  {
10204  assert (session != NULL);
10205 
10206  session->update_class_statistics (*thread_p);
10207  }
10208 
10209  if (er_errid () != NO_ERROR || er_has_error ())
10210  {
10211  return_error_to_client (thread_p, rid);
10212  }
10213 
10214  OR_ALIGNED_BUF (OR_INT_SIZE) a_reply;
10215  char *reply = OR_ALIGNED_BUF_START (a_reply);
10216 
10217  or_pack_int (reply, error_code);
10218  css_send_data_to_client (thread_p->conn_entry, rid, reply, OR_ALIGNED_BUF_SIZE (a_reply));
10219 }
10220 
10221 void
10223 {
10225 }
#define QFILE_TUPLE_VALUE_HEADER_SIZE
Definition: query_list.h:229
void stran_server_2pc_recovery_prepared(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define NUM_NORMAL_TRANS
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
void sloaddb_destroy(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
LC_FIND_CLASSNAME xlocator_delete_class_name(THREAD_ENTRY *thread_p, const char *classname)
Definition: locator_sr.c:755
char * PAGE_PTR
LC_FETCH_VERSION_TYPE
Definition: locator.h:178
#define OID_INITIALIZER
Definition: oid.h:36
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
#define ER_QPROC_XASLNODE_RECOMPILE_REQUESTED
Definition: error_code.h:1595
Definition: sha1.h:50
#define ER_LK_UNILATERALLY_ABORTED
Definition: error_code.h:130
void sbtree_delete_index(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slog_drop_lob_locator(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sboot_check_db_consistency(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define LANG_MAX_COLLATIONS
int xsession_delete_prepared_statement(THREAD_ENTRY *thread_p, const char *name)
Definition: session_sr.c:233
char * or_unpack_hfid_array(char *ptr, int n, HFID **hfids)
int xboot_compact_start(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:5886
char * or_unpack_oid(char *ptr, OID *oid)
#define OR_BTID_ALIGNED_SIZE
cubload::session load_session
unsigned int css_send_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *buffer, int buffer_size)
void sbtree_find_unique(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
OID * oid_Root_class_oid
Definition: oid.c:73
char * or_pack_btid(char *buf, const BTID *btid)
int page_size
Definition: unloaddb.c:52
void stran_server_is_active_and_has_updated(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
void set_buffer(const char *storage, const size_t amount)
Definition: packer.cpp:87
DB_INFO * cfg_find_db(const char *db_name)
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
#define __attribute__(X)
Definition: porting.h:36
char * perfmon_pack_stats(char *buf, UINT64 *stats)
void stran_server_2pc_prepare(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sthread_kill_tran_index(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define DB_ROW_COUNT_NOT_SET
Definition: dbtype_def.h:486
void shf_heap_reclaim_addresses(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xlogtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
void er_stack_push(void)
void stran_server_2pc_start(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void ssession_find_or_create_session(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void stran_server_savepoint(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xs_send_method_call_info_to_client(THREAD_ENTRY *thread_p, qfile_list_id *list_id, method_sig_list *methsg_list)
int xheap_has_instance(THREAD_ENTRY *thread_p, const HFID *hfid, OID *class_oid, int has_visible_instance)
Definition: heap_file.c:16429
void sboot_get_locales_info(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int file_spacedb(THREAD_ENTRY *thread_p, SPACEDB_FILES *spacedb)
STATIC_INLINE int or_get_varchar_compression_lengths(OR_BUF *buf, int *compressed_size, int *decompressed_size) __attribute__((ALWAYS_INLINE))
XASL_NODE_HEADER * xasl_header
Definition: xasl.h:611
void ssession_create_prepared_statement(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
struct qmgr_temp_file * tfile_vfid
Definition: query_list.h:440
void sqfile_get_list_file_page(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * or_unpack_string(char *ptr, char **string)
#define CACHE_TIME_RESET(T)
Definition: cache_time.h:40
void ssession_get_row_count(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define ASSERT_ERROR()
#define ER_NET_DIFFERENT_RELEASE
Definition: error_code.h:642
SCAN_CODE
int boot_compact_stop(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:724
void slocator_upgrade_instances_domain(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define NET_COPY_AREA_SENDRECV_SIZE
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
int xacl_reload(THREAD_ENTRY *thread_p)
#define ER_KILL_TR_NOT_ALLOWED
Definition: error_code.h:1476
QFILE_TUPLE_VALUE_TYPE_LIST type_list
Definition: query_list.h:428
char * sql_plan_text
Definition: xasl_cache.h:78
DB_TRAN_ISOLATION TRAN_ISOLATION
Definition: log_comm.h:81
#define ER_INVALID_PARTITION_REQUEST
Definition: error_code.h:1123
int sysprm_packed_assign_values_length(const SYSPRM_ASSIGN_VALUE *assign_values, int offset)
void slocator_fetch_all(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sbtree_get_statistics(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slocator_fetch(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define rmutex_unlock(a, b)
void stde_change_mk_on_server(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
unsigned int css_get_comm_request_id(THREAD_ENTRY *thread_p)
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
#define QFILE_FREE_AND_INIT_LIST_ID(list_id)
Definition: list_file.h:56
void slocator_fetch_lockhint_classes(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xboot_heap_compact(THREAD_ENTRY *thread_p, OID *class_oid)
Definition: boot_sr.c:5876
void stran_server_has_updated(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void xsysprm_obtain_server_parameters(SYSPRM_ASSIGN_VALUE *prm_values)
void smnt_server_stop_stats(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int or_listid_length(void *listid)
#define SHA1_HASH_INITIALIZER
Definition: sha1.h:54
void locator_free_copy_area(LC_COPYAREA *copyarea)
Definition: locator.c:534
void stde_get_mk_info(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
enum db_client_type BOOT_CLIENT_TYPE
PAGEID DKNPAGES
#define NET_SENDRECV_BUFFSIZE
char * or_pack_errcode(char *ptr, int error)
int db_get_int(const DB_VALUE *value)
void update_class_statistics(cubthread::entry &thread_ref)
int btree_get_stats(THREAD_ENTRY *thread_p, BTREE_STATS *stat_info_p, bool with_fullscan)
Definition: btree.c:6959
unsigned int css_send_reply_and_3_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *reply, int reply_size, char *buffer1, int buffer1_size, char *buffer2, int buffer2_size, char *buffer3, int buffer3_size)
LC_LOCKHINT * locator_allocate_and_unpack_lockhint(char *unpacked, int unpacked_size, bool unpack_classes, bool reg_unpacked)
Definition: locator.c:1876
void ssession_reset_cur_insert_id(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define ER_NET_SERVER_DATA_RECEIVE
Definition: error_code.h:256
int xsession_get_row_count(THREAD_ENTRY *thread_p, int *row_count)
Definition: session_sr.c:91
PAGE_PTR qmgr_get_old_page(THREAD_ENTRY *thread_p, VPID *vpid_p, QMGR_TEMP_FILE *tfile_vfid_p)
int xfile_apply_tde_to_class_files(THREAD_ENTRY *thread_p, const OID *class_oid)
void stran_lock_rep_read(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
TRAN_STATE xtran_server_partial_abort(THREAD_ENTRY *thread_p, const char *savept_name, LOG_LSA *savept_lsa)
void sboot_add_volume_extension(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sboot_find_last_permanent(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
FILEIO_REMOTE_PROMPT_TYPE
Definition: file_io.h:128
#define ER_FAILED
Definition: error_code.h:47
const TZ_DATA * tz_get_data(void)
Definition: tz_support.c:687
void server_ping(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int perfmon_calc_diff_stats(UINT64 *stats_diff, UINT64 *new_stats, UINT64 *old_stats)
#define ALWAYS_INLINE
int install_class(cubthread::entry &thread_ref, const batch &batch, bool &is_ignored, std::string &cls_name)
#define NULL_TRANID
TRAN_ABORT_REASON tran_abort_reason
Definition: log_impl.h:526
const char * boot_db_name(void)
Definition: boot_sr.c:459
void slog_add_lob_locator(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xlogtb_kill_tran_index(THREAD_ENTRY *thread_p, int kill_tran_index, char *kill_user, char *kill_host, int kill_pid)
#define ER_DB_NO_MODIFICATIONS
Definition: error_code.h:683
char * xdisk_get_remarks(THREAD_ENTRY *thread_p, VOLID volid)
char * or_unpack_string_alloc(char *ptr, char **string)
int lang_locales_count(bool check_codeset)
char * packed
Definition: locator.h:328
char * locator_unpack_copy_area_descriptor(int num_objs, LC_COPYAREA *copyarea, char *desc)
Definition: locator.c:619
int xs_receive_data_from_client_with_timeout(THREAD_ENTRY *thread_p, char **area, int *datasize, int timeout)
char * or_pack_db_value(char *buffer, DB_VALUE *var)
int rel_compare(const char *rel_a, const char *rel_b)
int rel_bit_platform(void)
void sprm_server_get_force_parameters(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
SCAN_CODE qfile_scan_list_next(THREAD_ENTRY *thread_p, QFILE_LIST_SCAN_ID *scan_id_p, QFILE_TUPLE_RECORD *tuple_record_p, int peek)
Definition: list_file.c:4724
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
void sync_dump_statistics(FILE *fp, SYNC_PRIMITIVE_TYPE type)
#define LC_ERROR
void sserial_get_current_value(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void stran_wait_server_active_trans(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void unpack(cubpacking::unpacker &deserializator) override
void ses_posix_copy_file(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int sysprm_set_error(SYSPRM_ERR rc, const char *data)
int xserial_get_current_value(THREAD_ENTRY *thread_p, DB_VALUE *result_num, const OID *oid_p, int cached_num)
Definition: serial.c:156
PSTAT_METADATA pstat_Metadata[]
#define OR_HFID_SIZE
char * packed
Definition: locator.h:302
char * or_pack_string(char *ptr, const char *string)
int css_change_ha_server_state(THREAD_ENTRY *thread_p, HA_SERVER_STATE state, bool force, int timeout, bool heartbeat)
int css_increment_num_conn(BOOT_CLIENT_TYPE client_type)
void xlogtb_dump_trantable(THREAD_ENTRY *thread_p, FILE *out_fp)
void sboot_compact_db(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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)
#define ASSERT_ERROR_AND_SET(error_code)
#define NET_CAP_HA_REPL_DELAY
Definition: network.h:268
int num_classes_processed
Definition: locator.h:325
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
int xlog_send_log_pages_to_client(THREAD_ENTRY *thread_p, char *logpg_area, int area_size, LOGWR_MODE mode)
void stran_server_commit(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define assert_release(e)
Definition: error_manager.h:96
#define REL_MAX_RELEASE_LENGTH
void sboot_notify_unregister_client(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define LOG_CHECK_LOG_APPLIER(thread_p)
Definition: log_impl.h:240
int xtran_server_start_topop(THREAD_ENTRY *thread_p, LOG_LSA *topop_lsa)
const char * get_host_name() const
int xrepl_set_info(THREAD_ENTRY *thread_p, REPL_INFO *repl_info)
Definition: locator_sr.c:11642
void stran_server_2pc_attach_global_tran(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define NET_CAP_HA_REPLICA
Definition: network.h:269
int pkeys_size
Definition: statistics.h:66
#define NET_CAP_FORWARD_COMPATIBLE
Definition: network.h:264
char * er_get_area_error(char *buffer, int *length)
INT16 VOLID
void slogtb_set_interrupt(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * info
Definition: replication.h:54
VOLID xboot_find_last_permanent(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:377
#define OR_ALIGNED_BUF(size)
void sboot_compact_start(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
#define QEWC_MAX_DATA_SIZE
TRAN_STATE xtran_server_commit(THREAD_ENTRY *thrd, bool retain_lock)
struct timeval TSCTIMEVAL
Definition: tsc_timer.h:40
#define OID_SET_NULL(oidp)
Definition: oid.h:85
void locator_free_lockhint(LC_LOCKHINT *lockhint)
Definition: locator.c:1765
bool xtran_should_connection_reset(THREAD_ENTRY *thread_p, bool has_updated)
void smnt_server_copy_global_stats(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xbtree_delete_index(THREAD_ENTRY *thread_p, BTID *btid)
Definition: btree.c:5691
void sqmgr_dump_query_plans(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xqmgr_end_query(THREAD_ENTRY *thrd, QUERY_ID query_id)
static FILE * log_fp
Definition: cas_log.c:91
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
char * sysprm_pack_assign_values(char *ptr, const SYSPRM_ASSIGN_VALUE *assign_values)
FILE * event_log_start(THREAD_ENTRY *thread_p, const char *event_name)
Definition: event_log.c:222
bool is_xasl_pinned_reference
void stran_get_local_transaction_id(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
LOG_TDES * LOG_FIND_TDES(int tran_index)
Definition: log_impl.h:1095
void tsc_elapsed_time_usec(TSCTIMEVAL *tv, TSC_TICKS end_tick, TSC_TICKS start_tick)
Definition: tsc_timer.c:101
STATIC_INLINE TRAN_STATE stran_server_commit_internal(THREAD_ENTRY *thread_p, unsigned int rid, bool retain_lock, bool *should_conn_reset) __attribute__((ALWAYS_INLINE))
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
void ssession_get_last_insert_id(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slocator_redistribute_partition_data(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xtx_add_lob_locator(cubthread::entry *thread_p, const char *locator, LOB_LOCATOR_STATE state)
void qmgr_setup_empty_list_file(char *page_p)
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)
#define OR_ALIGNED_BUF_SIZE(abuf)
int xlog_get_page_request_with_reply(THREAD_ENTRY *thread_p, LOG_PAGEID *fpageid_ptr, LOGWR_MODE *mode_ptr, int timeout)
char * or_pack_oid(char *ptr, const OID *oid)
int tran_abort(void)
void sboot_register_client(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sysprm_free_assign_values(SYSPRM_ASSIGN_VALUE **assign_values_ptr)
TRAN_STATE xtran_server_abort(THREAD_ENTRY *thrd)
#define bool
Definition: dbi_compat.h:31
void slog_change_state_of_locator(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define PTR_ALIGN(addr, boundary)
Definition: memory_alloc.h:77
void stran_server_partial_abort(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void xserial_decache(THREAD_ENTRY *thread_p, OID *oidp)
Definition: serial.c:1366
#define NET_CAP_INTERRUPT_ENABLED
Definition: network.h:265
void locator_free_lockset(LC_LOCKSET *lockset)
Definition: locator.c:1140
unsigned int css_send_reply_and_2_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *reply, int reply_size, char *buffer1, int buffer1_size, char *buffer2, int buffer2_size)
int or_packed_domain_size(struct tp_domain *domain, int include_classoids)
void sbtree_find_multi_uniques(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define er_log_debug(...)
int xsession_create_new(THREAD_ENTRY *thread_p, SESSION_ID *id)
Definition: session_sr.c:38
void sprm_server_dump_parameters(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * or_unpack_int_array(char *ptr, int n, int **number_array)
void slogtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void xlogpb_dump_stat(FILE *outfp)
static void event_log_slow_query(THREAD_ENTRY *thread_p, EXECUTION_INFO *info, int time, UINT64 *diff_stats)
void slocator_reserve_classnames(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xboot_compact_db(THREAD_ENTRY *thread_p, OID *class_oids, int n_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 *initial_last_repr_id)
Definition: boot_sr.c:5860
void slogtb_dump_trantable(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void _er_log_debug(const char *file_name, const int line_no, const char *fmt,...)
BOOT_SERVER_STATUS boot_Server_status
Definition: boot_sr.c:148
#define MAX_ALIGNMENT
Definition: memory_alloc.h:70
void ses_posix_delete_file(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
unsigned int css_receive_data_from_client_with_timeout(CSS_CONN_ENTRY *conn, unsigned int eid, char **buffer, int *size, int timeout)
#define ER_SLOW_QUERY
Definition: error_code.h:1392
void wait_for_completion()
int xsession_get_session_variable(THREAD_ENTRY *thread_p, const DB_VALUE *name, DB_VALUE *value)
Definition: session_sr.c:271
int packed_size
Definition: locator.h:327
void slocator_fetch_lockset(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sprm_server_obtain_parameters(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sserial_decache(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
LOCK lock_get_object_lock(const OID *oid, const OID *class_oid)
void shf_get_class_num_objs_and_pages(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * sysprm_pack_session_parameters(char *ptr, SESSION_PARAM *session_parameters)
int xboot_find_number_temp_volumes(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:359
void stran_server_start_topop(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xtde_get_mk_info(THREAD_ENTRY *thread_p, int *mk_index, time_t *created_time, time_t *set_time)
Definition: tde.c:1214
#define OR_FLOAT_SIZE
LANG_LOCALE_DATA * next_lld
int xlogtb_reset_wait_msecs(THREAD_ENTRY *thread_p, int wait_msecs)
int xlogin_user(THREAD_ENTRY *thread_p, const char *username)
Definition: session_sr.c:245
bool xlogtb_does_active_user_exist(THREAD_ENTRY *thread_p, const char *user_name)
void slocator_delete_class_name(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void css_set_ha_num_of_hosts(int num)
void THREAD_ENTRY
int xlocator_assign_oid_batch(THREAD_ENTRY *thread_p, LC_OIDSET *oidset)
Definition: locator_sr.c:11512
void stran_is_blocked(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void xlogtb_set_interrupt(THREAD_ENTRY *thread_p, int set)
#define NULL_PAGEID
void sacl_dump(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int or_packed_stream_length(size_t len)
int xtran_wait_server_active_trans(THREAD_ENTRY *thrd)
#define OR_ALIGNED_BUF_START(abuf)
LOCK
void sloaddb_update_stats(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define STATDUMP_BUF_SIZE
#define HA_GET_MODE()
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)
char boot_Host_name[CUB_MAXHOSTNAMELEN]
Definition: boot_cl.c:158
VACOMM_BUFFER_CLIENT_ACTION
Definition: method_def.hpp:33
REL_COMPATIBILITY
void sqmgr_end_query(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int session_set_load_session(THREAD_ENTRY *thread_p, load_session *load_session_p)
Definition: session.c:3113
char * perfmon_allocate_packed_values_buffer(void)
#define QFILE_GET_TUPLE_VALUE_FLAG(ptr)
Definition: query_list.h:250
static int client_capabilities(void)
Definition: network_cl.c:230
void sthread_kill_or_interrupt_tran(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
const LANG_LOCALE_DATA * lang_get_first_locale_for_lang(const INTL_LANG lang)
void slocator_get_reserved_class_name_oid(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
PGLENGTH log_page_size
Definition: boot.h:145
unsigned int DB_TIMESTAMP
Definition: dbtype_def.h:759
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 slog_find_lob_locator(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
PGLENGTH page_size
Definition: boot.h:144
char * or_pack_float(char *ptr, float number)
int xboot_compact_stop(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:5896
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
INTL_CODESET codeset
char * or_pack_stream(char *ptr, const char *stream, size_t len)
LANG_COLLATION * lang_get_collation(const int coll_id)
int xlocator_repl_force(THREAD_ENTRY *thread_p, LC_COPYAREA *copy_area, LC_COPYAREA **reply_area)
Definition: locator_sr.c:6781
void sqmgr_execute_query(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
int session_get_load_session(THREAD_ENTRY *thread_p, REFPTR(load_session, load_session_ref_ptr))
Definition: session.c:3129
#define TO_MSEC(elapsed)
void xqmgr_dump_query_plans(THREAD_ENTRY *thread_p, FILE *outfp)
void slocator_demote_class_lock(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define assert(x)
int xheap_destroy_newly_created(THREAD_ENTRY *thread_p, const HFID *hfid, const OID *class_oid)
Definition: heap_file.c:5818
char checksum[TZ_CHECKSUM_SIZE+1]
#define ER_LC_PARTIALLY_FAILED_TO_FLUSH
Definition: error_code.h:1394
FILEIO_ZIP_LEVEL
Definition: file_io.h:113
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)
static bool need_to_abort_tran(THREAD_ENTRY *thread_p, int *errid)
int xtx_drop_lob_locator(cubthread::entry *thread_p, const char *locator)
void sloaddb_fetch_status(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xtran_lock_rep_read(THREAD_ENTRY *thread_p, LOCK lock_rr_tran)
void ssession_set_session_variables(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
int prm_get_integer_value(PARAM_ID prm_id)
void sdk_totalpgs(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define ER_GENERIC_ERROR
Definition: error_code.h:49
#define STATIC_INLINE
bool boot_can_compact(THREAD_ENTRY *thread_p)
Definition: compactdb_sr.c:753
size_t get_current_size(void)
Definition: packer.cpp:936
int xcallback_console_print(THREAD_ENTRY *thread_p, char *print_str)
int xlocator_remove_class_from_index(THREAD_ENTRY *thread_p, OID *oid, BTID *btid, HFID *hfid)
Definition: locator_sr.c:8842
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
int num_exec_queries
Definition: log_impl.h:529
REL_COMPATIBILITY rel_get_net_compatible(const char *client_rel_str, const char *server_rel_str)
void logtb_set_current_user_name(THREAD_ENTRY *thread_p, const char *client_name)
#define TDE_DATA_KEY_LENGTH
Definition: tde.h:55
#define ER_OUT_OF_VIRTUAL_MEMORY
Definition: error_code.h:50
void ssession_get_prepared_statement(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void srepl_set_info(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define OR_PACK_XASL_NODE_HEADER(PTR, X)
Definition: xasl.h:74
void sdk_vlabel(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
TDE_CIPHER tde_Cipher
Definition: tde.c:69
char * or_pack_spacedb(char *ptr, const SPACEDB_ALL *all, const SPACEDB_ONEVOL *vols, const SPACEDB_FILES *files)
char * or_unpack_hfid(char *ptr, HFID *hfid)
#define QFILE_PAGE_HEADER_SIZE
Definition: query_list.h:47
#define OR_VALUE_ALIGNED_SIZE(value)
char * sysprm_unpack_assign_values(char *ptr, SYSPRM_ASSIGN_VALUE **assign_values_ptr)
void sboot_notify_ha_log_applier_state(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xsession_get_last_insert_id(THREAD_ENTRY *thread_p, DB_VALUE *value, bool update_last_insert_id)
Definition: session_sr.c:126
void shf_has_instance(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * or_unpack_lock(char *ptr, LOCK *lock)
int db_sys_date_and_epoch_time(DB_VALUE *dt_dbval, DB_VALUE *ts_dbval)
void log_wakeup_checkpoint_daemon()
void sserial_get_next_value(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sfile_apply_tde_to_class_files(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
SYSPRM_ASSIGN_VALUE * xsysprm_get_force_server_parameters(void)
static void event_log_temp_expand_pages(THREAD_ENTRY *thread_p, EXECUTION_INFO *info)
int sysprm_packed_session_parameters_length(SESSION_PARAM *session_parameters, int offset)
int or_db_value_size(DB_VALUE *var)
BTREE_SEARCH
void ssession_set_row_count(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slogtb_reset_wait_msecs(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define IS_QUERY_EXECUTED_WITHOUT_DATA_BUFFERS(flag)
Definition: query_list.h:581
void sct_check_rep_dir(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define ER_QUERY_EXECUTION_ERROR
Definition: error_code.h:1430
void tde_make_keys_file_fullname(char *keys_vol_fullname, const char *db_full_name, bool ignore_parm)
Definition: tde.c:492
#define NET_CAP_HA_IGNORE_REPL_DELAY
Definition: network.h:270
void xcache_unfix(THREAD_ENTRY *thread_p, XASL_CACHE_ENTRY *xcache_entry)
Definition: xasl_cache.c:1083
void sloaddb_load_batch(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
bool css_is_shutdowning_server()
#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)
int db_Disable_modifications
Definition: db_macro.c:90
void stran_server_abort(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void xlogtb_set_suppress_repl_on_transaction(THREAD_ENTRY *thread_p, int set)
#define ER_NET_DIFFERENT_BIT_PLATFORM
Definition: error_code.h:1207
unsigned char perm_key[TDE_DATA_KEY_LENGTH]
Definition: tde.h:87
int length
Definition: locator.h:322
bool logtb_has_updated(THREAD_ENTRY *thread_p)
void unpack(cubpacking::unpacker &deserializator) override
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
void sdk_freepgs(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void ssession_get_session_variable(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
enum ha_log_applier_state HA_LOG_APPLIER_STATE
int perfmon_get_number_of_statistic_values(void)
int lang_collation_count(void)
void sqmgr_prepare_query(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void event_log_bind_values(THREAD_ENTRY *thread_p, FILE *log_fp, int tran_index, int bind_index)
Definition: event_log.c:405
void smnt_server_start_stats(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sboot_find_number_temp_volumes(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sqmgr_dump_query_cache(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define NET_CAP_BACKWARD_COMPATIBLE
Definition: network.h:263
void slocator_fetch_all_reference_lockset(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xheap_create(THREAD_ENTRY *thread_p, HFID *hfid, const OID *class_oid, bool reuse_oid)
Definition: heap_file.c:5772
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
void shf_create(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
unsigned int css_receive_data_from_client(CSS_CONN_ENTRY *conn, unsigned int eid, char **buffer, int *size)
int xs_send_action_to_client(THREAD_ENTRY *thread_p, VACOMM_BUFFER_CLIENT_ACTION action)
static void cleanup(int signo)
Definition: broker.c:717
#define QFILE_GET_TUPLE_VALUE_LENGTH(ptr)
Definition: query_list.h:253
INT64 LOG_PAGEID
int xtde_change_mk_without_flock(THREAD_ENTRY *thread_p, const int mk_index)
Definition: tde.c:1246
int db_sys_timestamp(DB_VALUE *result_timestamp)
#define NULL
Definition: freelistheap.h:34
static int total_objects
Definition: compactdb.c:56
void event_log_end(THREAD_ENTRY *thread_p)
Definition: event_log.c:290
#define QFILE_TUPLE_LENGTH_SIZE
Definition: query_list.h:224
char * or_unpack_sha1(char *ptr, SHA1Hash *sha1)
char checksum[32+1]
struct pr_type * type
Definition: object_domain.h:76
void sbtree_get_key_type(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define QFILE_GET_TUPLE_LENGTH(tpl)
Definition: query_list.h:238
static int server_capabilities(void)
#define rmutex_lock(a, b)
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)
void tsc_getticks(TSC_TICKS *tck)
Definition: tsc_timer.c:81
#define CACHE_TIME_EQ(T1, T2)
Definition: cache_time.h:37
void sthread_dump_cs_stat(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define OR_BIGINT_SIZE
void css_end_server_request(CSS_CONN_ENTRY *conn)
int xio_send_user_prompt_to_client(THREAD_ENTRY *thread_p, FILEIO_REMOTE_PROMPT_TYPE prompt_id, const char *prompt, const char *failure_prompt, int range_low, int range_high, const char *secondary_prompt, int reprompt_value)
void smnt_server_copy_stats(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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()
void unpack_bool(bool &value)
Definition: packer.cpp:172
void slock_dump(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
LC_FIND_CLASSNAME
#define err(fd,...)
Definition: porting.h:431
void sloaddb_init(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#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 xvacuum(THREAD_ENTRY *thread_p)
Definition: vacuum.c:962
#define DB_EMPTY_SESSION
Definition: dbtype_def.h:483
int or_method_sig_list_length(void *method_sig_list_ptr)
static int failed_objects
Definition: compactdb.c:57
void slogtb_set_suppress_repl_on_transaction(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xsession_set_session_variables(THREAD_ENTRY *thread_p, DB_VALUE *values, const int count)
Definition: session_sr.c:258
void ssession_delete_prepared_statement(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
void or_init(OR_BUF *buf, char *data, int length)
SCAN_OPERATION_TYPE
HA_SERVER_STATE ha_server_state
Definition: boot.h:147
void sloaddb_interrupt(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define db_private_alloc(thrd, size)
Definition: memory_alloc.h:227
void shf_destroy_when_new(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sboot_heap_compact(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * or_unpack_int64(char *ptr, INT64 *number)
#define ER_NET_DATA_RECEIVE_TIMEDOUT
Definition: error_code.h:1426
void sbtree_class_test_unique(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void xperfmon_server_copy_stats(THREAD_ENTRY *thread_p, UINT64 *to_stats)
#define OR_PTR_ALIGNED_SIZE
void sjsp_get_server_port(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define OR_LOG_LSA_ALIGNED_SIZE
#define OR_PACK_CACHE_TIME(PTR, T)
Definition: cache_time.h:58
CLIENTIDS client
Definition: log_impl.h:484
int xtran_server_get_global_tran_info(THREAD_ENTRY *thread_p, int gtrid, void *buffer, int size)
void er_set_with_oserror(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
void slocator_rename_class_name(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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 or_packed_spacedb_size(const SPACEDB_ALL *all, const SPACEDB_ONEVOL *vols, const SPACEDB_FILES *files)
int pr_clear_value(DB_VALUE *value)
int qfile_open_list_scan(QFILE_LIST_ID *list_id_p, QFILE_LIST_SCAN_ID *scan_id_p)
Definition: list_file.c:4658
void shf_destroy(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define ER_LDR_INVALID_STATE
Definition: error_code.h:655
int xtran_server_is_active_and_has_updated(THREAD_ENTRY *thread_p)
EXECUTION_INFO sql_info
Definition: xasl_cache.h:103
void locator_free_oid_set(THREAD_ENTRY *thread_p, LC_OIDSET *oidset)
Definition: locator.c:2227
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
const char * lang_name
int xsession_drop_session_variables(THREAD_ENTRY *thread_p, DB_VALUE *values, const int count)
Definition: session_sr.c:306
void fetch_status(load_status &status, bool has_lock=false)
void ses_posix_write_file(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void net_cleanup_server_queues(unsigned int rid)
Definition: network_sr.c:1430
void er_stack_pop(void)
int num_reqobjs
Definition: locator.h:287
int xsession_reset_cur_insert_id(THREAD_ENTRY *thread_p)
Definition: session_sr.c:147
LC_COPYAREA * locator_recv_allocate_copyarea(int num_objs, char **packed_desc, int packed_desc_length, char **contents_ptr, int contents_length)
Definition: locator.c:755
unsigned int css_send_abort_to_client(CSS_CONN_ENTRY *conn, unsigned int eid)
void ses_posix_rename_file(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xs_receive_data_from_client(THREAD_ENTRY *thread_p, char **area, int *datasize)
int load_batch(cubthread::entry &thread_ref, const batch *batch, bool use_temp_batch, bool &is_batch_accepted, load_status &status)
#define NULL_TRAN_INDEX
int xsession_end_session(THREAD_ENTRY *thread, const SESSION_ID id)
Definition: session_sr.c:65
bool logtb_is_interrupted(THREAD_ENTRY *thread_p, bool clear, bool *continue_checking)
int xsession_set_tran_auto_commit(THREAD_ENTRY *thread_p, bool auto_commit)
Definition: session_sr.c:370
void slocator_find_class_oid(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
DB_VOLPURPOSE
Definition: dbtype_def.h:185
#define OR_UNPACK_XASL_ID(PTR, X)
Definition: xasl.h:591
static void error(const char *msg)
Definition: gencat.c:331
#define ER_CSS_CLIENTS_EXCEEDED
Definition: error_code.h:809
#define ER_NET_SERVER_HAND_SHAKE
Definition: error_code.h:922
#define VPID_ISNULL(vpid_ptr)
Definition: dbtype_def.h:925
int xsession_set_row_count(THREAD_ENTRY *thread_p, int row_count)
Definition: session_sr.c:78
void sqp_get_sys_timestamp(THREAD_ENTRY *thread_p, unsigned int rid, char *request_ignore, int reqlen_ignore)
static int rc
Definition: serial.c:50
char * or_pack_int(char *ptr, int number)
#define ER_INTERRUPTED
Definition: error_code.h:51
void stran_server_set_global_tran_info(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xtran_server_savepoint(THREAD_ENTRY *thread_p, const char *savept_name, LOG_LSA *savept_lsa)
void qfile_close_scan(THREAD_ENTRY *thread_p, QFILE_LIST_SCAN_ID *scan_id_p)
Definition: list_file.c:4774
LOG_TDES * LOG_FIND_CURRENT_TDES(THREAD_ENTRY *thread_p=NULL)
Definition: log_impl.h:1115
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
Definition: perf_monitor.h:158
#define IS_TRAN_AUTO_COMMIT(flag)
Definition: query_list.h:583
const char * xboot_get_server_session_key(void)
Definition: boot_sr.c:3151
void sboot_find_number_permanent_volumes(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
static void event_log_many_ioreads(THREAD_ENTRY *thread_p, EXECUTION_INFO *info, int time, UINT64 *diff_stats)
void stran_server_end_topop(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define ARG_FILE_LINE
Definition: error_manager.h:44
#define NET_CAP_UPDATE_DISABLED
Definition: network.h:266
int xstats_update_all_statistics(THREAD_ENTRY *thread_p, bool with_fullscan)
TRAN_STATE tran_server_unilaterally_abort_tran(THREAD_ENTRY *thread_p)
#define NET_DEFER_END_QUERIES_MAX
int xheap_destroy(THREAD_ENTRY *thread_p, const HFID *hfid, const OID *class_oid)
Definition: heap_file.c:5786
void event_log_print_client_info(int tran_index, int indent)
Definition: event_log.c:335
void sboot_change_ha_mode(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * or_pack_listid(char *ptr, void *listid)
bool er_has_error(void)
int repl_info_type
Definition: replication.h:55
char * or_pack_method_sig_list(char *ptr, void *method_sig_list)
#define OR_UTIME_SIZE
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
void sboot_find_last_temp(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void ssession_end_session(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slocator_get_class(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
bool reset_on_commit
int buffer_size
Definition: xasl.h:614
void sprm_server_change_parameters(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slocator_find_lockhint_class_oids(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
void ses_posix_read_file(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define OR_CACHE_TIME_SIZE
Definition: cache_time.h:56
int length
Definition: locator.h:283
char * sql_hash_text
Definition: xasl_cache.h:76
const char * get_db_user() const
void slogtb_reset_isolation(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slocator_force(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define free_and_init(ptr)
Definition: memory_alloc.h:147
void stran_server_2pc_prepare_global_tran(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define OR_UNPACK_CACHE_TIME(PTR, T)
Definition: cache_time.h:74
#define strlen(s1)
Definition: intl_support.c:43
void sdk_remarks(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
char * or_pack_lock(char *ptr, LOCK lock)
char * or_unpack_ptr(char *ptr, UINTPTR *ptrval)
void css_set_user_access_status(const char *db_user, const char *host, const char *program_name)
int xstats_update_statistics(THREAD_ENTRY *thread_p, OID *classoid, bool with_fullscan)
int xlogtb_get_pack_tran_table(THREAD_ENTRY *thread_p, char **buffer_p, int *size_p, int include_query_exec_info)
char * or_pack_string_with_length(char *ptr, const char *string, int length)
#define STATS_WITH_FULLSCAN
Definition: statistics.h:34
int xlogtb_kill_or_interrupt_tran(THREAD_ENTRY *thread_p, int tran_id, bool is_dba_group_member, bool interrupt_only)
void xsysprm_dump_server_parameters(FILE *outfp)
void slocator_assign_oid(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void ses_posix_get_file_size(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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)
#define DB_PAGESIZE
unsigned int SESSION_ID
Definition: dbtype_def.h:480
int disk_spacedb(THREAD_ENTRY *thread_p, SPACEDB_ALL *spaceall, SPACEDB_ONEVOL **spacevols)
void slogtb_get_pack_tran_table(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void ssession_stop_attached_threads(void *session)
void xacl_dump(THREAD_ENTRY *thread_p, FILE *outfp)
DKNPAGES xdisk_get_free_numpages(THREAD_ENTRY *thread_p, VOLID volid)
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
bool prm_get_bool_value(PARAM_ID prm_id)
bool is_loaded
Definition: tde.h:148
#define LC_MANYOBJS_PTR_IN_COPYAREA(copy_areaptr)
Definition: locator.h:39
void schksum_insert_repl_log_and_demote_table_lock(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
DB_TIMESTAMP * db_get_timestamp(const DB_VALUE *value)
bool css_is_ha_repl_delayed(void)
HA_SERVER_STATE css_ha_server_state(void)
void slogpb_dump_stat(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int jsp_server_port(void)
Definition: jsp_sr.c:751
void sqmgr_prepare_and_execute_query(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void unpack_all(Args &&...args)
Definition: packer.hpp:397
char * or_unpack_value(const char *buf, DB_VALUE *value)
INTL_CODESET codeset
void er_clear(void)
int xlocator_fetch_lockset(THREAD_ENTRY *thread_p, LC_LOCKSET *lockset, LC_COPYAREA **fetch_area)
Definition: locator_sr.c:3047
SYSPRM_ERR
void perfmon_server_dump_stats_to_buffer(const UINT64 *stats, char *buffer, int buf_size, const char *substr)
char * or_pack_ptr(char *ptr, UINTPTR ptrval)
#define NET_CAP_REMOTE_DISABLED
Definition: network.h:267
enum logwr_mode LOGWR_MODE
Definition: log_writer.h:54
#define XASL_NODE_HEADER_SIZE
Definition: xasl.h:72
char ES_URI[ES_MAX_URI_LEN]
Definition: es.h:35
void slogin_user(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
XASL_ID * xasl_id
Definition: xasl.h:610
void srepl_log_get_append_lsa(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
unsigned int css_send_reply_and_data_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *reply, int reply_size, char *buffer, int buffer_size)
char * locator_pack_copy_area_descriptor(int num_objs, LC_COPYAREA *copyarea, char *desc, int desc_len)
Definition: locator.c:577
char * buffer
Definition: xasl.h:613
int i
Definition: dynamic_load.c:954
void sbtree_load_index(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define ERR_CSS_ERROR_FROM_SERVER
Definition: error_code.h:442
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
void slocator_assign_oid_batch(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
TDE_DATA_KEY_SET data_keys
Definition: tde.h:149
UINT64 * perfmon_allocate_values(void)
DB_TYPE id
#define XASL_ID_IS_NULL(X)
Definition: xasl.h:560
bool xtran_is_blocked(THREAD_ENTRY *thread_p, int tran_index)
void svacuum_dump(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slocator_remove_class_from_index(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int packed_size
Definition: locator.h:301
void ses_posix_create_file(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slog_checkpoint(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slocator_notify_isolation_incons(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define SERVER_SESSION_KEY_SIZE
char * or_pack_log_lsa(const char *ptr, const struct log_lsa *lsa)
#define QFILE_GET_LAST_TUPLE_OFFSET(ptr)
Definition: query_list.h:76
#define NULL_VOLID
const char * comments
void stran_server_get_global_tran_info(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slogtb_does_active_user_exist(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
TRAN_STATE state
Definition: log_impl.h:469
int num_classes_of_reqobjs_processed
Definition: locator.h:297
void slocator_check_fk_validity(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
TRAN_STATE
Definition: log_comm.h:36
int QUERY_FLAG
Definition: query_list.h:585
void stde_get_data_keys(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define QUERY_INFO_BUF_SIZE
#define IO_MAX_PAGE_SIZE
char coll_name[COLL_NAME_SIZE]
void xperfmon_server_copy_global_stats(UINT64 *to_stats)
#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
void svacuum(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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 xtx_change_state_of_locator(cubthread::entry *thread_p, const char *locator, const char *new_locator, LOB_LOCATOR_STATE state)
char * or_unpack_oid_array(char *ptr, int n, OID **oids)
int qmgr_get_sql_id(THREAD_ENTRY *thread_p, char **sql_id_buf, char *query, size_t sql_len)
void xqmgr_dump_query_cache(THREAD_ENTRY *thread_p, FILE *outfp)
char * or_unpack_stream(char *ptr, char *stream, size_t len)
LC_OIDSET * locator_unpack_oid_set_to_new(THREAD_ENTRY *thread_p, char *buffer)
Definition: locator.c:2499
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
#define ER_COMPACTDB_ALREADY_STARTED
Definition: error_code.h:1261
enum ha_server_state HA_SERVER_STATE
Definition: boot.h:126
char * sql_user_text
Definition: xasl_cache.h:77
void sqp_get_server_info(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sboot_compact_stop(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void ssession_drop_session_variables(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
static void sbtree_find_unique_internal(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define INIT_XASL_NODE_HEADER(X)
Definition: xasl.h:98
#define OID_ISNULL(oidp)
Definition: oid.h:81
int server_ping_with_handshake(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sbtree_add_index(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
LOG_RESULT_TOPOP
Definition: log_comm.h:73
bool log_does_allow_replication(void)
Definition: log_comm.c:270
STATIC_INLINE void stran_server_auto_commit_or_abort(THREAD_ENTRY *thread_p, unsigned int rid, QUERY_ID *p_end_queries, int n_query_ids, bool need_abort, bool has_updated, bool *end_query_allowed, TRAN_STATE *tran_state, bool *should_conn_reset) __attribute__((ALWAYS_INLINE))
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)
char * css_add_client_version_string(THREAD_ENTRY *thread_p, const char *version_string)
int num_classes_of_reqobjs
Definition: locator.h:296
#define CHECKDB_ALL_CHECK_EXCEPT_PREV_LINK
void netsr_spacedb(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define QFILE_GET_TUPLE_COUNT(ptr)
Definition: query_list.h:67
void sqmgr_drop_all_query_plans(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sboot_initialize_server(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
const char * program_name
Definition: cas.c:147
void sboot_get_timezone_checksum(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define CUB_MAXHOSTNAMELEN
Definition: porting.h:379
const char * rel_release_string(void)
unsigned int db_on_server
int num_reqobjs_processed
Definition: locator.h:289
int db_error
char * db_full_name
Definition: boot.h:138
STATIC_INLINE TRAN_STATE stran_server_abort_internal(THREAD_ENTRY *thread_p, unsigned int rid, bool retain_lock, bool *should_conn_reset) __attribute__((ALWAYS_INLINE))
void sqst_update_all_statistics(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
static char * host
TRAN_STATE return_error_to_client(THREAD_ENTRY *thread_p, unsigned int rid)
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 xlocator_demote_class_lock(THREAD_ENTRY *thread_p, const OID *class_oid, LOCK lock, LOCK *ex_lock)
Definition: locator_sr.c:13706
#define ER_TDE_CIPHER_IS_NOT_LOADED
Definition: error_code.h:1613
#define DB_MAX_USER_LENGTH
Definition: dbtype_def.h:498
int xlocator_get_reserved_class_name_oid(THREAD_ENTRY *thread_p, const char *classname, OID *class_oid)
Definition: locator_sr.c:689
#define XASL_ID_SET_NULL(X)
Definition: xasl.h:546
#define PEEK
Definition: file_io.h:74
int xtran_server_2pc_start(THREAD_ENTRY *thread_p)
FILEIO_BACKUP_LEVEL
Definition: file_io.h:96
int xheap_reclaim_addresses(THREAD_ENTRY *thread_p, const HFID *hfid)
Definition: heap_file.c:6122
static int er_log_slow_query(THREAD_ENTRY *thread_p, EXECUTION_INFO *info, int time, UINT64 *diff_stats, char *queryinfo_string)
FILEIO_ZIP_METHOD
Definition: file_io.h:104
void stde_get_mk_file_path(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int num_classes
Definition: locator.h:324
#define ER_LAST_ERROR
Definition: error_code.h:1646
unsigned int css_send_error_to_client(CSS_CONN_ENTRY *conn, unsigned int eid, char *buffer, int buffer_size)
void slocator_repl_force(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
#define EXECUTE_QUERY_MAX_ARGUMENT_DATA_SIZE
Definition: network.h:41
void sqst_update_statistics(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void cfg_free_directory(DB_INFO *databases)
LOB_LOCATOR_STATE xtx_find_lob_locator(cubthread::entry *thread_p, const char *locator, char *real_locator)
void sqst_server_get_statistics(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void slogwr_get_log_pages(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
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
int xqmgr_drop_all_query_plans(THREAD_ENTRY *thread_p)
int xlocator_upgrade_instances_domain(THREAD_ENTRY *thread_p, OID *class_oid, int att_id)
Definition: locator_sr.c:12070
int css_notify_ha_log_applier_state(THREAD_ENTRY *thread_p, HA_LOG_APPLIER_STATE state)
#define qmgr_free_old_page_and_init(thread_p, page_p, tfile_vfidp)
Definition: query_manager.h:42
STATIC_INLINE int stran_can_end_after_query_execution(THREAD_ENTRY *thread_p, int query_flag, QFILE_LIST_ID *list_id, bool *can_end_transaction) __attribute__((ALWAYS_INLINE))
const char ** p
Definition: dynamic_load.c:945
char * or_unpack_db_value(char *buffer, DB_VALUE *val)
int intl_identifier_upper(const char *src, char *dst)
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 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
static int check_client_capabilities(THREAD_ENTRY *thread_p, int client_cap, int rel_compare, REL_COMPATIBILITY *compatibility, const char *client_host)
void sacl_reload(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
VOLID xboot_find_last_temp(THREAD_ENTRY *thread_p)
Definition: boot_sr.c:407
#define QFILE_GET_OVERFLOW_PAGE_ID(ptr)
Definition: query_list.h:79
#define MAX_NUM_EXEC_QUERY_HISTORY
Definition: log_impl.h:275
void slocator_does_exist(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sboot_backup(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
void sloaddb_install_class(THREAD_ENTRY *thread_p, unsigned int rid, char *request, int reqlen)
int xtran_server_2pc_recovery_prepared(THREAD_ENTRY *thread_p, int gtrids[], int size)
#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
int ib_thread_count
void session_stop_attached_threads(void *session_arg)
Definition: session.c:3150