CUBRID Engine  latest
parse_dbi.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  * parse_dbi.c - a number of auxiliary functions required to convert parse tree
21  * data structures to data structures compatible with DB interface
22  * functions
23  */
24 
25 #ident "$Id$"
26 
27 #include "config.h"
28 
29 #include <assert.h>
30 #include <stdarg.h>
31 #include <ctype.h>
32 
33 #include "porting.h"
34 #include "error_manager.h"
35 #include "parser.h"
36 #include "xasl_generation.h"
37 #include "parser_message.h"
38 #include "memory_alloc.h"
39 #include "language_support.h"
40 #include "db.h"
41 #include "schema_manager.h"
42 #include "cnv.h"
43 #include "string_opfunc.h"
44 #include "set_object.h"
45 #include "intl_support.h"
46 #include "virtual_object.h"
47 #include "object_primitive.h"
48 #include "object_template.h"
49 #include "db_json.hpp"
50 
51 #if defined (SUPPRESS_STRLEN_WARNING)
52 #define strlen(s1) ((int) strlen(s1))
53 #endif /* defined (SUPPRESS_STRLEN_WARNING) */
54 
55 #define SET_PARSER_ERROR_AND_FREE_NODE(parser, result, default_msg_id) \
56  do { \
57  if (!pt_has_error(parser)) \
58  { \
59  if (er_errid() != NO_ERROR) \
60  { \
61  PT_ERRORc (parser, result, er_msg()); \
62  } \
63  else \
64  { \
65  PT_ERRORm (parser, result, MSGCAT_SET_PARSER_RUNTIME, \
66  default_msg_id); \
67  assert (false); \
68  } \
69  } \
70  parser_free_node (parser, result); \
71  result = NULL; \
72  } while (0)
73 
74 #include "dbtype.h"
75 
77 
78 static PT_NODE *pt_bind_helper (PARSER_CONTEXT * parser, PT_NODE * node, DB_VALUE * val, int *data_type_added);
79 
80 static PT_NODE *pt_bind_set_type (PARSER_CONTEXT * parser, PT_NODE * node, DB_VALUE * val, int *data_type_added);
83 
84 /*
85  * pt_misc_to_qp_misc_operand() - convert a PT_MISC_TYPE trim qualifier or
86  * an extract field specifier to a qp MISC_OPERAND
87  * return: MISC_OPERAND, 0 on error
88  * misc_specifier(in):
89  */
92 {
93  MISC_OPERAND operand;
94 
95  switch (misc_specifier)
96  {
97  case PT_LEADING:
98  operand = LEADING;
99  break;
100  case PT_TRAILING:
101  operand = TRAILING;
102  break;
103  case PT_BOTH:
104  operand = BOTH;
105  break;
106  case PT_YEAR:
107  operand = YEAR;
108  break;
109  case PT_MONTH:
110  operand = MONTH;
111  break;
112  case PT_DAY:
113  operand = DAY;
114  break;
115  case PT_HOUR:
116  operand = HOUR;
117  break;
118  case PT_MINUTE:
119  operand = MINUTE;
120  break;
121  case PT_SECOND:
122  operand = SECOND;
123  break;
124  case PT_MILLISECOND:
125  operand = MILLISECOND;
126  break;
127  case PT_SUBSTR_ORG:
128  operand = SUBSTRING;
129  break;
130  case PT_SUBSTR:
131  operand = SUBSTR;
132  break;
133  default:
134  operand = (MISC_OPERAND) 0; /* technically an error */
135  }
136 
137  return operand;
138 }
139 
140 /*
141  * pt_is_same_enum_data_type() - Compares two enum data types
142  * return: true if exact match, false otherwise
143  * dt1(in): first data type
144  * dt2(in): second data type
145  */
146 bool
148 {
149  PT_NODE *e1 = NULL, *e2 = NULL;
150  PARSER_VARCHAR *pvc1 = NULL, *pvc2 = NULL;
151  int l1 = 0, l2 = 0;
152 
153  if (dt1 == dt2)
154  {
155  return true;
156  }
157 
158  if (dt1 == NULL || dt1->type_enum != PT_TYPE_ENUMERATION || dt2 == NULL || dt2->type_enum != PT_TYPE_ENUMERATION)
159  {
160  return false;
161  }
162 
163  e1 = dt1->info.data_type.enumeration;
164  e2 = dt2->info.data_type.enumeration;
165  for (; e1 != NULL && e2 != NULL; e1 = e1->next, e2 = e2->next)
166  {
167  assert (e1->node_type == PT_VALUE && e2->node_type == PT_VALUE);
168 
169  pvc1 = e1->info.value.data_value.str;
170  pvc2 = e2->info.value.data_value.str;
171  l1 = pt_get_varchar_length (pvc1);
172  l2 = pt_get_varchar_length (pvc2);
173  if (l1 != l2 || memcmp (pt_get_varchar_bytes (pvc1), pt_get_varchar_bytes (pvc2), l1))
174  {
175  break;
176  }
177  }
178 
179  if (e1 == NULL && e2 == NULL)
180  {
181  return true;
182  }
183 
184  return false;
185 }
186 
187 /*
188  * pt_add_type_to_set() - add a db_value's data_type to a set of data_types
189  * return: none
190  * parser(in): handle to parser context
191  * typs(in): a list of PT_DATA_TYPE nodes to add to the set
192  * set(out): a set of PT_DATA_TYPE nodes
193  *
194  * Note :
195  * modifies: parser heap, set
196  */
197 void
199 {
200  PT_TYPE_ENUM typ, expected_typ;
201  PT_NODE *next_typs, *expected_typs = NULL;
202  PT_NODE *s, *ent;
203  DB_OBJECT *cls = NULL;
204  bool found = false;
205  const char *cls_nam = NULL, *e_nam;
206 
207  assert (parser != NULL && set != NULL);
208 
209  while (typs)
210  {
211  /* apparently during runtime, type information is not maintained. for instance: insert into bug(history) values
212  * ({insert into situation(status) values ('e')}); in this case, when pt_evaluate_tree() performs the situation
213  * insert, the resultant object's type is PT_TYPE_NONE. We ignore this situation, although its not clear why it
214  * works. */
215  next_typs = typs->next;
216 
217  /* if the hostvar node with expected domain */
218  if (typs->node_type == PT_HOST_VAR && typs->expected_domain != NULL)
219  {
220  expected_typ = pt_db_to_type_enum (typs->expected_domain->type->id);
221 
222  assert (typs->type_enum == PT_TYPE_MAYBE && PT_IS_CHAR_STRING_TYPE (expected_typ));
223 
224  expected_typs = parser_new_node (parser, PT_DATA_TYPE);
225  expected_typs->type_enum = expected_typ;
226  expected_typs->data_type = pt_domain_to_data_type (parser, typs->expected_domain);
227 
228  typs = expected_typs;
229  }
230 
231  typ = typs->type_enum;
232  if (typ != PT_TYPE_NONE && typ != PT_TYPE_MAYBE)
233  {
234  /* check for system errors */
235  if (typ == PT_TYPE_OBJECT)
236  {
237  if (typs->data_type == NULL)
238  {
239  PT_INTERNAL_ERROR (parser, "interface");
240  goto exit_on_error;
241  }
242 
243  if (typs->data_type->info.data_type.entity == NULL)
244  {
245  /* this type is the generic object */
246  cls_nam = NULL;
247  cls = NULL;
248  }
249  else
250  {
251  /* non-generic object. it must have a class name */
253  cls_nam = db_get_class_name (cls);
254  if (cls == NULL || cls_nam == NULL)
255  {
256  PT_INTERNAL_ERROR (parser, "interface");
257  goto exit_on_error;
258  }
259  }
260  }
261 
262  /* check if the type is already in the set */
263  for (s = *set, found = false; s && s->node_type == PT_DATA_TYPE && !found; s = s->next)
264  {
265  if (typ == s->type_enum)
266  {
267  if (typ == PT_TYPE_OBJECT)
268  {
269  /* for objects, check if the classes are equal */
270  ent = s->info.data_type.entity;
271  if (ent && (ent->node_type == PT_NAME) && (e_nam = ent->info.name.original))
272  {
273  /* ent is not the generic object so equality is based on class_name. But be careful because
274  * the type we're looking for may still be the generic object. */
275  if (cls != NULL)
276  {
277  found = !intl_identifier_casecmp (cls_nam, e_nam);
278  }
279  }
280  else
281  {
282  /* ent must be the generic object, the only way it matches is if typs is also the generic
283  * object. */
284  found = (cls == NULL);
285  }
286  }
287  /* PR) core dumped & deficient character related with CONST CHAR & CHAR in set. */
288  else if (typ == PT_TYPE_CHAR || typ == PT_TYPE_NCHAR || typ == PT_TYPE_BIT)
289  {
291  {
292  continue;
293  }
294  else if (PT_HAS_COLLATION (typ)
296  {
297  continue;
298  }
299 
300  found = true;
301  }
302  else if (typ == PT_TYPE_NUMERIC)
303  {
306  {
307  continue;
308  }
309  found = true;
310  }
311  else if (typ == PT_TYPE_ENUMERATION)
312  {
313  found = pt_is_same_enum_data_type (typs->data_type, s);
314  }
315  else
316  {
317  /* for simple types, equality of type_enum is enough */
318  found = true;
319  }
320  }
321  else
322  {
323  found = false;
324  }
325  }
326 
327  if (!found)
328  {
329  /* prepend it to the set of data_types */
330  PT_NODE *new_typ = NULL;
331  if (typs->data_type == NULL)
332  {
333  new_typ = parser_new_node (parser, PT_DATA_TYPE);
334  new_typ->type_enum = typ;
335  }
336  else
337  {
338  /* If the node has been parameterized by its data_type, node, copy ALL pertinent information into
339  * this node. Datatype parameterization includes ALL the fields of a data_type node (ie, virt_object,
340  * proxy_object, etc). */
341  new_typ = parser_copy_tree_list (parser, typs->data_type);
342  }
343  if (new_typ && PT_IS_COLLECTION_TYPE (typs->type_enum))
344  {
345  /* In case of a set in a multiset the data type must be of type set and not just simply adding types
346  * of the set into the types of multiset */
347  s = parser_new_node (parser, PT_DATA_TYPE);
348  s->type_enum = typs->type_enum;
349  s->data_type = new_typ;
350  new_typ = s;
351  }
352  if (new_typ)
353  {
354  if ((typ == PT_TYPE_OBJECT) && (cls != NULL))
355  {
356  PT_NODE *entity = NULL, *t;
357  entity = pt_add_class_to_entity_list (parser, cls, entity, typs, (UINTPTR) typs, PT_CLASS);
358  if (entity == NULL)
359  {
360  goto exit_on_error;
361  }
362  new_typ->info.data_type.virt_type_enum = typ;
363  if (new_typ->info.data_type.entity != NULL)
364  {
365  parser_free_tree (parser, new_typ->info.data_type.entity);
366  }
367  new_typ->info.data_type.entity = entity;
368 
369  /*
370  * Make sure that everything on the entity list has the
371  * same bloody spec_id.
372  */
373  for (t = entity; t; t = t->next)
374  {
375  t->info.name.spec_id = (UINTPTR) entity;
376  }
377  }
378  new_typ->next = *set;
379  *set = new_typ;
380  }
381  }
382  }
383 
384  if (expected_typs != NULL)
385  {
386  parser_free_node (parser, expected_typs);
387  expected_typs = NULL;
388  }
389 
390  typs = next_typs;
391  } /* while (typs) */
392 
393 exit_on_error:
394  if (expected_typs != NULL)
395  {
396  parser_free_node (parser, expected_typs);
397  expected_typs = NULL;
398  }
399 }
400 
401 /*
402  * pt_get_object_data_type() - derive, create, return a DB_OBJECT's data_type
403  * node from its db_value container
404  * return: val's PT_DATA_TYPE node
405  * parser(in): parser context from which to get PT_NODEs
406  * val(in): a db_value container of type DB_OBJECT
407  *
408  * Note :
409  * requires: val->type == DB_TYPE_OBJECT
410  * modifies: parser's heap
411  * effects : allocates, initializes, returns a new PT_DATA_TYPE node
412  * describing val's data_type
413  */
414 static PT_NODE *
416 {
417  DB_OBJECT *cls;
418  PT_NODE *name, *dt;
419  const char *class_name = NULL;
420 
421  assert (parser != NULL && val != NULL);
422 
423  if (db_value_type (val) != DB_TYPE_OBJECT)
424  {
425  PT_INTERNAL_ERROR (parser, "not object type");
426  return NULL;
427  }
428 
429  cls = (DB_OBJECT *) db_get_class (db_get_object (val));
430  if (cls == NULL)
431  {
432  PT_INTERNAL_ERROR (parser, "unknown class object");
433  return NULL;
434  }
435 
436  class_name = db_get_class_name (cls);
437  if (class_name == NULL)
438  {
439  PT_INTERNAL_ERROR (parser, "unknown class name");
440  return NULL;
441  }
442 
443  name = pt_name (parser, class_name);
444  if (name == NULL)
445  {
446  PT_INTERNAL_ERROR (parser, "allocate new node");
447  return NULL;
448  }
449 
450  dt = parser_new_node (parser, PT_DATA_TYPE);
451  if (dt == NULL)
452  {
453  PT_INTERNAL_ERROR (parser, "allocate new node");
454  return NULL;
455  }
456 
457  name->info.name.db_object = cls;
458  name->info.name.spec_id = (UINTPTR) name;
460  dt->info.data_type.entity = name;
462  if (db_is_vclass (cls) > 0)
463  {
464  dt->info.data_type.virt_object = cls;
465  }
466 
467  return dt;
468 }
469 
470 /*
471  * pt_set_elements_to_value() - allocates, initializes, returns a new PT_VALUE
472  * return: a PT_VALUE type PT_NODE list
473  * parser(in): parser context from which to get a new PT_NODE
474  * val(in): a db_value of a set type
475  */
476 static PT_NODE *
478 {
479  PT_NODE result, *elem = NULL;
480  DB_VALUE element;
481  int error = NO_ERROR;
482  int i, size;
483 
484  assert (parser != NULL && val != NULL);
485 
486  result.next = NULL;
487 
488  db_make_null (&element);
489  for (i = 0, size = db_set_size (db_get_set (val)); i < size && error >= 0; i++)
490  {
491  error = db_set_get (db_get_set (val), i, &element);
492  if (error >= 0 && (elem = pt_dbval_to_value (parser, &element)))
493  {
494  parser_append_node (elem, &result);
495  db_value_clear (&element);
496  }
497  else
498  {
499  result.next = NULL;
500  db_value_clear (&element);
501  break;
502  }
503  }
504 
505  return result.next;
506 }
507 
508 /*
509  * pt_sm_default_value_to_node () - returns a PT_NODE equivalent to the info
510  * in the default_value
511  *
512  * parser (in):
513  * default_value (in):
514  */
515 PT_NODE *
517 {
518  PT_NODE *result;
521 
522  if (sm_attr == NULL || &sm_attr->default_value == NULL)
523  {
524  return NULL;
525  }
526 
527  default_value = &sm_attr->default_value;
528 
529  if (default_value == NULL)
530  {
531  return NULL;
532  }
533 
534  if (default_value->default_expr.default_expr_type == DB_DEFAULT_NONE)
535  {
536  result = pt_dbval_to_value (parser, &default_value->value);
537  if (result == NULL)
538  {
539  return NULL;
540  }
541  }
542  else
543  {
544  result = parser_new_node (parser, PT_EXPR);
545  if (!result)
546  {
547  PT_INTERNAL_ERROR (parser, "allocate new node");
548  return NULL;
549  }
551  }
552 
553  data_type = parser_new_node (parser, PT_DATA_TYPE);
554  if (data_type == NULL)
555  {
556  PT_INTERNAL_ERROR (parser, "allocate new node");
557  parser_free_tree (parser, result);
558  return NULL;
559  }
560  result->type_enum = pt_db_to_type_enum (sm_attr->type->id);
561  data_type->type_enum = result->type_enum;
562  result->data_type = data_type;
563 
564  return result;
565 }
566 
567 /*
568  * pt_dbval_to_value() - convert a db_value into a PT_NODE
569  * return: a PT_VALUE type PT_NODE
570  * parser(in): parser context from which to get a new PT_NODE
571  * val(in): a db_value
572  */
573 PT_NODE *
575 {
576  PT_NODE *result;
577  const char *bytes;
578  int size;
579  DB_OBJECT *mop;
580  DB_TYPE db_type;
581  char buf[100];
582  char *json_body = NULL;
583 
584  assert (parser != NULL && val != NULL);
585 
586  result = parser_new_node (parser, PT_VALUE);
587  if (result == NULL)
588  {
589  PT_INTERNAL_ERROR (parser, "allocate new node");
590  return NULL;
591  }
592 
593  /* copy the db_value */
594  db_value_clone ((DB_VALUE *) val, &result->info.value.db_value);
595  result->info.value.db_value_is_initialized = true;
596  result->info.value.db_value_is_in_workspace = true;
597 
598  db_type = DB_VALUE_TYPE (val);
599  result->type_enum = pt_db_to_type_enum (db_type);
600 
601  switch (db_type)
602  {
603  case DB_TYPE_NULL:
604  result->type_enum = PT_TYPE_NULL;
605  break;
606  case DB_TYPE_SET:
607  result->info.value.data_value.set = pt_set_elements_to_value (parser, val);
608  pt_add_type_to_set (parser, result->info.value.data_value.set, &result->data_type);
609  break;
610  case DB_TYPE_MULTISET:
611  result->info.value.data_value.set = pt_set_elements_to_value (parser, val);
612  pt_add_type_to_set (parser, result->info.value.data_value.set, &result->data_type);
613  break;
614  case DB_TYPE_SEQUENCE:
615  result->info.value.data_value.set = pt_set_elements_to_value (parser, val);
616  pt_add_type_to_set (parser, result->info.value.data_value.set, &result->data_type);
617  break;
618 
619  case DB_TYPE_INTEGER:
620  result->info.value.data_value.i = db_get_int (val);
621  break;
622  case DB_TYPE_BIGINT:
623  result->info.value.data_value.bigint = db_get_bigint (val);
624  break;
625  case DB_TYPE_FLOAT:
626  result->info.value.data_value.f = db_get_float (val);
627  break;
628  case DB_TYPE_DOUBLE:
629  result->info.value.data_value.d = db_get_double (val);
630  break;
631  case DB_TYPE_JSON:
632  result->data_type = parser_new_node (parser, PT_DATA_TYPE);
633  if (result->data_type == NULL)
634  {
635  parser_free_node (parser, result);
636  result = NULL;
637  }
638  else
639  {
640  result->data_type->type_enum = result->type_enum;
641  json_body = db_get_json_raw_body (val);
642  result->info.value.data_value.str = pt_append_nulstring (parser, (PARSER_VARCHAR *) NULL, json_body);
643  db_private_free (NULL, json_body);
644  if (db_get_json_schema (val) != NULL)
645  {
646  /* check valid schema */
648  {
649  assert (false);
650  parser_free_node (parser, result);
651  PT_INTERNAL_ERROR (parser, "invalid json schema");
652  result = NULL;
653  }
654  else
655  {
658  }
659  }
660  }
661  break;
662  case DB_TYPE_NUMERIC:
663  numeric_db_value_print (val, buf);
664  result->info.value.data_value.str = pt_append_nulstring (parser, (PARSER_VARCHAR *) NULL, (const char *) buf);
665  result->data_type = parser_new_node (parser, PT_DATA_TYPE);
666  if (result->data_type == NULL)
667  {
668  parser_free_node (parser, result);
669  result = NULL;
670  }
671  else
672  {
673  result->data_type->type_enum = result->type_enum;
676  }
677  break;
678 
679  case DB_TYPE_VARNCHAR:
680  case DB_TYPE_NCHAR:
681  case DB_TYPE_VARCHAR:
682  case DB_TYPE_CHAR:
683  bytes = db_get_string (val);
684  size = db_get_string_size (val);
685  result->info.value.data_value.str = pt_append_bytes (parser, NULL, bytes, size);
686  result->info.value.data_value.str->length = size;
687  if (db_type == DB_TYPE_VARNCHAR || db_type == DB_TYPE_NCHAR)
688  {
689  result->info.value.string_type = 'N';
690  }
691  else
692  {
693  result->info.value.string_type = ' ';
694  }
695  result->data_type = parser_new_node (parser, PT_DATA_TYPE);
696  if (result->data_type == NULL)
697  {
698  parser_free_node (parser, result);
699  result = NULL;
700  }
701  else
702  {
703  result->data_type->type_enum = result->type_enum;
707  assert (result->data_type->info.data_type.collation_id >= 0);
708  }
709  break;
710  case DB_TYPE_BIT:
711  case DB_TYPE_VARBIT:
712  {
713  int max_length = 0;
714  char *printed_bit = NULL;
715 
716  size = 0;
717  bytes = db_get_bit (val, &size);
718  max_length = ((size + 3) / 4) + 4;
719  printed_bit = (char *) db_private_alloc (NULL, max_length);
720  if (printed_bit == NULL)
721  {
723  parser_free_node (parser, result);
724  result = NULL;
725  break;
726  }
727  if (db_bit_string (val, "%X", printed_bit, max_length) != NO_ERROR)
728  {
729  db_private_free_and_init (NULL, printed_bit);
732  parser_free_node (parser, result);
733  result = NULL;
734  break;
735  }
736 
737  /* get the printed size */
738  size = strlen (printed_bit);
739 
740  result->info.value.string_type = 'X';
741  result->info.value.data_value.str = pt_append_bytes (parser, NULL, printed_bit, size);
742 
743  db_private_free_and_init (NULL, printed_bit);
744 
745  result->info.value.data_value.str->length = size;
746 
747  result->data_type = parser_new_node (parser, PT_DATA_TYPE);
748  if (result->data_type == NULL)
749  {
750  parser_free_node (parser, result);
751  result = NULL;
752  }
753  else
754  {
755  result->data_type->type_enum = result->type_enum;
758  }
759  break;
760  }
761  case DB_TYPE_OBJECT:
762  result->info.value.data_value.op = db_get_object (val);
763  result->data_type = pt_get_object_data_type (parser, val);
764  if (result->data_type == NULL)
765  {
766  parser_free_node (parser, result);
767  result = NULL;
768  }
769  break;
770  case DB_TYPE_TIME:
771  if (db_time_to_string (buf, sizeof (buf), db_get_time (val)) == 0)
772  {
774  }
775  else
776  {
777  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
778  }
779  break;
780  case DB_TYPE_TIMESTAMP:
781  if (db_utime_to_string (buf, sizeof (buf), db_get_timestamp (val)) == 0)
782  {
784  }
785  else
786  {
787  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
788  }
789  break;
791  if (db_timestampltz_to_string (buf, sizeof (buf), db_get_timestamp (val)) == 0)
792  {
794  }
795  else
796  {
797  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
798  }
799  break;
800  case DB_TYPE_TIMESTAMPTZ:
801  {
802  DB_TIMESTAMPTZ *ts_tz = db_get_timestamptz (val);
803 
804  if (db_timestamptz_to_string (buf, sizeof (buf), &ts_tz->timestamp, &ts_tz->tz_id) == 0)
805  {
807  }
808  else
809  {
810  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
811  }
812  }
813  break;
814  case DB_TYPE_DATETIME:
815  if (db_datetime_to_string (buf, sizeof (buf), db_get_datetime (val)) == 0)
816  {
818  }
819  else
820  {
821  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
822  }
823  break;
824  case DB_TYPE_DATETIMELTZ:
825  if (db_datetimeltz_to_string (buf, sizeof (buf), db_get_datetime (val)) == 0)
826  {
828  }
829  else
830  {
831  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
832  }
833  break;
834  case DB_TYPE_DATETIMETZ:
835  {
836  DB_DATETIMETZ *dt_tz = db_get_datetimetz (val);
837 
838  if (db_datetimetz_to_string (buf, sizeof (buf), &dt_tz->datetime, &(dt_tz->tz_id)) == 0)
839  {
841  }
842  else
843  {
844  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
845  }
846  }
847  break;
848  case DB_TYPE_DATE:
849  if (db_date_to_string (buf, sizeof (buf), db_get_date (val)) == 0)
850  {
852  }
853  else
854  {
855  result->info.value.data_value.str = pt_append_bytes (parser, NULL, buf, strlen (buf));
856  }
857  break;
858  case DB_TYPE_MONETARY:
861  result->data_type = parser_new_node (parser, PT_DATA_TYPE);
862  if (result->data_type == NULL)
863  {
864  parser_free_node (parser, result);
865  result = NULL;
866  }
867  else
868  {
869  result->data_type->type_enum = result->type_enum;
871  }
872  break;
873  case DB_TYPE_SHORT:
874  result->info.value.data_value.i = db_get_short (val);
875  break;
876 
877  case DB_TYPE_VOBJ:
878  if (vid_vobj_to_object (val, &mop) != NO_ERROR)
879  {
880  parser_free_node (parser, result);
881  result = NULL;
882  }
883  else
884  {
885  db_make_object (&result->info.value.db_value, mop);
886  result->type_enum = PT_TYPE_OBJECT;
887  result->data_type = pt_get_object_data_type (parser, &result->info.value.db_value);
888  if (result->data_type == NULL)
889  {
890  parser_free_node (parser, result);
891  result = NULL;
892  }
893  }
894  break;
895 
896  case DB_TYPE_OID:
897  if (vid_oid_to_object (val, &mop) != NO_ERROR)
898  {
899  parser_free_node (parser, result);
900  result = NULL;
901  }
902  else
903  {
904  db_make_object (&result->info.value.db_value, mop);
905  result->type_enum = PT_TYPE_OBJECT;
906  result->data_type = pt_get_object_data_type (parser, &result->info.value.db_value);
907  if (result->data_type == NULL)
908  {
909  parser_free_node (parser, result);
910  result = NULL;
911  }
912  }
913  break;
914 
915  case DB_TYPE_BLOB:
916  case DB_TYPE_CLOB:
917  {
918  DB_ELO *db_elo;
919 
920  db_elo = db_get_elo (val);
921  if (db_elo)
922  {
923  if (db_elo_copy_structure (db_elo, &result->info.value.data_value.elo) != NO_ERROR)
924  {
925  parser_free_node (parser, result);
926  result = NULL;
927  }
928  }
929 
930  result->type_enum = db_type == DB_TYPE_BLOB ? PT_TYPE_BLOB : PT_TYPE_CLOB;
931  }
932  break;
933 
934  case DB_TYPE_ENUMERATION:
935  bytes = db_get_enum_string (val);
936  size = db_get_enum_string_size (val);
938  if (db_get_enum_short (val) != 0)
939  {
940  result->info.value.data_value.enumeration.str_val = pt_append_bytes (parser, NULL, bytes, size);
941  result->info.value.text = (const char *) result->info.value.data_value.enumeration.str_val->bytes;
942  }
943  result->data_type = NULL;
944  break;
945 
946  /* explicitly treat others as an error condition */
947  case DB_TYPE_VARIABLE:
948  case DB_TYPE_SUB:
949  case DB_TYPE_POINTER:
950  case DB_TYPE_ERROR:
951  case DB_TYPE_DB_VALUE:
952  case DB_TYPE_TABLE:
953  parser_free_node (parser, result);
954  result = NULL;
955  break;
956  default:
957  /* ALL TYPES MUST HAVE AN EXPLICIT CONVERSION, OR THE CODE IS IN ERROR */
958  assert (false);
959  }
960 
961  return result;
962 }
963 
964 /*
965  * pt_seq_value_to_db() - add elements into a DB_VALUE sequence
966  * return: db_value if all OK, NULL otherwise.
967  * parser(in): handle to parser context
968  * values(in): the elements to be inserted
969  * db_value(out): a sequence value container
970  * el_types(out): the seq's element data_types
971  *
972  * Note :
973  * requires: db_value is an empty sequence value container
974  * values is a list of elements
975  * modifies: db_value, parser->error_msgs
976  * effects : evaluates and adds the values as elements of the db_value
977  */
978 DB_VALUE *
980 {
981  PT_NODE *element;
982  DB_VALUE e_val;
983  int indx;
984 
985  assert (parser != NULL);
986  db_make_null (&e_val);
987 
988  for (element = values, indx = 0; element != NULL; element = element->next, indx++)
989  {
990  pt_evaluate_tree (parser, element, &e_val, 1);
991  if (!pt_has_error (parser))
992  {
993  if (db_seq_put (db_get_set (db_value), indx, &e_val) != NO_ERROR)
994  {
995  PT_ERRORc (parser, element, db_error_string (3));
996  pr_clear_value (&e_val);
997  return NULL;
998  }
999  }
1000  else
1001  {
1002  /* this is not an error case, but a result of the use of PT_VALUE node to represent non constant expressions
1003  * Here we are trying to convert a non-constant expression, and failed. NULL is returned, indicating that a
1004  * db_value cannot be made, because this is not a constant sequence. Yeah, this is a kludge.... */
1005  pr_clear_value (&e_val);
1006  return NULL;
1007  }
1008  /* db_seq_add() clones the value so we can clear the element value generated by pt_evaluate_tree() */
1009  pr_clear_value (&e_val);
1010  }
1011 
1012  pt_add_type_to_set (parser, values, el_types);
1013 
1014  return db_value;
1015 }
1016 
1017 /*
1018  * pt_set_value_to_db() - add set elements into a DB_VALUE set/multiset
1019  * return: db_value if all OK, NULL otherwise.
1020  * parser(in): handle to parser context
1021  * values(in/out): the set/multiset elements to be inserted
1022  * db_value(out): a set or multiset value container
1023  * el_types(out): the set's element data_types
1024  *
1025  * Note :
1026  * requires: db_value is a set or multiset value container
1027  * values is a list of set/multiset elements
1028  * modifies: db_value, parser->error_msgs, values
1029  * effects : evaluates and adds the values as elements of the db_value
1030  * set or multiset.
1031  */
1032 DB_VALUE *
1034 {
1035  PT_NODE *element;
1036  DB_VALUE e_val;
1037 
1038  assert (parser != NULL && values != NULL);
1039  db_make_null (&e_val);
1040 
1041  for (element = *values; element != NULL; element = element->next)
1042  {
1043  pt_evaluate_tree (parser, element, &e_val, 1);
1044  if (!pt_has_error (parser))
1045  {
1046  if (db_set_add (db_get_set (db_value), &e_val) != NO_ERROR)
1047  {
1048  PT_ERRORc (parser, element, db_error_string (3));
1049 
1050  if (DB_VALUE_TYPE (&e_val) == DB_TYPE_POINTER)
1051  {
1052  obt_quit ((OBJ_TEMPLATE *) db_get_pointer (&e_val));
1053  }
1054  return NULL;
1055  }
1056  }
1057  else
1058  {
1059  /* this is not an error case, but a result of the use of PT_VALUE node to represent non constant expressions
1060  * Here we are trying to convert a non-constant expression, and failed. NULL is returned, indicating that a
1061  * db_value cannot be made, because this is not a constant set. Yeah, this is a kludge.... */
1062  return NULL;
1063  }
1064  /* db_set_add() clones the value so we can clear the element value generated by pt_evaluate_tree() */
1065  pr_clear_value (&e_val);
1066  }
1067 
1068  pt_add_type_to_set (parser, *values, el_types);
1069 
1070  return db_value;
1071 }
1072 
1073 
1074 /*
1075  * pt_value_to_db() - converts a PT_VALUE type node into a DB_VALUE
1076  * return: DB_VALUE equivalent of value on successful conversion
1077  * NULL otherwise
1078  * parser(in): handle to context used to derive PT_VALUE type node,
1079  * may also have associated host_variable bound DB_VALUEs
1080  * value(in): the PT_VALUE type node to be converted to DB_VALUE
1081  *
1082  * Note :
1083  * requires: parser is the parser context used to derive value
1084  * value is a PT_VALUE type node
1085  * modifies: heap, parser->error_msgs, value->data_type
1086  */
1087 DB_VALUE *
1089 {
1090  DB_VALUE *db_value;
1091  int more_type_info_needed;
1092 
1093  assert (parser != NULL);
1094 
1095  if (value == NULL || !pt_is_const (value))
1096  {
1097  return NULL;
1098  }
1099 
1100  /*
1101  * if it is an input host_variable then its associated DB_VALUE is in parser->host_variables[x] */
1102  if (value->node_type == PT_HOST_VAR && value->info.host_var.var_type == PT_HOST_IN)
1103  {
1104  DB_DOMAIN *hv_dom;
1105 
1106  db_value = pt_host_var_db_value (parser, value);
1107 
1108  if (db_value)
1109  {
1110  if (value->type_enum != PT_TYPE_NONE && value->type_enum != PT_TYPE_NULL && value->type_enum != PT_TYPE_MAYBE
1111  && value->type_enum != PT_TYPE_NUMERIC && value->type_enum != PT_TYPE_CHAR
1112  && value->type_enum != PT_TYPE_NCHAR && value->type_enum != PT_TYPE_BIT
1113  && value->type_enum != PT_TYPE_VARCHAR && value->type_enum != PT_TYPE_VARNCHAR
1114  && value->type_enum != PT_TYPE_VARBIT && (hv_dom = pt_node_to_db_domain (parser, value, NULL)) != NULL)
1115  {
1116  /* host_var node "value" has a useful domain for itself so that check compatibility between the "value"
1117  * and the host variable provided by the user */
1118 
1119  hv_dom = tp_domain_cache (hv_dom);
1120  if (!hv_dom /* must be cached before use! */
1121  || tp_value_cast (db_value, db_value, hv_dom, false) != DOMAIN_COMPATIBLE)
1122  {
1124  pt_node_to_db_domain_name (value));
1125  return NULL;
1126  }
1127 
1128  }
1129  else
1130  {
1131  DB_TYPE expected_db_type, val_type;
1132  /* host var node "value" has no useful domain, which probably means that it's a so-far untyped host var
1133  * reference whose type we're trying to deduce from the supplied value itself. Just return the value and
1134  * continue on... */
1135  if (value->expected_domain)
1136  {
1137  expected_db_type = TP_DOMAIN_TYPE (value->expected_domain);
1138  }
1139  else
1140  {
1141  expected_db_type = DB_TYPE_NULL;
1142  }
1143 
1144  val_type = DB_VALUE_DOMAIN_TYPE (db_value);
1145  /* if "value" has expected domain but its type is different from the supplied value, we need to deduce
1146  * from the supplied value */
1147  if ((value->type_enum == PT_TYPE_MAYBE)
1148  || (expected_db_type != DB_TYPE_NULL && expected_db_type != val_type))
1149  {
1150 
1151  if (expected_db_type != DB_TYPE_NULL && expected_db_type != val_type)
1152  {
1153 
1154  if ((expected_db_type == DB_TYPE_CHAR && val_type == DB_TYPE_VARCHAR)
1155  || (expected_db_type == DB_TYPE_NCHAR && val_type == DB_TYPE_VARNCHAR)
1156  || (expected_db_type == DB_TYPE_BIT && val_type == DB_TYPE_VARBIT))
1157  {
1158  /* to prevent padding, skip these cases */
1159  }
1160  /* cast db_value */
1161  else if (tp_value_cast_preserve_domain (db_value, db_value, value->expected_domain, false, true)
1162  != DOMAIN_COMPATIBLE)
1163  {
1165  "host var", pr_type_name (expected_db_type));
1166  return NULL;
1167  }
1168  }
1169 
1170  if (pt_bind_type_from_dbval (parser, value, db_value) == NULL)
1171  {
1172  return NULL;
1173  }
1174 
1175  /* In case of DB_TYPE_ENUMERATION as expected type we need to compute data type from expected_domain
1176  * of host variable */
1177  if (value->type_enum == PT_TYPE_ENUMERATION && expected_db_type == DB_TYPE_ENUMERATION)
1178  {
1179  value->data_type = pt_domain_to_data_type (parser, value->expected_domain);
1180  }
1181  hv_dom = pt_node_to_db_domain (parser, value, NULL);
1182  hv_dom = tp_domain_cache (hv_dom);
1183  if (!hv_dom /* domain must be cached before use! */
1184  || tp_value_coerce (db_value, db_value, hv_dom) != DOMAIN_COMPATIBLE)
1185  {
1187  "host var", pt_node_to_db_domain_name (value));
1188  return NULL;
1189  }
1190  value->expected_domain = hv_dom;
1191  }
1192  else
1193  {
1194  if (pt_bind_type_from_dbval (parser, value, db_value) == NULL)
1195  {
1196  return NULL;
1197  }
1198  }
1199  }
1200 
1201  }
1202  else /* if (db_value) */
1203  {
1204  if (parser->flag.set_host_var == 1)
1205  {
1207  value->info.host_var.index, parser->host_var_count);
1208  }
1209  return NULL;
1210  }
1211 
1212  return db_value;
1213  }
1214  else if (value->node_type == PT_NAME && value->info.name.meta_class == PT_PARAMETER)
1215  {
1216  db_value = pt_find_value_of_label (value->info.name.original);
1217  if (!db_value)
1218  {
1220  value->info.name.original);
1221  return (DB_VALUE *) NULL;
1222  }
1223  return db_value;
1224  }
1225 
1226  /* don't reinitialize non-empty DB_VALUE containers */
1227  db_value = &value->info.value.db_value;
1228  if (value->info.value.db_value_is_initialized)
1229  {
1230  return db_value;
1231  }
1232 
1233  more_type_info_needed = 0;
1234  if (pt_db_value_initialize (parser, value, db_value, &more_type_info_needed) == NULL)
1235  {
1236  return (DB_VALUE *) NULL;
1237  }
1238  else
1239  {
1240  value->info.value.db_value_is_initialized = true;
1241  }
1242 
1243  /*
1244  * We want to make sure that none of the parameterized types can leave
1245  * here without the proper DATA_TYPE information tacked onto them. A
1246  * common symptom of a screwup here is character strings that are
1247  * misinterpreted when they are unpacked from list files, caused by the
1248  * unpacker using a different domain than that used by the packer.
1249  */
1250  if (more_type_info_needed)
1251  {
1252  pt_bind_type_from_dbval (parser, value, db_value);
1253  }
1254 
1255  return (db_value);
1256 }
1257 
1258 // pt_data_type_init_value - initialize value according to node data type
1259 //
1260 // node : PT_NODE for which value_out is initialized
1261 // value_out : DB_VALUE initialized according to node data type
1262 //
1263 void
1264 pt_data_type_init_value (const PT_NODE * node, DB_VALUE * value_out)
1265 {
1266  // init as null
1267  db_make_null (value_out);
1268 
1269  // make sure we get rid of pointer
1270  CAST_POINTER_TO_NODE (node);
1271 
1272  if (node->data_type == NULL)
1273  {
1274  // init as node->type_enum
1276  return;
1277  }
1278  // node->data_type is not null
1279 
1280  // get data type
1281  PT_NODE *node_data_type = node->data_type;
1282  DB_TYPE node_db_type = pt_type_enum_to_db (node_data_type->type_enum);
1283 
1284  if (node_db_type == DB_TYPE_OBJECT && node->data_type->info.data_type.virt_object != NULL)
1285  {
1286  // virtual object
1287  node_db_type = DB_TYPE_VOBJ;
1288  }
1289 
1290  db_value_domain_init_default (value_out, node_db_type);
1291  switch (node_db_type)
1292  {
1293  case DB_TYPE_VARCHAR:
1294  case DB_TYPE_CHAR:
1295  case DB_TYPE_NCHAR:
1296  case DB_TYPE_VARNCHAR:
1297  case DB_TYPE_BIT:
1298  case DB_TYPE_VARBIT:
1299  value_out->domain.char_info.length = node_data_type->info.data_type.precision;
1300  break;
1301 
1302  case DB_TYPE_NUMERIC:
1303  value_out->domain.numeric_info.precision = node_data_type->info.data_type.precision;
1304  value_out->domain.numeric_info.scale = node_data_type->info.data_type.dec_precision;
1305  break;
1306  case DB_TYPE_JSON:
1307  // we should really move json_schema from value.data
1308  if (node_data_type->info.data_type.json_schema != NULL)
1309  {
1310  value_out->data.json.schema_raw =
1311  db_private_strdup (NULL, (const char *) node_data_type->info.data_type.json_schema->bytes);
1312  value_out->need_clear = true;
1313  }
1314  else
1315  {
1316  value_out->data.json.schema_raw = NULL;
1317  }
1318  break;
1319 
1320  default:
1321  ; /* Do nothing. This suppresses compiler's warnings. */
1322  }
1323 }
1324 
1325 /*
1326  * pt_string_to_db_domain() - returns DB_DOMAIN * that matches the string
1327  * return: a DB_DOMAIN
1328  * s(in) : a string
1329  * class_name(in): name of the class
1330  */
1331 DB_DOMAIN *
1332 pt_string_to_db_domain (const char *s, const char *class_name)
1333 {
1334  DB_DOMAIN *retval = (DB_DOMAIN *) 0;
1336  PT_NODE **dtp, *dt;
1337  char *stmt;
1338  const char *prefix = "DATA_TYPE___ ";
1339 
1340  if (s == NULL)
1341  {
1342  return (DB_DOMAIN *) NULL;
1343  }
1344 
1345  stmt = (char *) malloc (strlen (prefix) + strlen (s) + 1);
1346  if (stmt == NULL)
1347  {
1349  (size_t) (strlen (prefix) + strlen (s) + 1));
1350  return (DB_DOMAIN *) NULL;
1351  }
1352 
1353  sprintf (stmt, "%s%s", prefix, s);
1354  parser = parser_create_parser ();
1355  if (parser)
1356  {
1357  dtp = parser_parse_string (parser, stmt);
1358  if (!pt_has_error (parser) && dtp)
1359  {
1360  dt = *dtp;
1361  if (dt && (dt->node_type == PT_DATA_TYPE))
1362  {
1363  retval = pt_data_type_to_db_domain (parser, dt, class_name);
1364  }
1365  }
1366  else
1367  {
1368  pt_report_to_ersys (parser, PT_SYNTAX);
1369  }
1370  parser_free_parser (parser);
1371  }
1372  free_and_init (stmt);
1373 
1374  return retval;
1375 }
1376 
1377 #if defined(ENABLE_UNUSED_FUNCTION)
1378 /*
1379  * pt_string_to_data_type() - adorns a PT_NODE with the type that matches
1380  * the string
1381  * return: none
1382  * parser(in):
1383  * s(in): domain string
1384  * node(out):
1385  */
1386 void
1387 pt_string_to_data_type (PARSER_CONTEXT * parser, const char *s, PT_NODE * node)
1388 {
1389  DB_DOMAIN *dom;
1390 
1391  dom = pt_string_to_db_domain (s, NULL);
1392  if (dom == NULL)
1393  {
1394  return;
1395  }
1396 
1398  switch (node->type_enum)
1399  {
1400  case PT_TYPE_OBJECT:
1401  case PT_TYPE_SET:
1402  case PT_TYPE_SEQUENCE:
1403  case PT_TYPE_MULTISET:
1404  case PT_TYPE_NUMERIC:
1405  case PT_TYPE_BIT:
1406  case PT_TYPE_VARBIT:
1407  case PT_TYPE_CHAR:
1408  case PT_TYPE_VARCHAR:
1409  case PT_TYPE_NCHAR:
1410  case PT_TYPE_VARNCHAR:
1411  node->data_type = pt_domain_to_data_type (parser, dom);
1412  break;
1413  default:
1414  break;
1415  }
1416 }
1417 #endif /* ENABLE_UNUSED_FUNCTION */
1418 
1419 /*
1420  * pt_type_enum_to_db_domain_name() - returns string form of t's datatype
1421  * return: character string denoting datatype dt
1422  * t(in): a PT_TYPE_ENUM
1423  */
1424 /* TODO: PT_TYPE_ENUM should be changed to
1425  * PT_TYPE_NUM by adjusting the order of including header files */
1426 const char *
1428 {
1429  const char *name;
1430 
1431  switch (t)
1432  {
1433  default:
1434  name = "unknown data_type";
1435  break;
1436  case PT_TYPE_NONE:
1437  name = "none";
1438  break;
1439 
1440  case PT_TYPE_LOGICAL:
1441  case PT_TYPE_INTEGER:
1442  name = "integer";
1443  break;
1444  case PT_TYPE_BIGINT:
1445  name = "bigint";
1446  break;
1447  case PT_TYPE_SMALLINT:
1448  name = "short";
1449  break;
1450  case PT_TYPE_NUMERIC:
1451  name = "numeric";
1452  break;
1453  case PT_TYPE_FLOAT:
1454  name = "float";
1455  break;
1456  case PT_TYPE_DOUBLE:
1457  name = "double";
1458  break;
1459 
1460  case PT_TYPE_DATE:
1461  name = "date";
1462  break;
1463 
1464  case PT_TYPE_TIME:
1465  return "time";
1466 
1467  case PT_TYPE_TIMESTAMP:
1468  name = "timestamp";
1469  break;
1470  case PT_TYPE_TIMESTAMPLTZ:
1471  name = "timestampltz";
1472  break;
1473  case PT_TYPE_TIMESTAMPTZ:
1474  name = "timestamptz";
1475  break;
1476 
1477  case PT_TYPE_DATETIME:
1478  name = "datetime";
1479  break;
1480  case PT_TYPE_DATETIMETZ:
1481  name = "datetimetz";
1482  break;
1483  case PT_TYPE_DATETIMELTZ:
1484  name = "datetimeltz";
1485  break;
1486 
1487  case PT_TYPE_MONETARY:
1488  name = "monetary";
1489  break;
1490 
1491  case PT_TYPE_VARCHAR:
1492  name = "char varying";
1493  break;
1494  case PT_TYPE_CHAR:
1495  name = "char";
1496  break;
1497 
1498  case PT_TYPE_OBJECT:
1499  name = "object";
1500  break;
1501 
1502  case PT_TYPE_SET:
1503  name = "set";
1504  break;
1505  case PT_TYPE_MULTISET:
1506  name = "multiset";
1507  break;
1508  case PT_TYPE_SEQUENCE:
1509  name = "sequence";
1510  break;
1511 
1512  case PT_TYPE_NCHAR:
1513  name = "nchar";
1514  break;
1515  case PT_TYPE_VARNCHAR:
1516  name = "nchar varying";
1517  break;
1518  case PT_TYPE_BIT:
1519  name = "bit";
1520  break;
1521  case PT_TYPE_VARBIT:
1522  name = "bit varying";
1523  break;
1524 
1525  case PT_TYPE_BLOB:
1526  name = "blob";
1527  break;
1528  case PT_TYPE_CLOB:
1529  name = "clob";
1530  break;
1531 
1532  case PT_TYPE_ENUMERATION:
1533  name = "enum";
1534  break;
1535  case PT_TYPE_JSON:
1536  name = "json";
1537  break;
1538  }
1539 
1540  return name;
1541 }
1542 
1543 /*
1544  * pt_type_enum_to_db_domain() - returns DB_DOMAIN * that matches a simple type
1545  * return: a DB_DOMAIN
1546  * t(in): a PT_TYPE_ENUM
1547  */
1548 DB_DOMAIN *
1550 {
1551  DB_DOMAIN *retval = (DB_DOMAIN *) 0;
1552  DB_TYPE domain_type;
1553 
1554  domain_type = pt_type_enum_to_db (t);
1555  switch (domain_type)
1556  {
1557  case DB_TYPE_INTEGER:
1558  retval = tp_domain_construct (domain_type, NULL, DB_INTEGER_PRECISION, 0, NULL);
1559  break;
1560  case DB_TYPE_SHORT:
1561  retval = tp_domain_construct (domain_type, NULL, DB_SHORT_PRECISION, 0, NULL);
1562  break;
1563  case DB_TYPE_BIGINT:
1564  retval = tp_domain_construct (domain_type, NULL, DB_BIGINT_PRECISION, 0, NULL);
1565  break;
1566  case DB_TYPE_FLOAT:
1567  retval = tp_domain_construct (domain_type, NULL, DB_FLOAT_DECIMAL_PRECISION, 0, NULL);
1568  break;
1569  case DB_TYPE_DOUBLE:
1570  retval = tp_domain_construct (domain_type, NULL, DB_DOUBLE_DECIMAL_PRECISION, 0, NULL);
1571  break;
1572  case DB_TYPE_MONETARY:
1573  retval = tp_domain_construct (domain_type, NULL, DB_MONETARY_DECIMAL_PRECISION, 0, NULL);
1574  break;
1575  case DB_TYPE_TIME:
1576  retval = tp_domain_construct (domain_type, NULL, DB_TIME_PRECISION, 0, NULL);
1577  break;
1578  case DB_TYPE_DATE:
1579  retval = tp_domain_construct (domain_type, NULL, DB_DATE_PRECISION, 0, NULL);
1580  break;
1581  case DB_TYPE_TIMESTAMPLTZ:
1582  case DB_TYPE_TIMESTAMP:
1583  retval = tp_domain_construct (domain_type, NULL, DB_TIMESTAMP_PRECISION, 0, NULL);
1584  break;
1585  case DB_TYPE_TIMESTAMPTZ:
1586  retval = tp_domain_construct (domain_type, NULL, DB_TIMESTAMPTZ_PRECISION, 0, NULL);
1587  break;
1588  case DB_TYPE_DATETIMELTZ:
1589  case DB_TYPE_DATETIME:
1591  break;
1592  case DB_TYPE_DATETIMETZ:
1594  break;
1595  case DB_TYPE_BLOB:
1596  case DB_TYPE_CLOB:
1597  case DB_TYPE_SUB:
1598  case DB_TYPE_POINTER:
1599  case DB_TYPE_ERROR:
1600  case DB_TYPE_VOBJ:
1601  case DB_TYPE_OID:
1602  case DB_TYPE_OBJECT:
1603  case DB_TYPE_SET:
1604  case DB_TYPE_MULTISET:
1605  case DB_TYPE_SEQUENCE:
1606  case DB_TYPE_MIDXKEY:
1607  case DB_TYPE_ENUMERATION:
1608  case DB_TYPE_JSON:
1609  retval = tp_domain_construct (domain_type, (DB_OBJECT *) 0, 0, 0, (TP_DOMAIN *) 0);
1610  break;
1611 
1612  case DB_TYPE_NUMERIC:
1614  break;
1615 
1616  case DB_TYPE_CHAR:
1617  case DB_TYPE_NCHAR:
1618  case DB_TYPE_BIT:
1619  case DB_TYPE_VARCHAR:
1620  case DB_TYPE_VARNCHAR:
1621  case DB_TYPE_VARBIT:
1622  /* Note that we assume that some other force is going to come in and repair the precision of the destination of
1623  * this domain is for the schema manager. Might be a problem . . . */
1624  retval = tp_domain_construct (domain_type, NULL, TP_FLOATING_PRECISION_VALUE, 0, NULL);
1625  break;
1626 
1627  case DB_TYPE_NULL:
1628  retval = &tp_Null_domain;
1629  break;
1630 
1631  case DB_TYPE_VARIABLE:
1632  retval = &tp_Variable_domain;
1633  break;
1634 
1635  case DB_TYPE_DB_VALUE:
1636  case DB_TYPE_TABLE:
1637  case DB_TYPE_RESULTSET:
1638  break;
1639 
1640  case DB_TYPE_ELO:
1641  /* obsolete. */
1642  assert (false);
1643  break;
1644  }
1645 
1646  return retval;
1647 }
1648 
1649 /*
1650  * pt_data_type_to_db_domain_name() - returns character string of dt's datatype
1651  * return: character string denoting datatype dt
1652  * dt(in): a PT_DATA_TYPE node and nothing else.
1653  */
1654 const char *
1656 {
1657  assert (dt != NULL);
1658 
1659  if (dt->node_type != PT_DATA_TYPE)
1660  {
1661  return "unknown data_type";
1662  }
1663 
1664  if (dt->type_enum == PT_TYPE_OBJECT)
1665  {
1667  {
1668  return dt->info.data_type.entity->info.name.original;
1669  }
1670  return "object";
1671  }
1672  else
1673  {
1675  }
1676 }
1677 
1678 /*
1679  * pt_get_enumeration_from_data_type() - construct a enumeration from data type.
1680  * return: NO_ERROR or error code.
1681  * parser(in):
1682  * dt(in): enumeration data type.
1683  * enumeration(in/out): address of a DB_ENUMERATION structure to fill.
1684  */
1685 static int
1687 {
1688  int err = NO_ERROR;
1689  PT_NODE *node = NULL;
1690  DB_ENUM_ELEMENT *db_enum = NULL, *enum_elements = NULL;
1691  char *str_val = NULL;
1692  int str_len = 0, enum_elements_cnt = 0, idx;
1693 
1694  if (dt == NULL || dt->type_enum != PT_TYPE_ENUMERATION || enumeration == NULL)
1695  {
1696  err = ER_FAILED;
1697  goto error;
1698  }
1699 
1700  node = dt->info.data_type.enumeration;
1701  while (node != NULL)
1702  {
1703  enum_elements_cnt++;
1704  node = node->next;
1705  }
1706 
1707  if (enum_elements_cnt == 0)
1708  {
1709  enumeration->count = 0;
1710  enumeration->elements = NULL;
1711  return NO_ERROR;
1712  }
1713 
1714  enum_elements = (DB_ENUM_ELEMENT *) malloc (enum_elements_cnt * sizeof (DB_ENUM_ELEMENT));
1715  if (enum_elements == NULL)
1716  {
1718  enum_elements_cnt * sizeof (DB_ENUM_ELEMENT));
1720  goto error;
1721  }
1722 
1723  idx = 0;
1724  node = dt->info.data_type.enumeration;
1725  while (node != NULL)
1726  {
1727  if (node->node_type != PT_VALUE)
1728  {
1729  /* node_type should always be PT_VALUE */
1730  assert (false);
1732 
1733  err = ER_GENERIC_ERROR;
1734  goto error;
1735  }
1736  db_enum = &enum_elements[idx];
1737  str_len = pt_get_varchar_length (node->info.value.data_value.str);
1738  str_val = (char *) malloc (str_len + 1);
1739  if (str_val == NULL)
1740  {
1741  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_OUT_OF_VIRTUAL_MEMORY, 1, (size_t) (str_len + 1));
1743  goto error;
1744  }
1745 
1746  memcpy (str_val, pt_get_varchar_bytes (node->info.value.data_value.str), str_len);
1747  str_val[str_len] = 0;
1748 
1749  /* enum values are indexed starting from 1 */
1750  DB_SET_ENUM_ELEM_SHORT (db_enum, (unsigned short) idx + 1);
1751  DB_SET_ENUM_ELEM_STRING (db_enum, str_val);
1752  DB_SET_ENUM_ELEM_STRING_SIZE (db_enum, str_len);
1754 
1755  idx++;
1756  node = node->next;
1757  }
1758 
1759  enumeration->count = enum_elements_cnt;
1760  enumeration->elements = enum_elements;
1761  enumeration->collation_id = dt->info.data_type.collation_id;
1762 
1763  return NO_ERROR;
1764 
1765 error:
1766  if (enum_elements != NULL)
1767  {
1768  for (--idx; idx >= 0; idx--)
1769  {
1770  free_and_init (DB_GET_ENUM_ELEM_STRING (&enum_elements[idx]));
1771  }
1772  free_and_init (enum_elements);
1773  }
1774 
1775  return err;
1776 }
1777 
1778 /*
1779  * pt_data_type_to_db_domain() - returns DB_DOMAIN * that matches dt
1780  * return: a DB_DOMAIN
1781  * parser(in):
1782  * dt(in): PT_DATA_TYPE PT_NODE
1783  * class_name(in):
1784  *
1785  * Note :
1786  * requires: dt has undergone type binding via pt_semantic_type.
1787  * effects : returns DB_DOMAIN * that matches dt
1788  * THIS DIFFERS FROM pt_node_data_type_to_db_domain() IN THAT THE
1789  * DATA TYPE NODE IS FROM A META DEFINITION OF A TYPE AND IS NOT
1790  * FROM A NON-META DATA NODE. THIS DIFFERENCE PRIMARILY IS SHOWN
1791  * BY SETS:
1792  * SET DOMAIN DEFINITION IS:
1793  * data_type node with type enum SET, MULTISET, or SEQUENCE
1794  * and this node has a list of data type nodes (off its
1795  * data_type ptr) that define the domains of the element
1796  * types.
1797  * FULLY RESOLVED NON-META DATA NODE:
1798  * the node (not a data type node) has type enum SET, MULTISET,
1799  * or SEQUENCE and this node has a list of data type nodes
1800  * (off its data_type ptr) that define the domains of the
1801  * element types.
1802  * Subtle, ain't it?
1803  */
1804 DB_DOMAIN *
1805 pt_data_type_to_db_domain (PARSER_CONTEXT * parser, PT_NODE * dt, const char *class_name)
1806 {
1807  DB_DOMAIN *retval = (DB_DOMAIN *) 0;
1808  DB_TYPE domain_type;
1809  DB_OBJECT *class_obj = (DB_OBJECT *) 0;
1810  int precision = 0, scale = 0, codeset = 0;
1811  DB_ENUMERATION enumeration;
1812  int collation_id = 0;
1814  JSON_VALIDATOR *validator = NULL;
1815 
1816  if (dt == NULL)
1817  {
1818  return NULL;
1819  }
1820 
1821  enumeration.count = 0;
1822  enumeration.elements = NULL;
1823 
1824  domain_type = pt_type_enum_to_db (dt->type_enum);
1825  switch (domain_type)
1826  {
1827  case DB_TYPE_INTEGER:
1828  case DB_TYPE_FLOAT:
1829  case DB_TYPE_DOUBLE:
1830  case DB_TYPE_BLOB:
1831  case DB_TYPE_CLOB:
1832  case DB_TYPE_TIME:
1833  case DB_TYPE_TIMESTAMP:
1834  case DB_TYPE_TIMESTAMPTZ:
1835  case DB_TYPE_TIMESTAMPLTZ:
1836  case DB_TYPE_DATETIME:
1837  case DB_TYPE_DATETIMETZ:
1838  case DB_TYPE_DATETIMELTZ:
1839  case DB_TYPE_DATE:
1840  case DB_TYPE_MONETARY:
1841  case DB_TYPE_SUB:
1842  case DB_TYPE_POINTER:
1843  case DB_TYPE_ERROR:
1844  case DB_TYPE_SHORT:
1845  case DB_TYPE_VOBJ:
1846  case DB_TYPE_OID:
1847  case DB_TYPE_BIGINT:
1848  return pt_type_enum_to_db_domain (dt->type_enum);
1849 
1850  case DB_TYPE_JSON:
1851  if (dt->info.data_type.json_schema)
1852  {
1853  int error_code;
1854 
1855  error_code = db_json_load_validator ((const char *) dt->info.data_type.json_schema->bytes, validator);
1856  if (error_code != NO_ERROR)
1857  {
1858  ASSERT_ERROR ();
1859  return NULL;
1860  }
1861  break;
1862  }
1863  else
1864  {
1865  return pt_type_enum_to_db_domain (dt->type_enum);
1866  }
1867 
1868  case DB_TYPE_OBJECT:
1869  /* first check if its a VOBJ */
1870  if (dt->info.data_type.virt_object)
1871  {
1872  return tp_domain_construct (DB_TYPE_VOBJ, class_obj, precision, scale, NULL);
1873  }
1874 
1876  {
1877  const char *name;
1878 
1879  name = dt->info.data_type.entity->info.name.original;
1880  assert (name != NULL);
1881 
1882  if (class_name != NULL && intl_identifier_casecmp (name, class_name) == 0)
1883  {
1884  /* If the attribute domain is the name of the class being created, indicate with a -1. */
1885  class_obj = (DB_OBJECT *) TP_DOMAIN_SELF_REF;
1886  }
1887  else
1888  {
1889  class_obj = db_find_class (name);
1890  if (class_obj == NULL)
1891  {
1893  return NULL;
1894  }
1895  }
1896  assert (class_obj != NULL);
1897  }
1898  break;
1899 
1900  case DB_TYPE_VARCHAR:
1901  case DB_TYPE_CHAR:
1902  case DB_TYPE_NCHAR:
1903  case DB_TYPE_VARNCHAR:
1904  precision = dt->info.data_type.precision;
1905  codeset = dt->info.data_type.units;
1906  collation_id = dt->info.data_type.collation_id;
1907  assert (collation_id >= 0);
1908  collation_flag = dt->info.data_type.collation_flag;
1909  break;
1910 
1911  case DB_TYPE_BIT:
1912  case DB_TYPE_VARBIT:
1913  precision = dt->info.data_type.precision;
1914  codeset = dt->info.data_type.units;
1915  break;
1916 
1917  case DB_TYPE_NUMERIC:
1918  precision = dt->info.data_type.precision;
1919  scale = dt->info.data_type.dec_precision;
1920  break;
1921 
1922  case DB_TYPE_SET:
1923  case DB_TYPE_MULTISET:
1924  case DB_TYPE_SEQUENCE:
1925  case DB_TYPE_MIDXKEY:
1926  return pt_node_to_db_domain (parser, dt, class_name);
1927 
1928  case DB_TYPE_ENUMERATION:
1929  if (pt_get_enumeration_from_data_type (parser, dt, &enumeration) != NO_ERROR)
1930  {
1931  return NULL;
1932  }
1933  codeset = dt->info.data_type.units;
1934  collation_id = dt->info.data_type.collation_id;
1935  assert (collation_id >= 0);
1936  collation_flag = dt->info.data_type.collation_flag;
1937  break;
1938 
1939  case DB_TYPE_NULL:
1940  case DB_TYPE_DB_VALUE:
1941  case DB_TYPE_VARIABLE:
1942  case DB_TYPE_TABLE:
1943  case DB_TYPE_RESULTSET:
1944  break;
1945 
1946  case DB_TYPE_ELO:
1947  /* obsolete */
1948  assert (false);
1949  break;
1950  }
1951 
1952  retval = tp_domain_new (domain_type);
1953  if (retval)
1954  {
1955  if (class_obj == (DB_OBJECT *) TP_DOMAIN_SELF_REF)
1956  {
1957  retval->class_mop = NULL;
1958  retval->self_ref = 1;
1959  }
1960  else
1961  {
1962  retval->class_mop = class_obj;
1963  retval->self_ref = 0;
1964  /* For compatibility on the server side, class objects must have the oid in the domain match the oid in the
1965  * class object. */
1966  if (class_obj)
1967  {
1968  retval->class_oid = class_obj->oid_info.oid;
1969  }
1970  }
1971  if (collation_flag == TP_DOMAIN_COLL_ENFORCE)
1972  {
1973  /* need to create a domain which enforces only the collation precision is set to default to keep list of
1974  * domains to minimum */
1975  precision = DB_DEFAULT_PRECISION;
1976  }
1977  else if (collation_flag == TP_DOMAIN_COLL_LEAVE)
1978  {
1979  /* need to create a domain which ignores the collation */
1980  codeset = LANG_SYS_CODESET;
1981  collation_id = LANG_SYS_COLLATION;
1982  }
1983  retval->precision = precision;
1984  retval->scale = scale;
1985  retval->codeset = codeset;
1986  retval->collation_id = collation_id;
1987  retval->collation_flag = collation_flag;
1988  retval->enumeration.collation_id = collation_id;
1989  DOM_SET_ENUM_ELEMENTS (retval, enumeration.elements);
1990  DOM_SET_ENUM_ELEMS_COUNT (retval, enumeration.count);
1991  retval->json_validator = validator;
1992  }
1993  else
1994  {
1995  tp_domain_clear_enumeration (&enumeration);
1996  }
1997 
1998  return retval;
1999 }
2000 
2001 /*
2002  * pt_node_data_type_to_db_domain() - creates a domain from a data type node
2003  * and a type enum
2004  * return: a DB_DOMAIN
2005  * parser(in):
2006  * dt(in): PT_DATA_TYPE PT_NODE
2007  * type(in):
2008  *
2009  * Note :
2010  * THIS DIFFERS FROM pt_data_type_to_db_domain() IN THAT THE
2011  * DATA TYPE NODE IS FROM A PT_NODE THAT HAS BEEN FULLY RESOLVED
2012  * AND IS NOT THE META DEFINITION OF A TYPE. THIS DIFFERENCE
2013  * PRIMARILY IS SHOWN BY SETS:
2014  * SET DOMAIN DEFINITION IS:
2015  * data_type node with type enum SET, MULTISET, or SEQUENCE
2016  * and this node has a list of data type nodes (off its
2017  * data_type ptr) that define the domains of the element
2018  * types.
2019  * FULLY RESOLVED NON-META DATA NODE:
2020  * the node (not a data type node) has type enum SET, MULTISET,
2021  * or SEQUENCE and this node has a list of data type nodes
2022  * (off its data_type ptr) that define the domains of the
2023  * element types.
2024  * Subtle, ain't it?
2025  */
2026 /* TODO: PT_TYPE_ENUM should be changed to
2027  * PT_TYPE_NUM by adjusting the order of including header files */
2028 DB_DOMAIN *
2030 {
2031  DB_TYPE domain_type;
2032  DB_OBJECT *class_obj = (DB_OBJECT *) 0;
2033  int precision = 0, scale = 0, codeset = 0, collation_id = 0;
2034  DB_DOMAIN *retval = (DB_DOMAIN *) 0;
2035  DB_DOMAIN *domain = (DB_DOMAIN *) 0;
2036  DB_DOMAIN *setdomain = (DB_DOMAIN *) 0;
2037  DB_ENUMERATION enumeration;
2038  int error = NO_ERROR;
2039  TP_DOMAIN_COLL_ACTION collation_flag;
2040  char *raw_schema = NULL;
2041  JSON_VALIDATOR *validator = NULL;
2042 
2043  if (dt == NULL)
2044  {
2045  return (DB_DOMAIN *) NULL;
2046  }
2047 
2048  enumeration.count = 0;
2049  enumeration.elements = NULL;
2050  collation_flag = TP_DOMAIN_COLL_NORMAL;
2051 
2052  domain_type = pt_type_enum_to_db ((PT_TYPE_ENUM) type);
2053  switch (domain_type)
2054  {
2055  case DB_TYPE_INTEGER:
2056  case DB_TYPE_FLOAT:
2057  case DB_TYPE_DOUBLE:
2058  case DB_TYPE_BLOB:
2059  case DB_TYPE_CLOB:
2060  case DB_TYPE_TIME:
2061  case DB_TYPE_TIMESTAMP:
2062  case DB_TYPE_TIMESTAMPTZ:
2063  case DB_TYPE_TIMESTAMPLTZ:
2064  case DB_TYPE_DATETIME:
2065  case DB_TYPE_DATETIMETZ:
2066  case DB_TYPE_DATETIMELTZ:
2067  case DB_TYPE_DATE:
2068  case DB_TYPE_MONETARY:
2069  case DB_TYPE_SUB:
2070  case DB_TYPE_POINTER:
2071  case DB_TYPE_ERROR:
2072  case DB_TYPE_SHORT:
2073  case DB_TYPE_VOBJ:
2074  case DB_TYPE_OID:
2075  case DB_TYPE_MIDXKEY:
2076  case DB_TYPE_BIGINT:
2077  return pt_type_enum_to_db_domain (type);
2078 
2079  case DB_TYPE_JSON:
2080  if (dt->info.data_type.json_schema)
2081  {
2082  int error_code;
2083 
2084  raw_schema = (char *) malloc (dt->info.data_type.json_schema->length + 1);
2085  if (raw_schema == NULL)
2086  {
2088  return NULL;
2089  }
2090 
2091  strcpy (raw_schema, (const char *) dt->info.data_type.json_schema->bytes);
2092  error_code = db_json_load_validator (raw_schema, validator);
2093  free (raw_schema);
2094 
2095  if (error_code != NO_ERROR)
2096  {
2097  ASSERT_ERROR ();
2098  return NULL;
2099  }
2100  break;
2101  }
2102  else
2103  {
2104  return pt_type_enum_to_db_domain (dt->type_enum);
2105  }
2106 
2107  case DB_TYPE_OBJECT:
2108  /* first check if its a VOBJ */
2109  if (dt->info.data_type.virt_object)
2110  {
2111  return tp_domain_construct (DB_TYPE_VOBJ, class_obj, precision, scale, setdomain);
2112  }
2113 
2115  {
2116  class_obj = (DB_OBJECT *) db_find_class (dt->info.data_type.entity->info.name.original);
2117  if (!class_obj)
2118  {
2121  return (DB_DOMAIN *) 0;
2122  }
2123  }
2124  break;
2125 
2126  case DB_TYPE_VARCHAR:
2127  case DB_TYPE_CHAR:
2128  case DB_TYPE_NCHAR:
2129  case DB_TYPE_VARNCHAR:
2130  case DB_TYPE_BIT:
2131  case DB_TYPE_VARBIT:
2132  precision = dt->info.data_type.precision;
2133  codeset = dt->info.data_type.units;
2134  collation_id = dt->info.data_type.collation_id;
2135  collation_flag = dt->info.data_type.collation_flag;
2136  break;
2137 
2138  case DB_TYPE_NUMERIC:
2139  precision = dt->info.data_type.precision;
2140  scale = dt->info.data_type.dec_precision;
2141  break;
2142 
2143  case DB_TYPE_SET:
2144  case DB_TYPE_MULTISET:
2145  case DB_TYPE_SEQUENCE:
2146  while (dt && (error == NO_ERROR))
2147  {
2148  domain = pt_data_type_to_db_domain (parser, dt, NULL);
2149  if (domain)
2150  {
2151  error = tp_domain_add (&setdomain, domain);
2152  }
2153  dt = dt->next;
2154  }
2155  if (error == NO_ERROR)
2156  {
2157  retval = tp_domain_construct (domain_type, (DB_OBJECT *) 0, 0, 0, setdomain);
2158  }
2159  return retval;
2160 
2161  case DB_TYPE_ENUMERATION:
2162  if (pt_get_enumeration_from_data_type (parser, dt, &enumeration) != NO_ERROR)
2163  {
2164  return NULL;
2165  }
2166  codeset = dt->info.data_type.units;
2167  collation_id = dt->info.data_type.collation_id;
2168  break;
2169 
2170  case DB_TYPE_NULL:
2171  case DB_TYPE_DB_VALUE:
2172  case DB_TYPE_VARIABLE:
2173  case DB_TYPE_TABLE:
2174  case DB_TYPE_RESULTSET:
2175  break;
2176 
2177  case DB_TYPE_ELO:
2178  /* obsolete */
2179  assert (false);
2180  break;
2181  }
2182 
2183  retval = tp_domain_new (domain_type);
2184  if (retval)
2185  {
2186  retval->class_mop = class_obj;
2187  retval->self_ref = 0;
2188  if (collation_flag == TP_DOMAIN_COLL_ENFORCE)
2189  {
2190  /* need to create a domain which enforces only the collation precision is set to default to keep list of
2191  * domains to minimum */
2192  precision = DB_DEFAULT_PRECISION;
2193  }
2194  else if (collation_flag == TP_DOMAIN_COLL_LEAVE)
2195  {
2196  /* need to create a domain which ignores the collation */
2197  codeset = LANG_SYS_CODESET;
2198  collation_id = LANG_SYS_COLLATION;
2199  }
2200  retval->precision = precision;
2201  retval->scale = scale;
2202  retval->codeset = codeset;
2203  retval->collation_id = collation_id;
2204  retval->collation_flag = collation_flag;
2205  retval->enumeration.collation_id = collation_id;
2206  retval->json_validator = validator;
2207  DOM_SET_ENUM_ELEMENTS (retval, enumeration.elements);
2208  DOM_SET_ENUM_ELEMS_COUNT (retval, enumeration.count);
2209  }
2210  else
2211  {
2212  tp_domain_clear_enumeration (&enumeration);
2213  }
2214 
2215  return retval;
2216 }
2217 
2218 /*
2219  * pt_node_to_db_domain_name() -
2220  * return: character string denoting domain name
2221  * node(in): any PT_NODE
2222  */
2223 const char *
2225 {
2226  assert (node != NULL);
2227 
2228  if (node->type_enum == PT_TYPE_OBJECT && node->data_type)
2229  {
2231  }
2232 
2234 }
2235 
2236 /*
2237  * pt_node_to_db_domain() - returns DB_DOMAIN * that matches node
2238  * return: a DB_DOMAIN
2239  * parser(in):
2240  * node(in): any PT_NODE
2241  * class_name(in):
2242  */
2243 DB_DOMAIN *
2244 pt_node_to_db_domain (PARSER_CONTEXT * parser, PT_NODE * node, const char *class_name)
2245 {
2246  int error = NO_ERROR, natts = 0;
2247  DB_DOMAIN *retval = (DB_DOMAIN *) 0;
2248  DB_DOMAIN *domain = (DB_DOMAIN *) 0;
2249  DB_DOMAIN *setdomain = (DB_DOMAIN *) 0;
2250  DB_TYPE domain_type;
2251  PT_NODE *dt;
2252 
2253  CAST_POINTER_TO_NODE (node);
2254 
2255  if (node->data_type)
2256  {
2257  domain_type = pt_type_enum_to_db (node->type_enum);
2258  switch (domain_type)
2259  {
2260  case DB_TYPE_SET:
2261  case DB_TYPE_MULTISET:
2262  case DB_TYPE_SEQUENCE:
2263  case DB_TYPE_MIDXKEY:
2264  /* Recursively build the setdomain */
2265  dt = node->data_type;
2266  while (dt && (error == NO_ERROR))
2267  {
2268  domain = pt_data_type_to_db_domain (parser, dt, class_name);
2269  if (domain)
2270  {
2271  if (domain_type == DB_TYPE_MIDXKEY)
2272  {
2273  error = tp_domain_attach (&setdomain, domain);
2274  natts++;
2275  }
2276  else
2277  {
2278  error = tp_domain_add (&setdomain, domain);
2279  }
2280  }
2281  else
2282  {
2283  /* given element domain was not found, raise error */
2284  assert (er_errid () != NO_ERROR);
2285  error = er_errid ();
2286  }
2287  dt = dt->next;
2288  }
2289  if (error == NO_ERROR)
2290  {
2291  retval = tp_domain_construct (domain_type, (DB_OBJECT *) 0, natts, 0, setdomain);
2292  }
2293  break;
2294 
2295  default:
2296  retval = pt_data_type_to_db_domain (parser, node->data_type, class_name);
2297  break;
2298  }
2299  }
2300  else
2301  {
2302  retval = pt_type_enum_to_db_domain (node->type_enum);
2303  }
2304 
2305  return retval;
2306 }
2307 
2308 /*
2309  * pt_type_enum_to_db() - return DB_TYPE equivalent of PT_TYPE_ENUM t
2310  * return: DB_TYPE equivalent of t
2311  * t(in): a PT_TYPE_ENUM value
2312  */
2313 DB_TYPE
2315 {
2316  DB_TYPE db_type = DB_TYPE_NULL;
2317 
2318  switch (t)
2319  {
2320  case PT_TYPE_NONE:
2321  db_type = DB_TYPE_NULL;
2322  break;
2323 
2324  case PT_TYPE_LOGICAL:
2325  case PT_TYPE_INTEGER:
2326  db_type = DB_TYPE_INTEGER;
2327  break;
2328 
2329  case PT_TYPE_BIGINT:
2330  db_type = DB_TYPE_BIGINT;
2331  break;
2332 
2333  case PT_TYPE_SMALLINT:
2334  db_type = DB_TYPE_SHORT;
2335  break;
2336  case PT_TYPE_FLOAT:
2337  db_type = DB_TYPE_FLOAT;
2338  break;
2339  case PT_TYPE_DOUBLE:
2340  db_type = DB_TYPE_DOUBLE;
2341  break;
2342 
2343  case PT_TYPE_DATE:
2344  db_type = DB_TYPE_DATE;
2345  break;
2346  case PT_TYPE_TIME:
2347  db_type = DB_TYPE_TIME;
2348  break;
2349  case PT_TYPE_TIMESTAMP:
2350  db_type = DB_TYPE_TIMESTAMP;
2351  break;
2352  case PT_TYPE_TIMESTAMPTZ:
2353  db_type = DB_TYPE_TIMESTAMPTZ;
2354  break;
2355  case PT_TYPE_TIMESTAMPLTZ:
2356  db_type = DB_TYPE_TIMESTAMPLTZ;
2357  break;
2358 
2359  case PT_TYPE_DATETIME:
2360  db_type = DB_TYPE_DATETIME;
2361  break;
2362  case PT_TYPE_DATETIMETZ:
2363  db_type = DB_TYPE_DATETIMETZ;
2364  break;
2365  case PT_TYPE_DATETIMELTZ:
2366  db_type = DB_TYPE_DATETIMELTZ;
2367  break;
2368  case PT_TYPE_MONETARY:
2369  db_type = DB_TYPE_MONETARY;
2370  break;
2371 
2372  case PT_TYPE_CHAR:
2373  db_type = DB_TYPE_CHAR;
2374  break;
2375  case PT_TYPE_VARCHAR:
2376  db_type = DB_TYPE_VARCHAR;
2377  break;
2378 
2379  case PT_TYPE_JSON:
2380  db_type = DB_TYPE_JSON;
2381  break;
2382 
2383  case PT_TYPE_OBJECT:
2384  db_type = DB_TYPE_OBJECT;
2385  break;
2386 
2387  case PT_TYPE_SET:
2388  db_type = DB_TYPE_SET;
2389  break;
2390 
2391  case PT_TYPE_MULTISET:
2392  db_type = DB_TYPE_MULTISET;
2393  break;
2394 
2395  case PT_TYPE_SEQUENCE:
2396  db_type = DB_TYPE_SEQUENCE;
2397  break;
2398 
2399  case PT_TYPE_MIDXKEY:
2400  db_type = DB_TYPE_MIDXKEY;
2401  break;
2402 
2403  case PT_TYPE_NUMERIC:
2404  db_type = DB_TYPE_NUMERIC;
2405  break;
2406  case PT_TYPE_NCHAR:
2407  db_type = DB_TYPE_NCHAR;
2408  break;
2409  case PT_TYPE_VARNCHAR:
2410  db_type = DB_TYPE_VARNCHAR;
2411  break;
2412  case PT_TYPE_BIT:
2413  db_type = DB_TYPE_BIT;
2414  break;
2415  case PT_TYPE_VARBIT:
2416  db_type = DB_TYPE_VARBIT;
2417  break;
2418 
2419  case PT_TYPE_RESULTSET:
2420  db_type = DB_TYPE_RESULTSET;
2421  break;
2422 
2423  case PT_TYPE_BLOB:
2424  db_type = DB_TYPE_BLOB;
2425  break;
2426 
2427  case PT_TYPE_CLOB:
2428  db_type = DB_TYPE_CLOB;
2429  break;
2430 
2431  case PT_TYPE_MAYBE:
2432  db_type = DB_TYPE_VARIABLE;
2433  break;
2434 
2435  case PT_TYPE_ENUMERATION:
2436  db_type = DB_TYPE_ENUMERATION;
2437  break;
2438 
2439  default:
2440  db_type = DB_TYPE_NULL;
2441  break;
2442  }
2443 
2444  return db_type;
2445 }
2446 
2447 /*
2448  * pt_node_to_db_type() - return DB_TYPE equivalent of PT_TYPE_ENUM of node
2449  * return: DB_TYPE equivalent of type_enum of node
2450  * node(in): a PT_NODE
2451  */
2452 DB_TYPE
2454 {
2455  DB_TYPE db_type;
2456 
2457  if (!node)
2458  {
2459  return DB_TYPE_NULL;
2460  }
2461 
2462  CAST_POINTER_TO_NODE (node);
2463 
2464  db_type = pt_type_enum_to_db (node->type_enum);
2465 
2466  if (db_type == DB_TYPE_OBJECT && node->data_type && (node->data_type->info.data_type.virt_object))
2467  {
2468  db_type = DB_TYPE_VOBJ;
2469  }
2470 
2471  return db_type;
2472 }
2473 
2474 /*
2475  * pt_sort_in_desc_order() - first builds a linked of integers from the value
2476  * list. then bubble sorts them in descending order.
2477  * finally removes all duplicates
2478  * return: returns a the list of nodes sorted in descending order and with
2479  * all the duplicates removed.
2480  * vlist(in): a list of value nodes with integer values
2481  */
2482 
2483 PT_NODE *
2485 {
2486  PT_NODE *init_list = vlist, *c_addr, *p_addr;
2487  int t;
2488 
2489  /*
2490  * bubble sort (yuck!) the linked list of nodes
2491  * in descending order.
2492  */
2493  do
2494  {
2495  t = init_list->info.value.data_value.i;
2496  for (c_addr = init_list->next, p_addr = init_list; c_addr != NULL; c_addr = c_addr->next, p_addr = p_addr->next)
2497  {
2498  if (p_addr->info.value.data_value.i < c_addr->info.value.data_value.i)
2499  {
2500  t = p_addr->info.value.data_value.i;
2501  p_addr->info.value.data_value.i = c_addr->info.value.data_value.i;
2502  c_addr->info.value.data_value.i = t;
2503  }
2504  }
2505  }
2506  while (t != init_list->info.value.data_value.i);
2507 
2508  /* now remove all the duplicates in the list */
2509  c_addr = init_list;
2510  while (c_addr)
2511  {
2512  if (c_addr->next == NULL)
2513  {
2514  break;
2515  }
2516 
2517  if (c_addr->info.value.data_value.i == c_addr->next->info.value.data_value.i)
2518  {
2519  c_addr->next = c_addr->next->next;
2520  }
2521  else
2522  {
2523  c_addr = c_addr->next;
2524  }
2525  }
2526 
2527  return init_list;
2528 }
2529 
2530 
2531 /*
2532  * pt_auth_to_db_auth() - an element of the enum type PT_PRIV_TYPE to its
2533  corresponding element in DB_AUTH
2534  * return: returns an enum of type DB_AUTH.
2535  * auth(in): a PT_NODE of type PT_AUTH_CMD
2536  */
2537 
2538 DB_AUTH
2540 {
2541  PT_PRIV_TYPE pt_auth;
2542  DB_AUTH db_auth;
2543 
2544  pt_auth = auth->info.auth_cmd.auth_cmd;
2545 
2546  switch (pt_auth)
2547  {
2548  case PT_ALL_PRIV:
2549  db_auth = DB_AUTH_ALL;
2550  break;
2551 
2552  case PT_ALTER_PRIV:
2553  db_auth = DB_AUTH_ALTER;
2554  break;
2555 
2556  case PT_DELETE_PRIV:
2557  db_auth = DB_AUTH_DELETE;
2558  break;
2559 
2560  case PT_EXECUTE_PRIV:
2561  db_auth = DB_AUTH_EXECUTE;
2562  break;
2563 
2564  case PT_INDEX_PRIV:
2565  db_auth = DB_AUTH_INDEX;
2566  break;
2567 
2568  case PT_INSERT_PRIV:
2569  db_auth = DB_AUTH_INSERT;
2570  break;
2571 
2572  case PT_SELECT_PRIV:
2573  db_auth = DB_AUTH_SELECT;
2574  break;
2575 
2576  case PT_UPDATE_PRIV:
2577  db_auth = DB_AUTH_UPDATE;
2578  break;
2579 
2580  default:
2581  db_auth = DB_AUTH_NONE;
2582  break;
2583  }
2584 
2585  return db_auth;
2586 }
2587 
2588 /*
2589  * pt_db_to_type_enum() - Convert type_enum from DB_TYPE... to PT_...
2590  * return: Returns one of the PT_TYPE_ENUMs defined
2591  * PT_TYPE_NONE for internal or unknown types
2592  * t(in): a data type as defined in dbi.h
2593  */
2596 {
2597  PT_TYPE_ENUM pt_type = PT_TYPE_NONE;
2598 
2599  if (t > DB_TYPE_LAST)
2600  {
2601  return PT_TYPE_NONE;
2602  }
2603  if (t <= DB_TYPE_FIRST)
2604  {
2605  return PT_TYPE_NONE;
2606  }
2607 
2608  switch (t)
2609  {
2610  case DB_TYPE_INTEGER:
2611  pt_type = PT_TYPE_INTEGER;
2612  break;
2613  case DB_TYPE_BIGINT:
2614  pt_type = PT_TYPE_BIGINT;
2615  break;
2616  case DB_TYPE_NUMERIC:
2617  pt_type = PT_TYPE_NUMERIC;
2618  break;
2619  case DB_TYPE_SHORT:
2620  pt_type = PT_TYPE_SMALLINT;
2621  break;
2622  case DB_TYPE_FLOAT:
2623  pt_type = PT_TYPE_FLOAT;
2624  break;
2625  case DB_TYPE_DOUBLE:
2626  pt_type = PT_TYPE_DOUBLE;
2627  break;
2628 
2629  case DB_TYPE_DATE:
2630  pt_type = PT_TYPE_DATE;
2631  break;
2632  case DB_TYPE_TIME:
2633  pt_type = PT_TYPE_TIME;
2634  break;
2635  case DB_TYPE_TIMESTAMP:
2636  pt_type = PT_TYPE_TIMESTAMP;
2637  break;
2638  case DB_TYPE_TIMESTAMPTZ:
2639  pt_type = PT_TYPE_TIMESTAMPTZ;
2640  break;
2641  case DB_TYPE_TIMESTAMPLTZ:
2642  pt_type = PT_TYPE_TIMESTAMPLTZ;
2643  break;
2644  case DB_TYPE_DATETIME:
2645  pt_type = PT_TYPE_DATETIME;
2646  break;
2647  case DB_TYPE_DATETIMETZ:
2648  pt_type = PT_TYPE_DATETIMETZ;
2649  break;
2650  case DB_TYPE_DATETIMELTZ:
2651  pt_type = PT_TYPE_DATETIMELTZ;
2652  break;
2653 
2654  case DB_TYPE_MONETARY:
2655  pt_type = PT_TYPE_MONETARY;
2656  break;
2657 
2658  case DB_TYPE_OBJECT:
2659  pt_type = PT_TYPE_OBJECT;
2660  break;
2661 
2662  case DB_TYPE_SET:
2663  pt_type = PT_TYPE_SET;
2664  break;
2665  case DB_TYPE_MULTISET:
2666  pt_type = PT_TYPE_MULTISET;
2667  break;
2668  case DB_TYPE_SEQUENCE:
2669  pt_type = PT_TYPE_SEQUENCE;
2670  break;
2671 
2672  case DB_TYPE_CHAR:
2673  pt_type = PT_TYPE_CHAR;
2674  break;
2675  case DB_TYPE_STRING:
2676  pt_type = PT_TYPE_VARCHAR;
2677  break;
2678  case DB_TYPE_NCHAR:
2679  pt_type = PT_TYPE_NCHAR;
2680  break;
2681  case DB_TYPE_VARNCHAR:
2682  pt_type = PT_TYPE_VARNCHAR;
2683  break;
2684  case DB_TYPE_BIT:
2685  pt_type = PT_TYPE_BIT;
2686  break;
2687  case DB_TYPE_VARBIT:
2688  pt_type = PT_TYPE_VARBIT;
2689  break;
2690  case DB_TYPE_MIDXKEY:
2691  pt_type = PT_TYPE_MIDXKEY;
2692  break;
2693  case DB_TYPE_RESULTSET:
2694  pt_type = PT_TYPE_RESULTSET;
2695  break;
2696  case DB_TYPE_BLOB:
2697  pt_type = PT_TYPE_BLOB;
2698  break;
2699  case DB_TYPE_CLOB:
2700  pt_type = PT_TYPE_CLOB;
2701  break;
2702  case DB_TYPE_ENUMERATION:
2703  pt_type = PT_TYPE_ENUMERATION;
2704  break;
2705  case DB_TYPE_VARIABLE:
2706  pt_type = PT_TYPE_MAYBE;
2707  break;
2708  case DB_TYPE_JSON:
2709  pt_type = PT_TYPE_JSON;
2710  break;
2711 
2712  /* these guys should not get encountered */
2713  case DB_TYPE_OID:
2714  case DB_TYPE_VOBJ:
2715  case DB_TYPE_UNKNOWN:
2716  case DB_TYPE_POINTER:
2717  case DB_TYPE_SUB:
2718  case DB_TYPE_ERROR:
2719  case DB_TYPE_DB_VALUE:
2720  case DB_TYPE_TABLE:
2721  pt_type = PT_TYPE_NONE;
2722  break;
2723  default:
2724  /* ALL TYPES MUST GET HANDLED HERE! */
2725  assert (false);
2726  }
2727  return pt_type;
2728 }
2729 
2730 /*
2731  * pt_node_to_cmd_type() - Convert node to CUBRID_STMT_TYPES
2732  * return: one of the CUBRID_STMT_TYPES defined in dbi.h.
2733  * node(in):
2734  */
2737 {
2738  if (node == NULL)
2739  {
2740  return CUBRID_STMT_NONE;
2741  }
2742 
2743  switch (node->node_type)
2744  {
2745  case PT_GET_XACTION:
2747  {
2748  return CUBRID_STMT_GET_ISO_LVL;
2749  }
2750  else if (node->info.get_xaction.option == PT_LOCK_TIMEOUT)
2751  {
2752  return CUBRID_STMT_GET_TIMEOUT;
2753  }
2754  assert (0); // should not reach here
2755  return CUBRID_STMT_NONE;
2756 
2757  case PT_DIFFERENCE:
2758  case PT_INTERSECTION:
2759  case PT_UNION:
2760  case PT_SELECT:
2761  return CUBRID_STMT_SELECT;
2762  case PT_KILL_STMT:
2763  return CUBRID_STMT_KILL;
2764  default:
2765  /* todo: is this acceptable?? I'll add safe-guard and let's see what happens... */
2766  assert ((int) node->node_type <= (int) PT_LAST_NODE_NUMBER);
2767  return (CUBRID_STMT_TYPE) node->node_type;
2768  }
2769 
2770  return CUBRID_STMT_NONE;
2771 }
2772 
2773 
2774 /*
2775  * pt_bind_helper() - annotate the PT_ type info of a node from a DB_VALUE
2776  * return: PT_NODE
2777  * parser(in): the parser context
2778  * node(in): an input data type node
2779  * val(in): an input dbval
2780  * data_type_added(out): indicates whether an auxiliary node was used
2781  *
2782  * Note :
2783  * looks at the actual type of the DB_VALUE and constructs an accurate
2784  * PT_ data type in "node". Will traverse all the elements of a set
2785  * in order to get an accurate data type, which means that we can find
2786  * out exact info about sets of uncertain pedigree.
2787  */
2788 
2789 static PT_NODE *
2790 pt_bind_helper (PARSER_CONTEXT * parser, PT_NODE * node, DB_VALUE * val, int *data_type_added)
2791 {
2792  PT_NODE *dt;
2793  DB_TYPE val_type;
2794  PT_TYPE_ENUM pt_type;
2795  char *json_body = NULL;
2796 
2797  assert (node != NULL && val != NULL);
2798 
2799  *data_type_added = 0;
2800  dt = NULL;
2801 
2802  val_type = DB_VALUE_DOMAIN_TYPE (val);
2803  if (DB_IS_NULL (val) && val_type == DB_TYPE_NULL)
2804  {
2805  node->type_enum = PT_TYPE_NULL;
2806  return node;
2807  }
2808 
2809  pt_type = pt_db_to_type_enum (val_type);
2810  if (pt_type == PT_TYPE_NONE)
2811  {
2812  PT_INTERNAL_ERROR (parser, "type assignment");
2813  return NULL;
2814  }
2815 
2816  node->type_enum = pt_type;
2817 
2818  switch (val_type)
2819  {
2820  case DB_TYPE_INTEGER:
2821  if (node->node_type == PT_DATA_TYPE)
2822  {
2823  node->info.data_type.precision = 10;
2824  node->info.data_type.dec_precision = 0;
2825  node->info.data_type.units = 0;
2826  }
2827  break;
2828 
2829  case DB_TYPE_BIGINT:
2830  if (node->node_type == PT_DATA_TYPE)
2831  {
2832  node->info.data_type.precision = 19;
2833  node->info.data_type.dec_precision = 0;
2834  node->info.data_type.units = 0;
2835  }
2836  break;
2837 
2838  case DB_TYPE_SHORT:
2839  if (node->node_type == PT_DATA_TYPE)
2840  {
2841  node->info.data_type.precision = 5;
2842  node->info.data_type.dec_precision = 0;
2843  node->info.data_type.units = 0;
2844  }
2845 
2846  case DB_TYPE_NULL:
2847  case DB_TYPE_FLOAT:
2848  case DB_TYPE_DOUBLE:
2849  case DB_TYPE_TIME:
2850  case DB_TYPE_TIMESTAMP:
2851  case DB_TYPE_TIMESTAMPTZ:
2852  case DB_TYPE_TIMESTAMPLTZ:
2853  case DB_TYPE_DATE:
2854  case DB_TYPE_DATETIME:
2855  case DB_TYPE_DATETIMETZ:
2856  case DB_TYPE_DATETIMELTZ:
2857  case DB_TYPE_BLOB:
2858  case DB_TYPE_CLOB:
2859  /*
2860  * Nothing more to do for these guys; their type is completely
2861  * described by the type_enum. Why don't we care about precision
2862  * and dec_precision for these, if we care about DB_TYPE_INT?
2863  */
2864  break;
2865 
2866  case DB_TYPE_VARIABLE:
2867  case DB_TYPE_SUB:
2868  case DB_TYPE_POINTER:
2869  case DB_TYPE_ERROR:
2870  case DB_TYPE_OID:
2871  case DB_TYPE_DB_VALUE:
2872  PT_INTERNAL_ERROR (parser, "type assignment");
2873  node = NULL;
2874  break;
2875 
2876  case DB_TYPE_SET:
2877  case DB_TYPE_MULTISET:
2878  case DB_TYPE_SEQUENCE:
2879  dt = pt_bind_set_type (parser, node, val, data_type_added);
2880  break;
2881 
2882  /*
2883  * All of the remaining cases need to tack a new DATA_TYPE node
2884  * onto the incoming node. Most of the cases allocate it
2885  * themselves, but not all.
2886  */
2887 
2888  case DB_TYPE_MONETARY:
2889  dt = parser_new_node (parser, PT_DATA_TYPE);
2890  if (dt)
2891  {
2892  dt->type_enum = node->type_enum;
2893  dt->info.data_type.precision = 0;
2894  dt->info.data_type.dec_precision = 0;
2896  }
2897  break;
2898 
2899  case DB_TYPE_NUMERIC:
2900  dt = parser_new_node (parser, PT_DATA_TYPE);
2901  if (dt)
2902  {
2903  dt->type_enum = node->type_enum;
2906  }
2907  break;
2908 
2909  case DB_TYPE_VARNCHAR:
2910  case DB_TYPE_NCHAR:
2911  case DB_TYPE_VARBIT:
2912  case DB_TYPE_BIT:
2913  case DB_TYPE_VARCHAR:
2914  case DB_TYPE_CHAR:
2915  dt = parser_new_node (parser, PT_DATA_TYPE);
2916  if (dt)
2917  {
2918  dt->type_enum = node->type_enum;
2920  dt->info.data_type.units = (int) db_get_string_codeset (val);
2922  assert (!TP_IS_CHAR_TYPE (val_type) || dt->info.data_type.collation_id >= 0);
2923  }
2924  break;
2925 
2926  case DB_TYPE_ENUMERATION:
2927  dt = NULL;
2928  break;
2929 
2930  case DB_TYPE_OBJECT:
2931  dt = pt_get_object_data_type (parser, val);
2932  break;
2933 
2934  case DB_TYPE_JSON:
2935  dt = parser_new_node (parser, PT_DATA_TYPE);
2936  if (dt)
2937  {
2939  if (db_json_validate_json (json_body) != NO_ERROR)
2940  {
2941  assert (false);
2942  parser_free_node (parser, dt);
2943  /* TODO: set a real error. */
2944  PT_INTERNAL_ERROR (parser, "json validation failed");
2945  db_private_free (NULL, json_body);
2946  return NULL;
2947  }
2948  /* valid schema */
2949 
2950  dt->type_enum = node->type_enum;
2951  db_private_free (NULL, json_body);
2952 
2953  /* save raw schema */
2954  if (val->data.json.schema_raw != NULL)
2955  {
2956  const char *schema_raw = val->data.json.schema_raw;
2957  dt->info.data_type.json_schema = pt_append_bytes (parser, NULL, schema_raw, strlen (schema_raw));
2958  }
2959  }
2960  break;
2961 
2962  default:
2963  PT_INTERNAL_ERROR (parser, "type assignment");
2964  node = NULL;
2965  break;
2966  }
2967 
2968  if (dt)
2969  {
2970  if (node)
2971  {
2972  node->data_type = dt;
2973  *data_type_added = 1;
2974  }
2975  else
2976  {
2977  parser_free_node (parser, dt);
2978  }
2979  }
2980 
2981  return node;
2982 }
2983 
2984 
2985 /*
2986  * pt_bind_set_type() - examine set elements and build up domain of their types
2987  * return: PT_NODE
2988  * parser(in): the parser context
2989  * node(in): an input data type node
2990  * val(in): an input DB_VALUE set
2991  * data_type_added(out): indicator of whether we built an auxiliary node
2992  */
2993 
2994 static PT_NODE *
2995 pt_bind_set_type (PARSER_CONTEXT * parser, PT_NODE * node, DB_VALUE * val, int *data_type_added)
2996 {
2997  SET_ITERATOR *iterator;
2998  DB_VALUE *element;
2999  PT_NODE *set_type;
3000  PT_NODE tmp;
3001  int tmp_data_type_added;
3002 
3003  assert (node != NULL && val != NULL);
3004 
3005  iterator = set_iterate (db_get_set (val));
3006  if (iterator == NULL)
3007  {
3008  goto error;
3009  }
3010  set_type = NULL;
3011 
3013  tmp.line_number = node->line_number;
3014  tmp.column_number = node->column_number;
3015 
3016  while ((element = set_iterator_value (iterator)))
3017  {
3018  if (!pt_bind_helper (parser, &tmp, element, &tmp_data_type_added))
3019  {
3020  goto error;
3021  }
3022 
3023  pt_add_type_to_set (parser, &tmp, &set_type);
3024 
3025  /*
3026  * pt_add_type_to_set will copy the data type we send it if it
3027  * needs to keep it, so it's our responsibility to clean up any
3028  * intermediate stuff that was produced by pt_bind_helper.
3029  */
3030  if (tmp_data_type_added)
3031  {
3032  parser_free_node (parser, tmp.data_type);
3033  }
3034  tmp.data_type = NULL;
3035 
3036  set_iterator_next (iterator);
3037  }
3038  set_iterator_free (iterator);
3039  iterator = NULL;
3040 
3041  *data_type_added = (set_type != NULL);
3042  return set_type;
3043 
3044 error:
3045  if (iterator)
3046  {
3047  set_iterator_free (iterator);
3048  }
3049  return NULL;
3050 }
3051 
3052 
3053 /*
3054  * pt_bind_type_from_dbval() - Build an accurate pt type for node given
3055  * the actual DB_VALUE val.
3056  * return: PT_NODE
3057  * parser(in): the parser context
3058  * node(in): an input data type node
3059  * val(in): an input DB_VALUE set
3060  *
3061  * Note :
3062  * This may allocate a PT_DATA_TYPE node for parameterized types, or a whole
3063  * slew of them for set types.
3064  */
3065 
3066 PT_NODE *
3068 {
3069  int data_type_added;
3070 
3071  return pt_bind_helper (parser, node, val, &data_type_added);
3072 }
3073 
3074 /*
3075  * pt_set_host_variables() - sets parser's host_variables & count
3076  * return: none
3077  * parser(in): the parser context
3078  * count(in): an input data type node
3079  * values(in): an input DB_VALUE set
3080  *
3081  * Note :
3082  * Its purpose is to hide the internal structure for portability and
3083  * maintainability of applications.
3084  */
3085 void
3087 {
3088  DB_VALUE *val, *hv;
3089  DB_TYPE typ;
3090  TP_DOMAIN *hv_dom;
3091  int i, is_ref = 0;
3092 
3093  if (parser == NULL || count <= 0 || values == NULL)
3094  {
3095  return;
3096  }
3097 
3098  parser->flag.set_host_var = 0;
3099 
3100  if (parser->host_var_count > count)
3101  {
3102  /* oh no, an user gave me wrong data ... generate warning! */
3104  parser->host_var_count);
3105  return;
3106  }
3107 
3108  /* cast and copy the given values to the place holder */
3109  for (val = values, hv = parser->host_variables, i = 0; i < parser->host_var_count; val++, hv++, i++)
3110  {
3111  is_ref = pt_is_reference_to_reusable_oid (val);
3112  if (is_ref < 0)
3113  {
3114  PT_ERRORc (parser, NULL, er_msg ());
3115  return;
3116  }
3117  if (is_ref > 0)
3118  {
3120  return;
3121  }
3122 
3123  pr_clear_value (hv);
3124  hv_dom = parser->host_var_expected_domains[i];
3125  if (TP_DOMAIN_TYPE (hv_dom) == DB_TYPE_UNKNOWN || hv_dom->type->id == DB_TYPE_ENUMERATION)
3126  {
3127  pr_clone_value (val, hv);
3128  }
3129  else
3130  {
3131  DB_TYPE val_type = db_value_type (val);
3132 
3133  if (tp_value_cast_preserve_domain (val, hv, hv_dom, false, true) != DOMAIN_COMPATIBLE)
3134  {
3135  typ = TP_DOMAIN_TYPE (hv_dom);
3138  return;
3139  }
3140  if (TP_IS_CHAR_TYPE (hv_dom->type->id))
3141  {
3142  if (hv_dom->type->id != val_type && (val_type == DB_TYPE_VARCHAR || val_type == DB_TYPE_VARNCHAR))
3143  {
3144  pr_clone_value (val, hv);
3145  }
3146  }
3147  }
3148  }
3149 
3150  parser->flag.set_host_var = 1; /* OK */
3151 }
3152 
3153 /*
3154  * pt_host_var_db_value() -
3155  * return:
3156  * parser(in):
3157  * hv(in):
3158  */
3159 DB_VALUE *
3161 {
3162  DB_VALUE *val = NULL;
3163  int idx;
3164 
3165  if (hv && hv->node_type == PT_HOST_VAR)
3166  {
3167  idx = hv->info.host_var.index;
3168  if (idx >= 0 && idx < parser->host_var_count && parser->flag.set_host_var)
3169  {
3170  val = &parser->host_variables[idx];
3171  }
3172  else if (idx >= parser->host_var_count && idx < parser->host_var_count + parser->auto_param_count)
3173  {
3174  val = &parser->host_variables[idx];
3175  }
3176  }
3177 
3178  return val;
3179 }
3180 
3181 /*
3182  * pt_db_value_initialize() - initialize DB_VALUE
3183  * return: DB_VALUE equivalent of value on successful conversion
3184  * NULL otherwise
3185  * parser(in): handle to context used to derive PT_VALUE type node,
3186  * may also have associated host_variable bound DB_VALUEs
3187  * value(in): the PT_VALUE type node to be converted to DB_VALUE
3188  * db_value(in): the DB_VALUE
3189  * more_type_info_needed(in): flag for need more info
3190  */
3191 /* TODO fix precision of char and bit constants and then remove the
3192  * pt_fixup_column_type function.
3193  */
3194 DB_VALUE *
3195 pt_db_value_initialize (PARSER_CONTEXT * parser, PT_NODE * value, DB_VALUE * db_value, int *more_type_info_needed)
3196 {
3197  DB_SET *set;
3198  DB_MULTISET *multiset;
3199  DB_SEQ *seq;
3200  DB_DATE date;
3201  DB_TIME time;
3202  DB_UTIME utime;
3203  DB_TIMESTAMPTZ ts_tz;
3204  DB_DATETIME datetime;
3205  DB_DATETIMETZ dt_tz;
3206  int src_length;
3207  int dst_length;
3208  int bits_converted;
3209  char *bstring;
3210  int collation_id = LANG_COERCIBLE_COLL;
3212  bool has_zone;
3213  const char *json_body = NULL;
3214 
3215  assert (value->node_type == PT_VALUE);
3216  if (PT_HAS_COLLATION (value->type_enum) && value->data_type != NULL)
3217  {
3218  collation_id = value->data_type->info.data_type.collation_id;
3219  codeset = (INTL_CODESET) value->data_type->info.data_type.units;
3220  }
3221 
3222  switch (value->type_enum)
3223  {
3224  case PT_TYPE_NA:
3225  case PT_TYPE_NULL:
3226  db_make_null (db_value);
3227  break;
3228 
3229  case PT_TYPE_SET:
3230  set = db_set_create_basic (NULL, NULL);
3231  if (set == NULL)
3232  {
3233  PT_ERROR (parser, value,
3235  return (DB_VALUE *) NULL;
3236  }
3237 
3238  db_make_set (db_value, set);
3239 
3240  if (pt_set_value_to_db (parser, &value->info.value.data_value.set, db_value, &value->data_type) == NULL)
3241  {
3242  pr_clear_value (db_value);
3243  return (DB_VALUE *) NULL;
3244  }
3245 
3246  value->info.value.db_value_is_in_workspace = true;
3247  break;
3248 
3249  case PT_TYPE_MULTISET:
3250  multiset = db_set_create_multi (NULL, NULL);
3251  if (multiset == NULL)
3252  {
3253  PT_ERROR (parser, value,
3255  return (DB_VALUE *) NULL;
3256  }
3257 
3258  db_make_multiset (db_value, multiset);
3259 
3260  if (pt_set_value_to_db (parser, &value->info.value.data_value.set, db_value, &value->data_type) == NULL)
3261  {
3262  pr_clear_value (db_value);
3263  return (DB_VALUE *) NULL;
3264  }
3265 
3266  value->info.value.db_value_is_in_workspace = true;
3267  break;
3268 
3269  case PT_TYPE_SEQUENCE:
3270  seq = db_seq_create (NULL, NULL, 0);
3271  if (seq == NULL)
3272  {
3273  PT_ERROR (parser, value,
3275  return (DB_VALUE *) NULL;
3276  }
3277 
3278  db_make_sequence (db_value, seq);
3279 
3280  if (pt_seq_value_to_db (parser, value->info.value.data_value.set, db_value, &value->data_type) == NULL)
3281  {
3282  pr_clear_value (db_value);
3283  return (DB_VALUE *) NULL;
3284  }
3285 
3286  value->info.value.db_value_is_in_workspace = true;
3287  break;
3288 
3289  case PT_TYPE_INTEGER:
3290  case PT_TYPE_LOGICAL:
3291  db_make_int (db_value, value->info.value.data_value.i);
3292  break;
3293 
3294  case PT_TYPE_BIGINT:
3295  db_make_bigint (db_value, value->info.value.data_value.bigint);
3296  break;
3297 
3298  case PT_TYPE_SMALLINT:
3299  db_make_short (db_value, (short) value->info.value.data_value.i);
3300  break;
3301 
3302  case PT_TYPE_FLOAT:
3303  db_make_float (db_value, value->info.value.data_value.f);
3304  break;
3305 
3306  case PT_TYPE_NUMERIC:
3307  if (numeric_coerce_string_to_num ((const char *) value->info.value.data_value.str->bytes,
3308  value->info.value.data_value.str->length, codeset, db_value) != NO_ERROR)
3309  {
3311  value->info.value.data_value.str->bytes);
3312  return (DB_VALUE *) NULL;
3313  }
3314  *more_type_info_needed = (value->data_type == NULL);
3315  break;
3316 
3317  case PT_TYPE_DOUBLE:
3318  db_make_double (db_value, value->info.value.data_value.d);
3319  break;
3320 
3321  case PT_TYPE_DATE:
3322  if (db_string_to_date ((const char *) value->info.value.data_value.str->bytes, &date) != NO_ERROR)
3323  {
3325  value->info.value.data_value.str->bytes);
3326  return (DB_VALUE *) NULL;
3327  }
3329  db_value_put_encoded_date (db_value, &date);
3330  break;
3331 
3332  case PT_TYPE_TIME:
3333  if (db_string_to_time ((const char *) value->info.value.data_value.str->bytes, &time) != NO_ERROR)
3334  {
3336  value->info.value.data_value.str->bytes);
3337  return (DB_VALUE *) NULL;
3338  }
3340  db_value_put_encoded_time (db_value, &time);
3341  break;
3342 
3343  case PT_TYPE_TIMESTAMP:
3344  if (db_string_to_utime ((const char *) value->info.value.data_value.str->bytes, &utime) != NO_ERROR)
3345  {
3347  value->info.value.data_value.str->bytes);
3348  return (DB_VALUE *) NULL;
3349  }
3350  db_make_timestamp (db_value, utime);
3351  break;
3352 
3353  case PT_TYPE_TIMESTAMPTZ:
3354  {
3355  bool has_zone = false;
3356 
3357  if (db_string_to_timestamptz ((const char *) value->info.value.data_value.str->bytes, &ts_tz, &has_zone) !=
3358  NO_ERROR)
3359  {
3361  value->info.value.data_value.str->bytes);
3362  return (DB_VALUE *) NULL;
3363  }
3364  db_make_timestamptz (db_value, &ts_tz);
3365  }
3366  break;
3367 
3368  case PT_TYPE_TIMESTAMPLTZ:
3369  if (db_string_to_timestampltz ((const char *) value->info.value.data_value.str->bytes, &utime) != NO_ERROR)
3370  {
3372  value->info.value.data_value.str->bytes);
3373  return (DB_VALUE *) NULL;
3374  }
3375  db_make_timestampltz (db_value, utime);
3376  break;
3377 
3378  case PT_TYPE_DATETIME:
3379  if (db_string_to_datetime ((const char *) value->info.value.data_value.str->bytes, &datetime) != NO_ERROR)
3380  {
3382  value->info.value.data_value.str->bytes);
3383  return (DB_VALUE *) NULL;
3384  }
3385  db_make_datetime (db_value, &datetime);
3386  break;
3387 
3388  case PT_TYPE_DATETIMETZ:
3389  if (db_string_to_datetimetz ((const char *) value->info.value.data_value.str->bytes, &dt_tz, &has_zone) !=
3390  NO_ERROR)
3391  {
3393  value->info.value.data_value.str->bytes);
3394  return (DB_VALUE *) NULL;
3395  }
3396  db_make_datetimetz (db_value, &dt_tz);
3397  break;
3398 
3399  case PT_TYPE_DATETIMELTZ:
3400  if (db_string_to_datetimeltz ((const char *) value->info.value.data_value.str->bytes, &datetime) != NO_ERROR)
3401  {
3403  value->info.value.data_value.str->bytes);
3404  return (DB_VALUE *) NULL;
3405  }
3406  db_make_datetimeltz (db_value, &datetime);
3407  break;
3408 
3409  case PT_TYPE_MONETARY:
3410  /*
3411  * Don't use db_make_monetary here, since it doesn't preserve the
3412  * currency info.
3413  */
3415  value->info.value.data_value.money.amount);
3416  break;
3417 
3418  case PT_TYPE_NCHAR:
3419  /* for constants, set the precision to TP_FLOATING_PRECISION_VALUE */
3421  REINTERPRET_CAST (char *, value->info.value.data_value.str->bytes),
3422  value->info.value.data_value.str->length, codeset, collation_id);
3423  value->info.value.db_value_is_in_workspace = false;
3424  *more_type_info_needed = (value->data_type == NULL);
3425  break;
3426 
3427  case PT_TYPE_VARNCHAR:
3428  /* for constants, set the precision to TP_FLOATING_PRECISION_VALUE */
3430  REINTERPRET_CAST (char *, value->info.value.data_value.str->bytes),
3431  value->info.value.data_value.str->length, codeset, collation_id);
3432  value->info.value.db_value_is_in_workspace = false;
3433  *more_type_info_needed = (value->data_type == NULL);
3434  break;
3435 
3436  case PT_TYPE_BIT:
3437  case PT_TYPE_VARBIT:
3438  if (value->info.value.string_type == 'B')
3439  {
3440  src_length = value->info.value.data_value.str->length;
3441  dst_length = (src_length + 7) / 8;
3442  bits_converted = 0;
3443  bstring = (char *) db_private_alloc (NULL, dst_length + 1);
3444  if (!bstring)
3445  {
3446  return (DB_VALUE *) NULL;
3447  }
3448  bits_converted =
3449  qstr_bit_to_bin (bstring, dst_length, (char *) value->info.value.data_value.str->bytes, src_length);
3450  if (bits_converted != src_length)
3451  {
3452  db_private_free_and_init (NULL, bstring);
3454  pt_short_print (parser, value));
3455  return (DB_VALUE *) NULL;
3456  }
3457 
3458  db_make_bit (db_value, TP_FLOATING_PRECISION_VALUE, bstring, src_length);
3459  db_value->need_clear = true;
3460  value->info.value.db_value_is_in_workspace = true;
3461  }
3462  else if (value->info.value.string_type == 'X')
3463  {
3464  src_length = value->info.value.data_value.str->length;
3465  dst_length = (src_length + 1) / 2;
3466  bits_converted = 0;
3467  bstring = (char *) db_private_alloc (NULL, dst_length + 1);
3468  if (!bstring)
3469  {
3470  return (DB_VALUE *) NULL;
3471  }
3472  bits_converted =
3473  qstr_hex_to_bin (bstring, dst_length, (char *) value->info.value.data_value.str->bytes, src_length);
3474  if (bits_converted != src_length)
3475  {
3476  db_private_free_and_init (NULL, bstring);
3478  pt_short_print (parser, value));
3479  return (DB_VALUE *) NULL;
3480  }
3481  db_make_bit (db_value, TP_FLOATING_PRECISION_VALUE, bstring, src_length * 4);
3482  db_value->need_clear = true;
3483  value->info.value.db_value_is_in_workspace = true;
3484  }
3485  else
3486  {
3488  return (DB_VALUE *) NULL;
3489  }
3490  db_value_alter_type (db_value, pt_type_enum_to_db (value->type_enum));
3491  *more_type_info_needed = (value->data_type == NULL);
3492  break;
3493 
3494  case PT_TYPE_CHAR:
3495  /* for constants, set the precision to TP_FLOATING_PRECISION_VALUE */
3497  REINTERPRET_CAST (char *, value->info.value.data_value.str->bytes),
3498  value->info.value.data_value.str->length, codeset, collation_id);
3499  value->info.value.db_value_is_in_workspace = false;
3500  *more_type_info_needed = (value->data_type == NULL);
3501  break;
3502 
3503  case PT_TYPE_VARCHAR:
3504  /* for constants, set the precision to TP_FLOATING_PRECISION_VALUE */
3506  REINTERPRET_CAST (char *, value->info.value.data_value.str->bytes),
3507  value->info.value.data_value.str->length, codeset, collation_id);
3508  value->info.value.db_value_is_in_workspace = false;
3509  *more_type_info_needed = (value->data_type == NULL);
3510  break;
3511 
3512  case PT_TYPE_JSON:
3513  db_value->domain.general_info.type = DB_TYPE_JSON;
3514  db_value->domain.general_info.is_null = 0;
3515  json_body = (const char *) value->info.value.data_value.str->bytes;
3516  if (db_json_get_json_from_str (json_body, db_value->data.json.document,
3517  value->info.value.data_value.str->length) != NO_ERROR)
3518  {
3520  value->info.value.data_value.str->bytes);
3521  return (DB_VALUE *) NULL;
3522  }
3523 
3524  value->info.value.db_value_is_in_workspace = true;
3525  db_value->need_clear = true;
3526  *more_type_info_needed = (value->data_type == NULL);
3527  break;
3528 
3529  case PT_TYPE_OBJECT:
3530  db_make_object (db_value, value->info.value.data_value.op);
3531  value->info.value.db_value_is_in_workspace = true;
3532  *more_type_info_needed = (value->data_type == NULL);
3533  break;
3534 
3535  case PT_TYPE_BLOB:
3536  /* db_make_blob (db_value, (DB_ELO *)value->info.value.data_value.elo); */
3537  db_make_elo (db_value, DB_TYPE_BLOB, &value->info.value.data_value.elo);
3538  db_value->domain.general_info.type = DB_TYPE_BLOB;
3539  value->info.value.db_value_is_in_workspace = false;
3540  break;
3541 
3542  case PT_TYPE_CLOB:
3543  /* db_make_clob (db_value, (DB_ELO *)value->info.value.data_value.elo); */
3544  db_make_elo (db_value, DB_TYPE_CLOB, &value->info.value.data_value.elo);
3545  db_value->domain.general_info.type = DB_TYPE_CLOB;
3546  value->info.value.db_value_is_in_workspace = false;
3547  break;
3548 
3549  case PT_TYPE_COMPOUND:
3551  return (DB_VALUE *) NULL;
3552 
3553  case PT_TYPE_NONE:
3554  case PT_TYPE_STAR:
3555  case PT_TYPE_MAYBE:
3556  case PT_TYPE_EXPR_SET:
3557  case PT_TYPE_MAX:
3558  case PT_TYPE_MIDXKEY:
3559  case PT_TYPE_RESULTSET:
3561  return (DB_VALUE *) NULL;
3562 
3563  default:
3564  break;
3565  }
3566 
3567  return db_value;
3568 }
3569 
3570 /*
3571  * db_json_val_from_str() - create JSON value from string
3572  * return: error code
3573  * raw_str(in): buffer storing a JSON
3574  * str_size(in): size of buffer
3575  * json_val(out): output JSON DB_VALUE
3576  */
3577 int
3578 db_json_val_from_str (const char *raw_str, const int str_size, DB_VALUE * json_val)
3579 {
3580  JSON_DOC *json_doc = NULL;
3581  int error_code = NO_ERROR;
3582 
3583  error_code = db_json_get_json_from_str (raw_str, json_doc, str_size);
3584  if (error_code != NO_ERROR)
3585  {
3586  assert (json_doc == NULL);
3587  return error_code;
3588  }
3589 
3590  db_make_json (json_val, json_doc, true);
3591 
3592  return error_code;
3593 }
DB_OBJECT * db_find_class(const char *name)
Definition: db_info.c:133
#define SET_PARSER_ERROR_AND_FREE_NODE(parser, result, default_msg_id)
Definition: parse_dbi.c:55
PT_NODE * pt_name(PARSER_CONTEXT *parser_ptr, const char *name)
DB_C_FLOAT db_get_float(const DB_VALUE *value)
struct db_domain_info::char_info char_info
PT_NODE * next
Definition: parse_tree.h:3447
PT_NAME_INFO name
Definition: parse_tree.h:3318
TP_DOMAIN_STATUS tp_value_coerce(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain)
int db_make_json(DB_VALUE *value, JSON_DOC *json_document, bool need_clear)
#define DB_DATETIMETZ_PRECISION
Definition: dbtype_def.h:613
int db_make_datetime(DB_VALUE *value, const DB_DATETIME *datetime)
#define NO_ERROR
Definition: error_code.h:46
DB_VALUE * pt_db_value_initialize(PARSER_CONTEXT *parser, PT_NODE *value, DB_VALUE *db_value, int *more_type_info_needed)
Definition: parse_dbi.c:3195
#define DB_GET_ENUM_ELEM_STRING(elem)
Definition: dbtype.h:103
MISC_OPERAND pt_misc_to_qp_misc_operand(PT_MISC_TYPE misc_specifier)
Definition: parse_dbi.c:91
DB_COLLECTION * db_get_set(const DB_VALUE *value)
int db_value_scale(const DB_VALUE *value)
#define LANG_SYS_COLLATION
int db_json_val_from_str(const char *raw_str, const int str_size, DB_VALUE *json_val)
Definition: parse_dbi.c:3578
int db_timestamptz_to_string(char *buf, int bufsize, DB_TIMESTAMP *utime, const TZ_ID *tz_id)
Definition: db_date.c:4090
const char * pt_node_to_db_domain_name(PT_NODE *node)
Definition: parse_dbi.c:2224
#define DB_SET_ENUM_ELEM_STRING(elem, str)
Definition: dbtype.h:116
TP_DOMAIN tp_Variable_domain
#define PT_IS_CHAR_STRING_TYPE(t)
Definition: parse_tree.h:164
PT_STATEMENT_INFO info
Definition: parse_tree.h:3487
TP_DOMAIN * expected_domain
Definition: parse_tree.h:3452
#define PT_ERRORm(parser, node, setNo, msgNo)
Definition: parse_tree.h:63
#define ASSERT_ERROR()
#define PT_WARNINGmf2(parser, node, setNo, msgNo, arg1, arg2)
Definition: parse_tree.h:85
const char * db_get_class_name(DB_OBJECT *class_)
Definition: db_info.c:608
PT_MISC_TYPE var_type
Definition: parse_tree.h:2317
unsigned self_ref
Definition: object_domain.h:96
const char * schema_raw
Definition: dbtype_def.h:1039
unsigned char codeset
Definition: object_domain.h:91
PT_PRIV_TYPE auth_cmd
Definition: parse_tree.h:1880
DB_SET * db_seq_create(MOP classop, const char *name, int size)
Definition: db_set.c:252
#define MSGCAT_SEMANTIC_DATA_OVERFLOW_ON
DB_CONST_C_BIT db_get_bit(const DB_VALUE *value, int *length)
int db_date_to_string(char *buf, int bufsize, DB_DATE *date)
Definition: db_date.c:3953
DB_DOMAIN * pt_type_enum_to_db_domain(const PT_TYPE_ENUM t)
Definition: parse_dbi.c:1549
PT_MISC_TYPE
Definition: parse_tree.h:983
#define PT_ERROR(parser, node, msg)
Definition: parse_tree.h:54
PARSER_VARCHAR * pt_append_nulstring(const PARSER_CONTEXT *parser, PARSER_VARCHAR *bstring, const char *nulstring)
Definition: parse_tree.c:1072
int db_make_bigint(DB_VALUE *value, const DB_BIGINT num)
int db_get_int(const DB_VALUE *value)
int db_string_to_datetimetz(const char *str, DB_DATETIMETZ *dt_tz, bool *has_zone)
Definition: db_date.c:4520
DB_TIMESTAMP timestamp
Definition: dbtype_def.h:766
int db_is_vclass(DB_OBJECT *op)
Definition: db_virt.c:681
#define ER_REFERENCE_TO_NON_REFERABLE_NOT_ALLOWED
Definition: error_code.h:1231
DB_TYPE
Definition: dbtype_def.h:670
unsigned short count
Definition: dbtype_def.h:1033
DB_C_DOUBLE db_get_double(const DB_VALUE *value)
#define ER_FAILED
Definition: error_code.h:47
int db_make_varchar(DB_VALUE *value, const int max_char_length, DB_CONST_C_CHAR str, const int char_str_byte_size, const int codeset, const int collation_id)
void set_iterator_free(SET_ITERATOR *it)
Definition: set_object.c:4188
int db_seq_put(DB_SET *set, int index, DB_VALUE *value)
Definition: db_set.c:745
#define MSGCAT_SEMANTIC_OUT_OF_MEMORY
int db_get_string_collation(const DB_VALUE *value)
DB_VALUE * pt_seq_value_to_db(PARSER_CONTEXT *parser, PT_NODE *values, DB_VALUE *db_value, PT_NODE **el_types)
Definition: parse_dbi.c:979
PT_GET_XACTION_INFO get_xaction
Definition: parse_tree.h:3305
char * db_json_get_json_body_from_document(const JSON_DOC &doc)
Definition: db_json.cpp:1370
PT_MISC_TYPE option
Definition: parse_tree.h:2301
int db_value_clone(DB_VALUE *src, DB_VALUE *dest)
Definition: db_macro.c:1564
void db_value_domain_init_default(DB_VALUE *value, const DB_TYPE type)
Definition: db_macro.c:394
enum pt_type_enum PT_TYPE_ENUM
Definition: parse_tree.h:962
#define DB_AUTH_ALL
Definition: dbtype_def.h:157
int db_get_enum_string_size(const DB_VALUE *value)
#define MSGCAT_RUNTIME_BAD_TIME
int db_string_to_datetime(const char *str, DB_DATETIME *datetime)
Definition: db_date.c:4441
char * db_get_json_raw_body(const DB_VALUE *value)
Definition: db_macro.c:5082
int db_make_object(DB_VALUE *value, DB_C_OBJECT *obj)
DB_DOMAIN * pt_node_data_type_to_db_domain(PARSER_CONTEXT *parser, PT_NODE *dt, PT_TYPE_ENUM type)
Definition: parse_dbi.c:2029
PT_EXPR_INFO expr
Definition: parse_tree.h:3299
#define DB_TIME_PRECISION
Definition: dbtype_def.h:598
PARSER_CONTEXT * parser_create_parser(void)
Definition: parse_tree.c:1169
PT_MISC_TYPE meta_class
Definition: parse_tree.h:2552
#define ER_SM_DOMAIN_NOT_A_CLASS
Definition: error_code.h:316
PT_TYPE_ENUM pt_db_to_type_enum(const DB_TYPE t)
Definition: parse_dbi.c:2595
const char * pt_type_enum_to_db_domain_name(const PT_TYPE_ENUM t)
Definition: parse_dbi.c:1427
int db_timestampltz_to_string(char *buf, int bufsize, DB_TIMESTAMP *utime)
Definition: db_date.c:4146
int vid_oid_to_object(const DB_VALUE *value, DB_OBJECT **mop)
DB_VALUE * pt_host_var_db_value(PARSER_CONTEXT *parser, PT_NODE *hv)
Definition: parse_dbi.c:3160
SM_DEFAULT_VALUE default_value
Definition: class_object.h:451
#define DB_SET_ENUM_ELEM_SHORT(elem, sv)
Definition: dbtype.h:114
PT_NODE * pt_bind_type_from_dbval(PARSER_CONTEXT *parser, PT_NODE *node, DB_VALUE *val)
Definition: parse_dbi.c:3067
PARSER_VARCHAR * pt_append_bytes(const PARSER_CONTEXT *parser, PARSER_VARCHAR *old_string, const char *new_tail, const int new_tail_length)
Definition: parse_tree.c:1014
#define MSGCAT_RUNTIME_PARM_IS_NOT_SET
DB_DATETIMETZ * db_get_datetimetz(const DB_VALUE *value)
int db_make_datetimeltz(DB_VALUE *value, const DB_DATETIME *datetime)
int set_iterator_next(SET_ITERATOR *it)
Definition: set_object.c:4236
int db_make_sequence(DB_VALUE *value, DB_C_SET *set)
DB_DOMAIN * pt_node_to_db_domain(PARSER_CONTEXT *parser, PT_NODE *node, const char *class_name)
Definition: parse_dbi.c:2244
unsigned set_host_var
Definition: parse_tree.h:3605
void pt_set_host_variables(PARSER_CONTEXT *parser, int count, DB_VALUE *values)
Definition: parse_dbi.c:3086
int er_errid(void)
DB_SET * db_set_create_multi(MOP classop, const char *name)
Definition: db_set.c:192
PT_NODE * pt_sort_in_desc_order(PT_NODE *vlist)
Definition: parse_dbi.c:2484
#define DB_VALUE_PRECISION(value)
Definition: dbtype.h:73
TP_DOMAIN tp_Null_domain
#define DB_SHORT_PRECISION
Definition: dbtype_def.h:586
DB_VALUE * host_variables
Definition: parse_tree.h:3560
void pt_add_type_to_set(PARSER_CONTEXT *parser, const PT_NODE *typs, PT_NODE **set)
Definition: parse_dbi.c:198
int db_make_elo(DB_VALUE *value, DB_TYPE type, const DB_ELO *elo)
PT_NODE * data_type
Definition: parse_tree.h:3453
#define DB_DEFAULT_NUMERIC_SCALE
Definition: dbtype_def.h:567
struct parser_context::@134 flag
DB_DOMAIN_INFO domain
Definition: dbtype_def.h:1082
#define DB_VALUE_SCALE(value)
Definition: dbtype.h:74
DB_ELO * db_get_elo(const DB_VALUE *value)
int db_datetimetz_to_string(char *buf, int bufsize, DB_DATETIME *dt, const TZ_ID *tz_id)
Definition: db_date.c:4302
#define DB_DATETIME_DECIMAL_SCALE
Definition: dbtype_def.h:616
#define DB_FLOAT_DECIMAL_PRECISION
Definition: dbtype_def.h:589
#define MSGCAT_SEMANTIC_CANT_COERCE_TO
void parser_free_parser(PARSER_CONTEXT *parser)
Definition: parse_tree.c:1240
#define REINTERPRET_CAST(dest_type, expr)
Definition: porting.h:1080
DB_TIMESTAMPTZ * db_get_timestamptz(const DB_VALUE *value)
#define MSGCAT_RUNTIME_INVALID_JSON
int db_make_short(DB_VALUE *value, const DB_C_SHORT num)
DB_DEFAULT_EXPR_TYPE default_expr_type
Definition: dbtype_def.h:1204
PT_CURRENCY type
Definition: parse_tree.h:3020
static PT_NODE * pt_set_elements_to_value(PARSER_CONTEXT *parser, const DB_VALUE *val)
Definition: parse_dbi.c:477
PT_TYPE_ENUM type_enum
Definition: parse_tree.h:3457
void pt_report_to_ersys(const PARSER_CONTEXT *parser, const PT_ERROR_TYPE error_type)
Definition: query_result.c:287
DB_VALUE * pt_set_value_to_db(PARSER_CONTEXT *parser, PT_NODE **values, DB_VALUE *db_value, PT_NODE **el_types)
Definition: parse_dbi.c:1033
DB_TYPE pt_type_enum_to_db(const PT_TYPE_ENUM t)
Definition: parse_dbi.c:2314
TP_DOMAIN_STATUS tp_value_cast_preserve_domain(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, bool implicit_coercion, bool preserve_domain)
unsigned char bytes[1]
Definition: parse_tree.h:3431
DB_MONETARY * db_get_monetary(const DB_VALUE *value)
int db_string_to_time(const char *str, DB_TIME *time)
Definition: db_date.c:3739
DB_DATA data
Definition: dbtype_def.h:1083
DB_CURRENCY
Definition: dbtype_def.h:799
DB_DEFAULT_EXPR default_expr
Definition: class_object.h:395
int pt_get_varchar_length(const PARSER_VARCHAR *string)
Definition: parse_tree.c:1106
DB_JSON json
Definition: dbtype_def.h:1073
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
Definition: db_set.h:35
int db_set_get(DB_SET *set, int index, DB_VALUE *value)
Definition: db_set.c:508
int db_value_put_encoded_time(DB_VALUE *value, const DB_TIME *time)
Definition: db_macro.c:1357
#define CAST_POINTER_TO_NODE(p)
Definition: parse_tree.h:607
DB_OBJECT * db_object
Definition: parse_tree.h:2546
int obt_quit(OBJ_TEMPLATE *template_ptr)
PT_OP_TYPE pt_op_type_from_default_expr_type(DB_DEFAULT_EXPR_TYPE expr_type)
PARSER_VARCHAR * json_schema
Definition: parse_tree.h:2054
#define PT_ERRORmf2(parser, node, setNo, msgNo, arg1, arg2)
Definition: parse_tree.h:65
#define assert(x)
#define DB_DATETIME_PRECISION
Definition: dbtype_def.h:610
int db_make_monetary(DB_VALUE *value, const DB_CURRENCY type, const double amount)
#define DOM_SET_ENUM_ELEMENTS(dom, elems)
Definition: object_domain.h:47
#define LANG_COERCIBLE_CODESET
#define DB_SET_ENUM_ELEM_STRING_SIZE(elem, sz)
Definition: dbtype.h:119
int qstr_hex_to_bin(char *dest, int dest_size, const char *src, int src_size)
#define DB_DOUBLE_DECIMAL_PRECISION
Definition: dbtype_def.h:592
#define MSGCAT_RUNTIME_HOSTVAR_INDEX_ERROR
int db_make_set(DB_VALUE *value, DB_C_SET *set)
struct db_domain_info::numeric_info numeric_info
void pt_evaluate_tree(PARSER_CONTEXT *parser, PT_NODE *tree, DB_VALUE *db_values, int values_count)
char * db_private_strdup(THREAD_ENTRY *thrd, const char *s)
Definition: memory_alloc.c:675
int db_make_multiset(DB_VALUE *value, DB_C_SET *set)
#define ER_GENERIC_ERROR
Definition: error_code.h:49
DB_OBJECT * op
Definition: parse_tree.h:3039
PT_TYPE_ENUM virt_type_enum
Definition: parse_tree.h:2042
DB_VALUE db_value
Definition: parse_tree.h:3059
TP_DOMAIN_COLL_ACTION
Definition: object_domain.h:62
const char * pt_show_type_enum(PT_TYPE_ENUM t)
#define TP_DOMAIN_SELF_REF
Definition: object_domain.h:60
#define ER_OUT_OF_VIRTUAL_MEMORY
Definition: error_code.h:50
PT_NODE * entity
Definition: parse_tree.h:2038
#define MSGCAT_SET_PARSER_RUNTIME
unsigned short short_val
Definition: parse_tree.h:3025
DB_TYPE db_value_type(const DB_VALUE *value)
PT_DATA_VALUE data_value
Definition: parse_tree.h:3058
PT_NODE ** parser_parse_string(PARSER_CONTEXT *parser, const char *buffer)
#define DB_INTEGER_PRECISION
Definition: dbtype_def.h:580
int db_json_get_json_from_str(const char *json_raw, JSON_DOC *&doc, size_t json_raw_length)
Definition: db_json.cpp:1608
const char * original
Definition: parse_tree.h:2544
JSON_DOC * document
Definition: dbtype_def.h:1040
DB_DATETIME datetime
Definition: dbtype_def.h:783
int intl_identifier_casecmp(const char *str1, const char *str2)
#define DB_VALUE_DOMAIN_TYPE(value)
Definition: dbtype.h:70
PT_NODE_TYPE node_type
Definition: parse_tree.h:3439
DB_BIGINT bigint
Definition: parse_tree.h:3033
const char * db_error_string(int level)
Definition: db_admin.c:2116
PT_NODE * pt_sm_attribute_default_value_to_node(PARSER_CONTEXT *parser, const SM_ATTRIBUTE *sm_attr)
Definition: parse_dbi.c:516
#define db_get_json_schema(v)
Definition: dbtype.h:148
#define MSGCAT_SEMANTIC_INVALID_BITSTRING
DB_DOMAIN * pt_data_type_to_db_domain(PARSER_CONTEXT *parser, PT_NODE *dt, const char *class_name)
Definition: parse_dbi.c:1805
DB_OBJECT * db_get_object(const DB_VALUE *value)
int db_make_timestamptz(DB_VALUE *value, const DB_C_TIMESTAMPTZ *ts_tz_val)
VID_OID oid_info
Definition: work_space.h:120
PT_NODE * enumeration
Definition: parse_tree.h:2039
UINTPTR spec_id
Definition: parse_tree.h:2543
static PT_NODE * pt_bind_set_type(PARSER_CONTEXT *parser, PT_NODE *node, DB_VALUE *val, int *data_type_added)
Definition: parse_dbi.c:2995
TP_DOMAIN_STATUS tp_value_cast(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, bool implicit_coercion)
#define TP_DOMAIN_TYPE(dom)
PT_DATA_TYPE_INFO data_type
Definition: parse_tree.h:3284
PARSER_VARCHAR * str
Definition: parse_tree.h:3036
SP_PARSER_CTX * parser
#define NULL
Definition: freelistheap.h:34
OID oid
Definition: work_space.h:65
unsigned short db_get_enum_short(const DB_VALUE *value)
const char * er_msg(void)
struct pr_type * type
Definition: object_domain.h:76
#define MSGCAT_RUNTIME_UNDEFINED_CONVERSION
#define LANG_COERCIBLE_COLL
DB_OBJECT * db_get_class(MOP obj)
Definition: db_info.c:589
CUBRID_STMT_TYPE pt_node_to_cmd_type(PT_NODE *node)
Definition: parse_dbi.c:2736
const char * pr_type_name(DB_TYPE id)
DB_CURRENCY type
Definition: dbtype_def.h:832
if(extra_options)
Definition: dynamic_load.c:958
#define MSGCAT_RUNTIME_BAD_NUMERIC
DB_AUTH pt_auth_to_db_auth(const PT_NODE *auth)
Definition: parse_dbi.c:2539
struct pr_type * type
Definition: class_object.h:443
int pt_is_reference_to_reusable_oid(DB_VALUE *val)
int db_set_add(DB_SET *set, DB_VALUE *value)
Definition: db_set.c:465
TP_DOMAIN * tp_domain_cache(TP_DOMAIN *transient)
#define err(fd,...)
Definition: porting.h:431
#define PT_ERRORc(parser, node, msg)
Definition: parse_tree.h:55
#define db_private_free_and_init(thrd, ptr)
Definition: memory_alloc.h:141
int db_value_put_encoded_date(DB_VALUE *value, const DB_DATE *date)
Definition: db_macro.c:1383
DB_SET * db_set_create_basic(MOP classop, const char *name)
Definition: db_set.c:134
#define PT_IS_COLLECTION_TYPE(t)
Definition: parse_tree.h:143
short db_value_is_in_workspace
Definition: parse_tree.h:3061
PT_AUTH_CMD_INFO auth_cmd
Definition: parse_tree.h:3274
#define db_private_free(thrd, ptr)
Definition: memory_alloc.h:229
#define db_private_alloc(thrd, size)
Definition: memory_alloc.h:227
int tp_domain_add(TP_DOMAIN **dlist, TP_DOMAIN *domain)
int db_elo_copy_structure(const DB_ELO *src, DB_ELO *dest)
Definition: db_elo.c:74
need_clear_type need_clear
Definition: dbtype_def.h:1084
#define DB_TIMESTAMP_PRECISION
Definition: dbtype_def.h:604
#define MSGCAT_RUNTIME_UNIMPLEMENTED_CONV
int db_set_size(DB_SET *set)
Definition: db_set.c:557
DB_DOMAIN * pt_string_to_db_domain(const char *s, const char *class_name)
Definition: parse_dbi.c:1332
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
#define db_utime_to_string
Definition: tz_support.h:29
int pr_clear_value(DB_VALUE *value)
#define MSGCAT_CATALOG_CUBRID
const char * text
Definition: parse_tree.h:3056
DB_BIGINT db_get_bigint(const DB_VALUE *value)
DB_TYPE pt_node_to_db_type(PT_NODE *node)
Definition: parse_dbi.c:2453
#define DB_MONETARY_DECIMAL_PRECISION
Definition: dbtype_def.h:595
#define DB_BIGINT_PRECISION
Definition: dbtype_def.h:577
int vid_vobj_to_object(const DB_VALUE *vobj, DB_OBJECT **mop)
int db_time_to_string(char *buf, int bufsize, DB_TIME *time)
Definition: db_date.c:3994
#define DB_DEFAULT_NUMERIC_PRECISION
Definition: dbtype_def.h:564
TP_DOMAIN ** host_var_expected_domains
Definition: parse_tree.h:3561
PT_NODE * pt_add_class_to_entity_list(PARSER_CONTEXT *parser, DB_OBJECT *class_, PT_NODE *entity, const PT_NODE *parent, UINTPTR id, PT_MISC_TYPE meta_class)
int db_datetime_to_string(char *buf, int bufsize, DB_DATETIME *datetime)
Definition: db_date.c:4225
#define DB_DEFAULT_SCALE
Definition: dbtype_def.h:561
DB_VALUE * pt_find_value_of_label(const char *label)
PT_NODE * set
Definition: parse_tree.h:3047
bool pt_is_same_enum_data_type(PT_NODE *dt1, PT_NODE *dt2)
Definition: parse_dbi.c:147
int db_make_datetimetz(DB_VALUE *value, const DB_DATETIMETZ *datetimetz)
struct db_domain_info::general_info general_info
int db_bit_string(const DB_VALUE *the_db_bit, const char *bit_format, char *string, int max_size)
Definition: cnv.c:8575
#define MSGCAT_RUNTIME_BAD_UTIME
static PT_NODE * pt_bind_helper(PARSER_CONTEXT *parser, PT_NODE *node, DB_VALUE *val, int *data_type_added)
Definition: parse_dbi.c:2790
PT_NODE * parser_append_node(PT_NODE *node, PT_NODE *list)
char * pt_short_print(PARSER_CONTEXT *parser, const PT_NODE *node)
PT_NODE * parser_init_node(PT_NODE *node, PT_NODE_TYPE node_type)
DB_ENUMERATION enumeration
Definition: object_domain.h:84
DB_CONST_C_CHAR db_get_enum_string(const DB_VALUE *value)
#define TP_IS_CHAR_TYPE(typeid)
TP_DOMAIN_COLL_ACTION collation_flag
Definition: object_domain.h:94
PT_NODE * parser_new_node(PARSER_CONTEXT *parser, PT_NODE_TYPE node_type)
static void error(const char *msg)
Definition: gencat.c:331
int db_make_float(DB_VALUE *value, const DB_C_FLOAT num)
void parser_free_node(const PARSER_CONTEXT *parser, PT_NODE *node)
Definition: parse_tree.c:869
int qstr_bit_to_bin(char *dest, int dest_size, const char *src, int src_size)
#define DB_DEFAULT_PRECISION
Definition: dbtype_def.h:558
const char * pt_data_type_to_db_domain_name(const PT_NODE *dt)
Definition: parse_dbi.c:1655
int db_json_validate_json(const char *json_body)
Definition: db_json.cpp:2316
TP_DOMAIN * tp_domain_construct(DB_TYPE domain_type, DB_OBJECT *class_obj, int precision, int scale, TP_DOMAIN *setdomain)
const unsigned char * pt_get_varchar_bytes(const PARSER_VARCHAR *string)
Definition: parse_tree.c:1089
int db_string_to_timestampltz(const char *str, DB_TIMESTAMP *ts)
Definition: db_date.c:3936
char * numeric_db_value_print(const DB_VALUE *val, char *buf)
short db_value_is_initialized
Definition: parse_tree.h:3060
#define MSGCAT_SET_ERROR
DB_AUTH
Definition: dbtype_def.h:239
#define ARG_FILE_LINE
Definition: error_manager.h:44
void pt_data_type_init_value(const PT_NODE *node, DB_VALUE *value_out)
Definition: parse_dbi.c:1264
int pr_clone_value(const DB_VALUE *src, DB_VALUE *dest)
void parser_free_tree(PARSER_CONTEXT *parser, PT_NODE *tree)
unsigned int DB_TIME
Definition: dbtype_def.h:754
enum pt_currency_types PT_CURRENCY
unsigned int DB_DATE
Definition: dbtype_def.h:771
int db_string_to_datetimeltz(const char *str, DB_DATETIME *datetime)
Definition: db_date.c:4555
#define MSGCAT_SET_PARSER_SEMANTIC
CUBRID_STMT_TYPE
Definition: cas_dbms_util.h:40
#define DB_SET_ENUM_ELEM_CODESET(elem, cs)
Definition: dbtype.h:111
#define free_and_init(ptr)
Definition: memory_alloc.h:147
#define strlen(s1)
Definition: intl_support.c:43
#define MSGCAT_RUNTIME_BAD_DATE
int db_make_timestampltz(DB_VALUE *value, const DB_C_TIMESTAMP ts_val)
DB_DATE * db_get_date(const DB_VALUE *value)
DB_ENUM_ELEMENT * elements
Definition: dbtype_def.h:1031
#define DB_DATE_PRECISION
Definition: dbtype_def.h:601
int db_value_precision(const DB_VALUE *value)
DB_OBJECT * virt_object
Definition: parse_tree.h:2040
enum intl_codeset INTL_CODESET
Definition: intl_support.h:190
JSON_VALIDATOR * json_validator
int db_json_load_validator(const char *json_schema_raw, JSON_VALIDATOR *&validator)
Definition: db_json.cpp:2362
DB_TIMESTAMP * db_get_timestamp(const DB_VALUE *value)
int db_get_string_size(const DB_VALUE *value)
DB_C_SHORT db_get_short(const DB_VALUE *value)
void tp_domain_clear_enumeration(DB_ENUMERATION *enumeration)
int db_make_varnchar(DB_VALUE *value, const int max_nchar_length, DB_CONST_C_NCHAR str, const int nchar_str_byte_size, const int codeset, const int collation_id)
#define TP_FLOATING_PRECISION_VALUE
DB_VALUE * set_iterator_value(SET_ITERATOR *it)
Definition: set_object.c:4201
DB_CURRENCY db_value_get_monetary_currency(const DB_VALUE *value)
Definition: db_macro.c:1492
#define DB_VALUE_TYPE(value)
Definition: dbtype.h:72
int i
Definition: dynamic_load.c:954
PT_VALUE_INFO value
Definition: parse_tree.h:3358
int db_make_null(DB_VALUE *value)
char * msgcat_message(int cat_id, int set_id, int msg_id)
#define DB_TIMESTAMPTZ_PRECISION
Definition: dbtype_def.h:607
DB_TYPE id
#define DB_IS_NULL(value)
Definition: dbtype.h:63
static int pt_get_enumeration_from_data_type(PARSER_CONTEXT *parser, PT_NODE *dt, DB_ENUMERATION *enumeration)
Definition: parse_dbi.c:1686
PT_OP_TYPE op
Definition: parse_tree.h:2200
PT_MONETARY money
Definition: parse_tree.h:3046
int db_make_double(DB_VALUE *value, const DB_C_DOUBLE num)
DB_DATETIME * db_get_datetime(const DB_VALUE *value)
#define PT_INTERNAL_ERROR(parser, what)
Definition: parse_tree.h:112
int db_value_clear(DB_VALUE *value)
Definition: db_macro.c:1588
int db_make_timestamp(DB_VALUE *value, const DB_C_TIMESTAMP timeval)
int db_make_int(DB_VALUE *value, const int num)
#define db_string_to_utime
Definition: tz_support.h:30
struct db_object * class_mop
Definition: object_domain.h:81
#define pt_has_error(parser)
Definition: parser.h:507
PT_NODE * pt_domain_to_data_type(PARSER_CONTEXT *parser, DB_DOMAIN *domain)
int db_make_char(DB_VALUE *value, const int char_length, DB_CONST_C_CHAR str, const int char_str_byte_size, const int codeset, const int collation_id)
PARSER_VARCHAR * str_val
Definition: parse_tree.h:3026
int tp_domain_attach(TP_DOMAIN **dlist, TP_DOMAIN *domain)
DB_TIMESTAMP DB_UTIME
Definition: dbtype_def.h:761
#define LANG_SYS_CODESET
#define PT_HAS_COLLATION(t)
Definition: parse_tree.h:243
int db_string_to_timestamptz(const char *str, DB_TIMESTAMPTZ *ts_tz, bool *has_zone)
Definition: db_date.c:3894
int collation_id
Definition: object_domain.h:92
static PT_NODE * pt_get_object_data_type(PARSER_CONTEXT *parser, const DB_VALUE *val)
Definition: parse_dbi.c:415
DB_TIME * db_get_time(const DB_VALUE *value)
#define DOM_SET_ENUM_ELEMS_COUNT(dom, cnt)
Definition: object_domain.h:49
int numeric_coerce_string_to_num(const char *astring, int astring_length, INTL_CODESET codeset, DB_VALUE *result)
PT_ENUM_ELEMENT enumeration
Definition: parse_tree.h:3050
PT_NODE * pt_dbval_to_value(PARSER_CONTEXT *parser, const DB_VALUE *val)
Definition: parse_dbi.c:574
DB_VALUE * default_value
Definition: esql_cli.c:348
int column_number
Definition: parse_tree.h:3442
DB_C_POINTER db_get_pointer(const DB_VALUE *value)
DB_VALUE * pt_value_to_db(PARSER_CONTEXT *parser, PT_NODE *value)
Definition: parse_dbi.c:1088
#define pt_is_const(n)
Definition: parse_tree.h:271
TP_DOMAIN * tp_domain_new(DB_TYPE type)
double amount
Definition: dbtype_def.h:831
PT_HOST_VAR_INFO host_var
Definition: parse_tree.h:3307
PT_PRIV_TYPE
Definition: parse_tree.h:965
TP_DOMAIN_COLL_ACTION collation_flag
Definition: parse_tree.h:2048
int db_make_bit(DB_VALUE *value, const int bit_length, DB_CONST_C_BIT bit_str, const int bit_str_bit_size)
int db_get_string_codeset(const DB_VALUE *value)
int db_string_to_date(const char *str, DB_DATE *date)
Definition: db_date.c:3693
PT_NODE * parser_copy_tree_list(PARSER_CONTEXT *parser, PT_NODE *tree)
SET_ITERATOR * set_iterate(DB_COLLECTION *set)
Definition: set_object.c:4146
DB_CONST_C_CHAR db_get_string(const DB_VALUE *value)
MISC_OPERAND
#define PT_ERRORmf(parser, node, setNo, msgNo, arg1)
Definition: parse_tree.h:64
int db_make_nchar(DB_VALUE *value, const int nchar_length, DB_CONST_C_NCHAR str, const int nchar_str_byte_size, const int codeset, const int collation_id)
int db_datetimeltz_to_string(char *buf, int bufsize, DB_DATETIME *dt)
Definition: db_date.c:4350
int db_value_domain_init(DB_VALUE *value, const DB_TYPE type, const int precision, const int scale)
Definition: db_macro.c:153
int db_value_alter_type(DB_VALUE *value, const DB_TYPE type)
Definition: db_macro.c:1225