CUBRID Engine  latest
query_result.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * query_result.c - Helper functions to allocate, initialize query result
21  * descriptor for select expressions.
22  */
23 
24 #ident "$Id$"
25 
26 #include "config.h"
27 
28 #include "authenticate.h"
29 #include "misc_string.h"
30 #include "error_manager.h"
31 #include "parser.h"
32 #include "parser_message.h"
33 #include "server_interface.h"
34 #include "db_query.h"
35 #include "object_accessor.h"
36 #include "schema_manager.h"
37 #include "memory_alloc.h"
38 #include "execute_statement.h"
39 #include "xasl_generation.h"
40 #include "object_primitive.h"
41 #include "db.h"
42 #include "network_interface_cl.h"
43 #include "transaction_cl.h"
44 #include "dbtype.h"
45 
46 static int pt_find_size_from_dbtype (const DB_TYPE T_type);
47 static int pt_arity_of_query_type (const DB_QUERY_TYPE * qt);
48 static char *pt_get_attr_name (PARSER_CONTEXT * parser, PT_NODE * node);
49 static DB_COL_TYPE pt_get_col_type (const PARSER_CONTEXT * parser, const PT_NODE * node);
50 static void pt_set_domain_class (SM_DOMAIN * dom, const PT_NODE * nam, const DB_OBJECT * virt);
51 static void pt_set_domain_class_list (SM_DOMAIN * dom, const PT_NODE * nam, const DB_OBJECT * virt);
52 static SM_DOMAIN *pt_get_src_domain (PARSER_CONTEXT * parser, const PT_NODE * s, const PT_NODE * specs);
53 static DB_QUERY_TYPE *pt_get_node_title (PARSER_CONTEXT * parser, const PT_NODE * col, const PT_NODE * from_list);
54 static PT_NODE *pt_get_from_list (const PARSER_CONTEXT * parser, const PT_NODE * query);
55 static void pt_fixup_select_columns_type (PT_NODE * columns);
56 
57 /*
58  * pt_find_size_from_dbtype () - return bytesize of memory representation of
59  * a given primitive DB_TYPE
60  * return: the bytesize of dt's memory representation
61  * T_type(in): a DB_TYPE
62  */
63 static int
65 {
66  PRIM type;
67  int size = 0;
68 
69  if (db_type != DB_TYPE_NULL)
70  {
71  type = pr_type_from_id (db_type);
72  if (type && !(type->variable_p))
73  {
74  size = pr_mem_size (type);
75  }
76  }
77 
78  return size;
79 }
80 
81 /*
82  * pt_arity_of_query_type () - return arity (number of columns) of
83  * a given DB_QUERY_TYPE
84  * return: the arity (number of columns) of qt
85  * qt(in): a DB_QUERY_TYPE handle
86  */
87 
88 static int
90 {
91  int cnt = 0;
92 
93  while (qt)
94  {
95  cnt++;
96  qt = qt->next;
97  }
98 
99  return cnt;
100 }
101 
102 /*
103  * pt_get_attr_name () - return the attribute name of a select_list item or NULL
104  * return: the attribute name of s if s is a path expression,
105  * NULL otherwise
106  * parser(in):
107  * node(in): an expression representing a select_list item
108  */
109 static char *
111 {
112  const char *name;
113  char *res = NULL;
114  unsigned int save_custom = parser->custom_print;
115 
116  node = pt_get_end_path_node (node);
117  if (node == NULL)
118  {
119  return NULL;
120  }
121  if (node->node_type != PT_NAME)
122  {
123  return NULL;
124  }
125 
127 
128  name = parser_print_tree (parser, node);
129  parser->custom_print = save_custom;
130 
131  if (name)
132  {
133  res = strdup (name);
134  }
135 
136  return res;
137 }
138 
139 /*
140  * pt_get_col_type () -
141  * return:
142  * parser(in):
143  * node(in):
144  */
145 static DB_COL_TYPE
147 {
148  if (pt_is_expr_node (node))
149  return DB_COL_EXPR;
150 
151  if (pt_is_value_node (node))
152  return DB_COL_VALUE;
153 
154  if (pt_is_oid_name (node))
155  return DB_COL_OID;
156 
157  if (pt_is_name_node (node))
158  return DB_COL_NAME;
159 
160  if (pt_is_dot_node (node))
161  {
162  if (node->info.dot.arg2->node_type == PT_FUNCTION || node->info.dot.arg2->node_type == PT_METHOD_CALL)
163  return DB_COL_OTHER;
164  else
165  return DB_COL_PATH;
166  }
167 
168  if (pt_is_function (node))
169  return DB_COL_FUNC;
170 
171  return DB_COL_OTHER;
172 }
173 
174 
175 /*
176  * pt_set_domain_class() - set SM_DOMAIN's class field
177  * return: none
178  * dom(out): an SM_DOMAIN
179  * nam(in): an entity name
180  * virt(in):
181  */
182 static void
183 pt_set_domain_class (SM_DOMAIN * dom, const PT_NODE * nam, const DB_OBJECT * virt)
184 {
185  if (!dom || !nam || nam->node_type != PT_NAME)
186  return;
187 
189  if (virt != NULL)
190  {
191  dom->class_mop = (DB_OBJECT *) virt;
192  }
193  else
194  {
195  if (nam->info.name.db_object != NULL)
196  {
197  dom->class_mop = nam->info.name.db_object;
198  COPY_OID (&dom->class_oid, &(dom->class_mop->oid_info.oid));
199  }
200  else
201  {
202  dom->class_mop = db_find_class (nam->info.name.original);
203  if (dom->class_mop != NULL)
204  {
205  COPY_OID (&dom->class_oid, &(dom->class_mop->oid_info.oid));
206  }
207  }
208  }
209 }
210 
211 /*
212  * pt_set_domain_class_list() - set SM_DOMAIN's class fields
213  * return: none
214  * dom(out): an SM_DOMAIN anchor node
215  * nam(in): an entity name list
216  * virt(in):
217  */
218 static void
219 pt_set_domain_class_list (SM_DOMAIN * dom, const PT_NODE * nam, const DB_OBJECT * virt)
220 {
221  SM_DOMAIN *tail = dom;
222 
223  while (nam && nam->node_type == PT_NAME && dom)
224  {
225  pt_set_domain_class (dom, nam, virt);
226  nam = nam->next;
227 
228  if (!nam || nam->node_type != PT_NAME)
229  break;
230 
231  dom = sm_domain_alloc ();
232  assert (dom != NULL);
234  tail->next = dom;
235  tail = dom;
236  }
237 }
238 
239 /*
240  * pt_get_src_domain() - compute & return the source domain of an expression
241  * return: source domain of the given expression
242  * parser(in): the parser context
243  * s(in): an expression representing a select_list item
244  * specs(in): the list of specs to which s was resolved
245  */
246 static SM_DOMAIN *
248 {
249  SM_DOMAIN *result;
250  PT_NODE *spec, *entity_names, *leaf = (PT_NODE *) s;
251  UINTPTR spec_id;
252 
253  result = sm_domain_alloc ();
254  if (result == NULL)
255  {
256  return result;
257  }
259 
260  /* if s is not a path expression then its source domain is DB_TYPE_NULL */
261  result->type = pr_type_from_id (DB_TYPE_NULL);
262 
263  /* make leaf point to the last leaf name node */
264  if (s->node_type == PT_DOT_)
265  {
266  leaf = s->info.dot.arg2;
267  }
268 
269  /* s's source domain is the domain of leaf's resolvent(s) */
270  if (leaf->node_type == PT_NAME && (spec_id = leaf->info.name.spec_id)
271  && (spec = pt_find_entity (parser, specs, spec_id)) && (entity_names = spec->info.spec.flat_entity_list))
272  {
273  pt_set_domain_class_list (result, entity_names, entity_names->info.name.virt_object);
274  }
275 
276  return result;
277 }
278 
279 /*
280  * pt_report_to_ersys () - report query compilation error by
281  * setting global ER state
282  * return:
283  * parser(in): handle to parser used to process the query
284  * error_type(in): syntax, semantic, or execution
285  */
286 void
288 {
289  PT_NODE *error_node;
290  int err;
291  char buf[1000];
292 
293  error_node = parser->error_msgs;
294  if (error_node && error_node->node_type == PT_ZZ_ERROR_MSG)
295  {
296 #if 0 /* TODO */
297  assert (er_errid () != NO_ERROR);
298 #endif
299  err = er_errid ();
301  {
302  switch (error_type)
303  {
304  case PT_SYNTAX:
306  error_node->info.error_msg.error_message, "");
307  break;
308  case PT_SEMANTIC:
309  default:
311  error_node->info.error_msg.error_message, "");
312  break;
313  case PT_EXECUTION:
315  error_node->info.error_msg.error_message, "");
316  break;
317  }
318  }
319  return;
320  }
321 
322  /* a system error reporting error messages */
323  sprintf (buf, "Internal error- reporting %s error.",
324  (error_type == PT_SYNTAX ? "syntax" : (error_type == PT_SEMANTIC ? "semantic" : "execution")));
325 
327 }
328 
329 /*
330  * pt_report_to_ersys_with_statement () - report query compilation error by
331  * setting global ER state
332  * return:
333  * parser(in): handle to parser used to process the query
334  * error_type(in): syntax, semantic, or execution
335  * statement(in): statement tree
336  */
337 void
339 {
340  PT_NODE *error_node;
341  char buf[1000];
342  char *stmt_string = NULL;
343  int err;
344 
345  if (parser == NULL)
346  {
347  return;
348  }
349 
350  error_node = parser->error_msgs;
351  if (statement)
352  {
354  stmt_string = (char *) statement->alias_print;
355  }
356  if (stmt_string == NULL)
357  {
358  stmt_string = (char *) "";
359  }
360 
361  if (error_node && error_node->node_type == PT_ZZ_ERROR_MSG)
362  {
363 #if 0 /* TODO */
364  assert (er_errid () != NO_ERROR);
365 #endif
366  err = er_errid ();
368  {
369  switch (error_type)
370  {
371  case PT_SYNTAX:
373  error_node->info.error_msg.error_message, stmt_string);
374  break;
375  case PT_SEMANTIC:
376  default:
378  error_node->info.error_msg.error_message, stmt_string);
379  break;
380  case PT_EXECUTION:
382  error_node->info.error_msg.error_message, stmt_string);
383  break;
384  }
385  }
386  return;
387  }
388 
389  /* a system error reporting error messages */
390  sprintf (buf, "Internal error- reporting %s error.",
391  (error_type == PT_SYNTAX ? "syntax" : (error_type == PT_SEMANTIC ? "semantic" : "execution")));
392 
394 } /* pt_report_to_ersys_with_statement() */
395 
396 /*
397  * pt_get_select_list () - PT_NODE *, a pointer to query's select list
398  * NULL if query is a 'SELECT *' query
399  * return:
400  * parser(in): handle to parser used to process & derive query
401  * query(out): abstract syntax tree form of a SELECT expression
402  */
403 PT_NODE *
405 {
406  PT_NODE *list, *attr;
407  PT_NODE *arg1, *arg2, *attr1, *attr2, *select_list, *col, *next;
408  int cnt1, cnt2;
409  PT_TYPE_ENUM common_type;
410 
411  if (query == NULL)
412  {
413  return NULL;
414  }
415 
416  switch (query->node_type)
417  {
418  default:
419  return NULL;
420 
421  case PT_SELECT:
422  list = query->info.query.q.select.list;
423  if (list == NULL)
424  {
425  return NULL;
426  }
427 
428  /* return the first row of PT_NODE_LIST */
429  if (list->node_type == PT_NODE_LIST)
430  {
431  return list->info.node_list.list;
432  }
433 
434  if (list->node_type == PT_VALUE && list->type_enum == PT_TYPE_STAR)
435  {
436  return NULL;
437  }
438 
439  for (attr = list; attr; attr = attr->next)
440  {
441  if (attr->node_type == PT_NAME && attr->type_enum == PT_TYPE_STAR)
442  {
443  /* found "class_name.*" */
444  return NULL;
445  }
446  }
447 
448  return list;
449 
450  case PT_DIFFERENCE:
451  case PT_INTERSECTION:
452  case PT_UNION:
453  select_list = query->info.query.q.union_.select_list;
454 
455  assert (query->parser_id == parser->id);
456  if (select_list && select_list->parser_id != parser->id)
457  {
458  /*
459  * Union PT_NODE keeps select_list as reference
460  * this case means, this parser copy other parsers tree
461  * but union.info.select_list points old reference
462  *
463  * this function can free & realloc select_list->data_type
464  * so, to prevent modifying (other parser's) original
465  * tree, deep copy select_list in this parser's context
466  */
467  select_list = parser_copy_tree_list (parser, select_list);
468  query->info.query.q.union_.select_list = select_list;
469  }
470 
471  arg1 = pt_get_select_list (parser, query->info.query.q.union_.arg1);
472  arg2 = pt_get_select_list (parser, query->info.query.q.union_.arg2);
473 
474  if (select_list == NULL)
475  {
476  /* if arg1 or arg2 is null, there need be resolved firstly. */
477  if (arg1 == NULL || arg2 == NULL)
478  {
479  return NULL;
480  }
481 
484 
485  if (cnt1 != cnt2)
486  {
488  return NULL;
489  }
490 
491  select_list = parser_copy_tree_list (parser, arg1);
493  {
494  /* hidden column is included. get rid of it */
495  for (col = select_list; col && col->next; col = next)
496  {
497  next = col->next;
498  if (next->flag.is_hidden_column)
499  {
500  parser_free_tree (parser, next);
501  col->next = NULL;
502  break;
503  }
504  }
505  }
506  }
507 
508  for (col = select_list, attr1 = arg1, attr2 = arg2; col && attr1 && attr2;
509  col = col->next, attr1 = attr1->next, attr2 = attr2->next)
510  {
511  /* preserve the ENUM type as common type between two ENUMs in UNION, DIFFERENCE and INTERSECTION. The ENUM
512  * domains already have been verified and if they are different an error is generated. */
513  if (attr1->type_enum == attr2->type_enum && attr1->type_enum == PT_TYPE_ENUMERATION)
514  {
515  common_type = PT_TYPE_ENUMERATION;
516  }
517  else
518  {
519  common_type = pt_common_type (attr1->type_enum, attr2->type_enum);
520  }
521 
522  if (pt_is_value_node (col) && (col->type_enum == PT_TYPE_NA || col->type_enum == PT_TYPE_NULL))
523  {
525  }
526 
527  if ((attr2->type_enum == PT_TYPE_NONE) || (attr2->type_enum == PT_TYPE_NA)
528  || (attr2->type_enum == PT_TYPE_NULL))
529  {
530  /* convert type to that of non-null */
531  if (col->type_enum == PT_TYPE_NA && col->alias_print == NULL)
532  {
533  col->alias_print = pt_append_string (parser, NULL, "na");
534  }
535  else if (col->type_enum == PT_TYPE_NULL && col->alias_print == NULL)
536  {
537  col->alias_print = pt_append_string (parser, NULL, "null");
538  }
539  col->type_enum = attr1->type_enum;
540  if (col->data_type)
541  {
542  parser_free_tree (parser, col->data_type);
543  }
544  col->data_type = parser_copy_tree_list (parser, attr1->data_type);
545 
546  }
547  else if ((attr1->type_enum == PT_TYPE_NONE) || (attr1->type_enum == PT_TYPE_NA)
548  || (attr1->type_enum == PT_TYPE_NULL))
549  {
550  /* convert type to that of non-null */
551  if (col->type_enum == PT_TYPE_NA && col->alias_print == NULL)
552  {
553  col->alias_print = pt_append_string (parser, NULL, "na");
554  }
555  else if (col->type_enum == PT_TYPE_NULL && col->alias_print == NULL)
556  {
557  col->alias_print = pt_append_string (parser, NULL, "null");
558  }
559  col->type_enum = attr2->type_enum;
560  if (col->data_type)
561  {
562  parser_free_tree (parser, col->data_type);
563  }
564  col->data_type = parser_copy_tree_list (parser, attr2->data_type);
565  }
566  else if (PT_IS_PARAMETERIZED_TYPE (common_type)
567  || (common_type != PT_TYPE_NONE && col->type_enum != common_type))
568  {
569  col->type_enum = common_type;
570 
571  if (col->data_type)
572  {
573  parser_free_tree (parser, col->data_type);
574  col->data_type = NULL;
575  }
576  if (PT_IS_COMPLEX_TYPE (common_type))
577  {
578  col->data_type = parser_copy_tree_list (parser, attr2->data_type);
579  }
580  }
581  }
582 
583  if (select_list != query->info.query.q.union_.select_list)
584  {
585  parser_free_tree (parser, query->info.query.q.union_.select_list);
586  }
587 
588  query->info.query.q.union_.select_list = select_list;
589 
590  return select_list;
591  }
592 }
593 
594 /*
595  * pt_get_from_list () - returns a pointer to query's from list
596  * return:
597  * parser(in): handle to parser used to process & derive query
598  * query(in): abstract syntax tree form of a SELECT expression
599  */
600 static PT_NODE *
602 {
603  if (query == NULL)
604  {
605  return NULL;
606  }
607 
608  switch (query->node_type)
609  {
610  default:
611  return NULL;
612 
613  case PT_SELECT:
614  return query->info.query.q.select.from;
615 
616  case PT_DIFFERENCE:
617  case PT_INTERSECTION:
618  case PT_UNION:
619  return pt_get_from_list (parser, query->info.query.q.union_.arg1);
620  }
621 }
622 
623 static void
625 {
626  PT_NODE *col = NULL;
627  for (col = columns; col != NULL; col = col->next)
628  {
629  pt_fixup_column_type (col);
630  }
631 }
632 
633 /*
634  * pt_get_titles() - creates, initializes, returns DB_QUERY_TYPE describing the
635  * output columns titles of the given query
636  * return: DB_QUERY_TYPE*, a descriptor of query's output columns
637  * parser(in/out): handle to parser used to process & derive query
638  * query(out): abstract syntax tree form of a SELECT expression
639  */
640 
643 {
644  DB_QUERY_TYPE *q, *t, *tail;
645  PT_NODE *s, *f;
646 
647  s = pt_get_select_list (parser, query);
649  {
650  return NULL;
651  }
652  f = pt_get_from_list (parser, query);
653 
654  for (q = NULL, tail = NULL; s; s = s->next)
655  {
656  if (s->flag.is_hidden_column)
657  {
658  continue;
659  }
660  else
661  {
663  t = pt_get_node_title (parser, s, f);
665 
666  if (t == NULL)
667  {
669  return NULL;
670  }
671 
672  if (q == NULL)
673  {
674  q = t;
675  }
676  else
677  {
678  tail->next = t;
679  }
680 
681  t->next = NULL;
682  tail = t;
683  }
684  }
685 
686  return q;
687 }
688 
689 /*
690  * pt_get_node_title() - allocate and initialize a query_type node.
691  * return: a fully initialized query type node
692  * parser(in/out): handle to parser used to process & derive query
693  * col(in): column to create the query type node from.
694  * from_list(in):
695  *
696  */
697 
698 static DB_QUERY_TYPE *
699 pt_get_node_title (PARSER_CONTEXT * parser, const PT_NODE * col, const PT_NODE * from_list)
700 {
701  DB_QUERY_TYPE *q;
702  char *name;
703  unsigned int save_custom;
704  PT_NODE *node, *spec, *range_var;
705  char *original_name;
706 
707  save_custom = parser->custom_print;
708  parser->custom_print |= PT_SUPPRESS_QUOTES;
709 
710  if ((q = (DB_QUERY_TYPE *) malloc (DB_SIZEOF (DB_QUERY_TYPE))) == NULL)
711  {
712  goto error;
713  }
715  q->next = NULL;
716  q->db_type = DB_TYPE_NULL;
717  q->size = 0;
718 
719  if (pt_resolved (col))
720  {
722  }
723 
724  original_name = name = pt_print_alias (parser, col);
725 
726  if (col->alias_print == NULL)
727  {
728  switch (col->node_type)
729  {
730  case PT_NAME:
731  if (pt_resolved (col))
732  {
733  if (col->info.name.meta_class == PT_META_ATTR)
734  {
735  name =
736  pt_append_string (parser, pt_append_string (parser, (char *) col->info.name.resolved, "."), name);
737  name = pt_append_string (parser, pt_append_string (parser, NULL, "class "), name);
738  original_name = name;
739  }
741  {
742  /* PT_NAME comes from PT_DOT_ */
743  original_name =
744  pt_append_string (parser, pt_append_string (parser, (char *) col->info.name.resolved, "."),
745  original_name);
746  }
748  {
749  /* PT_NAME comes from classname.* */
750  original_name = NULL;
751  }
753  {
754  /* PT_NAME comes from * */
755  original_name = NULL;
756  }
757  }
758  break;
759  case PT_DOT_:
760 
761  /* traverse left node */
762  node = (PT_NODE *) col;
763  while (node && node->node_type == PT_DOT_)
764  {
765  node = node->info.dot.arg1;
766  }
767 
768  if (node && node->node_type == PT_NAME)
769  {
770  if (pt_resolved (col))
771  {
772  if (node->info.name.meta_class == PT_META_ATTR)
773  {
774  name =
775  pt_append_string (parser, pt_append_string (parser, (char *) node->info.name.resolved, "."),
776  name);
777  name = pt_append_string (parser, pt_append_string (parser, NULL, "class "), name);
778  original_name = name;
779  }
781  {
782  /* PT_NAME comes from PT_DOT_ */
783  original_name =
784  pt_append_string (parser, pt_append_string (parser, (char *) node->info.name.resolved, "."),
785  original_name);
786  }
787  }
788  else if (node->info.name.meta_class == PT_NORMAL)
789  {
790  /* check for classname */
791  for (spec = (PT_NODE *) from_list; spec; spec = spec->next)
792  {
793  /* get spec's range variable if range variable for spec is used, use range_var. otherwise, use
794  * entity_name */
795  range_var = spec->info.spec.range_var ? spec->info.spec.range_var : spec->info.spec.entity_name;
796 
797  if (pt_check_path_eq (parser, range_var, node) == 0)
798  {
799 
800 
801  if (original_name)
802  {
803  /* strip off classname.* */
804  name = strchr (original_name, '.');
805  if (name == NULL || name[0] == '\0')
806  {
807  name = original_name;
808  }
809  else
810  {
811  name++;
812  }
813  break;
814  }
815  else
816  {
817  name = NULL;
818  }
819 
820  }
821  }
822  }
823  }
824  break;
825  default:
826  break;
827  }
828  }
829 
830  if (name)
831  {
832  q->name = strdup (name);
833  if (q->name == NULL)
834  {
835  goto error;
836  }
837  }
838  else
839  {
840  q->name = NULL;
841  }
842 
843  if (original_name)
844  {
845  q->original_name = strdup (original_name);
846  if (q->original_name == NULL)
847  {
848  if (q->name)
849  {
850  free_and_init (q->name);
851  }
852 
853  goto error;
854  }
855  }
856  else
857  {
858  /* PT_NAME comes from classname.* or * */
859  q->original_name = NULL;
860  }
861 
862  q->attr_name = pt_get_attr_name (parser, (PT_NODE *) col);
863  q->spec_name = NULL; /* fill it at pt_fillin_type_size() */
864 
865  /* At this time before query compilation, we cannot differentiate qualified attribute name(DB_COL_NAME) from path
866  * expression(DB_COL_PATH). */
867  q->col_type = pt_get_col_type (parser, col);
868  q->domain = NULL;
869  q->src_domain = NULL;
870 
871  parser->custom_print = save_custom;
872  return q;
873 
874 error:
875  parser->custom_print = save_custom;
876  if (q)
877  free_and_init (q);
878  return NULL;
879 } /* pt_get_node_title */
880 
881 
882 /*
883  * pt_fillin_type_size() - set the db_type&size fields of a DB_QUERY_TYPE list
884  * return: list, a fully initialized descriptor of query's output columns
885  * parser(in): handle to parser used to process & derive query
886  * query(out): abstract syntax tree form of a SELECT expression
887  * list(in/out): a partially initialized DB_QUERY_TYPE list
888  * oids_included(in):
889  * fixup_columns_type(in): whether fixup column type
890  */
891 
893 pt_fillin_type_size (PARSER_CONTEXT * parser, PT_NODE * query, DB_QUERY_TYPE * list, const int oids_included,
894  bool want_spec_entity_name, bool fixup_columns_type)
895 {
896  DB_QUERY_TYPE *q, *t;
897  PT_NODE *s, *from_list;
898  const char *spec_name;
899  PT_NODE *node, *spec;
900  UINTPTR spec_id;
901  char *original_name;
902 
903  s = pt_get_select_list (parser, query);
904  if (s == NULL || list == NULL)
905  {
906  return list;
907  }
908 
909  if (fixup_columns_type)
910  {
911  /* fixup the columns of union statement */
913  }
914  from_list = pt_get_from_list (parser, query);
915  /* from_list is allowed to be NULL for supporting SELECT without references to tables */
916 
917  if (oids_included == 1)
918  {
919  /*
920  * prepend single oid column onto the type list
921  * the first node of the select list will be the oid column.
922  */
923  q = pt_get_node_title (parser, s, from_list);
924 
925  if (q == NULL)
926  {
927  db_free_query_format (list);
928  return NULL;
929  }
930  q->visible_type = OID_COLUMN; /* oid columns are NOT user visible */
931  q->next = list;
932  list = q;
933  }
934 
936  {
937  PT_INTERNAL_ERROR (parser, "query result");
938  return list;
939  }
940 
941  for (t = list; s && t; s = s->next, t = t->next)
942  {
943  t->col_type = pt_get_col_type (parser, s);
944  t->db_type = pt_type_enum_to_db (s->type_enum);
945  t->size = pt_find_size_from_dbtype (t->db_type);
946  t->domain = pt_xasl_node_to_domain (parser, s);
947  t->src_domain = pt_get_src_domain (parser, s, from_list);
948 
949  spec_name = NULL;
950  /* if it is attribute, find spec name */
951  if (pt_is_attr (s))
952  {
953  node = s;
954  while (node->node_type == PT_DOT_)
955  {
956  node = node->info.dot.arg1; /* root node for path expression */
957  }
958  if (node->node_type == PT_NAME && (spec_id = node->info.name.spec_id)
959  && (spec = pt_find_entity (parser, from_list, spec_id)))
960  {
961  if (want_spec_entity_name == true && spec->info.spec.entity_name)
962  {
963  spec_name = spec->info.spec.entity_name->info.name.original;
964  }
965  else if (want_spec_entity_name == false && spec->info.spec.range_var)
966  {
967  spec_name = spec->info.spec.range_var->info.name.original;
968  }
969  }
970  }
971  /* if it is method, find spec name */
972  if (pt_is_method_call (s))
973  {
974  node = s;
975  while (node->node_type == PT_DOT_)
976  {
977  node = node->info.dot.arg2; /* leaf node for qualified method */
978  }
979  node = node->info.method_call.method_name;
980  if (node->node_type == PT_NAME && (spec_id = node->info.name.spec_id)
981  && (spec = pt_find_entity (parser, from_list, spec_id)))
982  {
983  if (want_spec_entity_name == true && spec->info.spec.entity_name)
984  {
985  spec_name = spec->info.spec.entity_name->info.name.original;
986  }
987  else if (want_spec_entity_name == false && spec->info.spec.range_var)
988  {
989  spec_name = spec->info.spec.range_var->info.name.original;
990  }
991  }
992  }
993 
994  t->spec_name = (spec_name) ? strdup (spec_name) : NULL;
995 
996  if (!t->original_name)
997  {
998  /* PT_NAME comes from classname.* or build original_name( = spec_name.name) */
999  if (pt_length_of_list (from_list) == 1)
1000  {
1001  /* there is only one class spec */
1002  original_name = pt_append_string (parser, NULL, t->name);
1003  t->original_name = (char *) malloc (strlen (original_name) + 1);
1004  }
1005  else
1006  {
1007  /* there are plural class specs */
1008  original_name = pt_append_string (parser, pt_append_string (parser, (char *) t->spec_name, "."), t->name);
1009  t->original_name = (char *) malloc (strlen (original_name) + 1);
1010  }
1011  if (!t->original_name)
1012  {
1013  PT_INTERNAL_ERROR (parser, "insufficient memory");
1014  return list;
1015  }
1016  strcpy ((char *) t->original_name, original_name);
1017  }
1018  }
1019 
1020  return list;
1021 }
1022 
1023 /*
1024  * pt_new_query_result_descriptor() - allocates, initializes, returns a new
1025  * query result descriptor and opens a cursor for the query's results
1026  * return: DB_QUERY_RESULT* with an open cursor
1027  * parser(in): handle to parser used to process & derive query
1028  * query(out): abstract syntax tree (AST) form of a query statement
1029  */
1030 
1033 {
1034  int degree;
1035  DB_QUERY_RESULT *r = NULL;
1036  QFILE_LIST_ID *list_id;
1037  int oids_included = 0;
1038  bool failure = false;
1039 
1040  if (query == NULL)
1041  {
1042  return NULL;
1043  }
1044 
1045  switch (query->node_type)
1046  {
1047  default:
1048  return NULL;
1049  break;
1050 
1051  case PT_EXECUTE_PREPARE:
1052  if (query->info.execute.stmt_type != CUBRID_STMT_SELECT)
1053  {
1054  return NULL;
1055  }
1056  oids_included = query->info.execute.oids_included;
1057  degree = query->info.execute.column_count;
1058  break;
1059 
1060  case PT_INSERT:
1061  oids_included = 0;
1062  degree = 1;
1063  break;
1064 
1065  case PT_DIFFERENCE:
1066  case PT_INTERSECTION:
1067  case PT_UNION:
1068  case PT_SELECT:
1069  oids_included = query->info.query.oids_included;
1070  degree = 0;
1072  break;
1073  }
1074 
1075  r = db_alloc_query_result (T_SELECT, degree);
1076  if (r == NULL)
1077  {
1078  return NULL;
1079  }
1080 
1082  r->type = T_SELECT;
1083  r->col_cnt = degree;
1084 
1085  r->oid_included = oids_included == 1;
1086  r->res.s.query_id = parser->query_id;
1087  r->res.s.stmt_id = 0;
1089  r->res.s.cache_time = query->cache_time;
1090 
1091  /* the following is for clean up when the query fails */
1092  memset (&r->res.s.cursor_id.list_id, 0, sizeof (QFILE_LIST_ID));
1093  r->res.s.cursor_id.query_id = parser->query_id;
1094  r->res.s.cursor_id.buffer = NULL;
1096  r->res.s.holdable = parser->flag.is_holdable;
1097 
1098  list_id = (QFILE_LIST_ID *) query->etc;
1099  r->type_cnt = degree;
1100  if (list_id)
1101  {
1102  failure = !cursor_open (&r->res.s.cursor_id, list_id, false, r->oid_included);
1103  /* free result, which was copied by open cursor operation! */
1104  cursor_free_self_list_id (list_id);
1105  }
1106  else
1107  {
1108  QFILE_LIST_ID empty_list_id;
1109  QFILE_CLEAR_LIST_ID (&empty_list_id);
1110  failure = !cursor_open (&r->res.s.cursor_id, &empty_list_id, false, r->oid_included);
1111  }
1112 
1113  if (failure)
1114  {
1116  r = NULL;
1117  }
1118 
1119  return r;
1120 }
1121 
1122 /*
1123  * pt_make_cache_hit_result_descriptor () -
1124  * return:
1125  */
1128 {
1129  DB_QUERY_RESULT *r;
1130 
1132  if (r == NULL)
1133  {
1134  return NULL;
1135  }
1136 
1138 
1139  return r;
1140 }
1141 
1142 
1143 /*
1144  * pt_free_query_etc_area () -
1145  * return: none
1146  * session(in):
1147  * query(in): abstract syntax tree (AST) form of a query statement
1148  */
1149 void
1151 {
1152  if (query && query->etc
1154  || pt_is_server_insert_with_generated_keys (parser, query)))
1155  {
1156  cursor_free_self_list_id (query->etc);
1157  }
1158 }
1159 
1160 
1161 /*
1162  * pt_end_query() -
1163  * return:
1164  * parser(in): parser context
1165  * query_id_self(in):
1166  */
1167 void
1168 pt_end_query (PARSER_CONTEXT * parser, QUERY_ID query_id_self)
1169 {
1170  assert (parser != NULL);
1171  assert (query_id_self != 0);
1172  assert (query_id_self == NULL_QUERY_ID || query_id_self > 0);
1173 
1174  if (parser->query_id > 0)
1175  {
1177  {
1178  qmgr_end_query (parser->query_id);
1179  }
1180  }
1181  else
1182  {
1183  assert (parser->query_id == 0);
1184  }
1185 
1186  parser->query_id = query_id_self;
1187 }
1188 
1189 
1190 /*
1191  * db_object_describe() - get a DB_QUERY_TYPE descriptor of the named
1192  * attributes of a given object
1193  * return: int (non-zero in case of error)
1194  * obj_mop(in): a DB_OBJECT in the workspace
1195  * num_attrs(in): number of names in attrs array
1196  * attrs(in): an array of null-terminated character strings
1197  * col_spec(out): a new DB_QUERY_TYPE structure
1198  */
1199 int
1200 db_object_describe (DB_OBJECT * obj_mop, int num_attrs, const char **attrs, DB_QUERY_TYPE ** col_spec)
1201 {
1202  DB_QUERY_TYPE *t;
1203  int i, attrid, shared, err = NO_ERROR;
1204  MOP class_mop;
1205  const char **name;
1206  SM_DOMAIN *tmp_dom;
1207 
1209 
1210  if (!col_spec)
1211  {
1213  return -1;
1214  }
1215 
1216  *col_spec = NULL;
1217 
1218  class_mop = WS_CLASS_MOP (obj_mop);
1219  if (class_mop == NULL)
1220  {
1221  return -1;
1222  }
1223 
1224  *col_spec = db_alloc_query_format (num_attrs);
1225  if (*col_spec == NULL)
1226  {
1227  return -1;
1228  }
1229 
1230  for (i = 0, t = *col_spec, name = attrs; i < num_attrs && t && name && err == NO_ERROR; i++, t = t->next, name++)
1231  {
1232  t->db_type = sm_att_type_id (class_mop, *name);
1233  t->size = pt_find_size_from_dbtype (t->db_type);
1234  t->name = (char *) malloc (1 + strlen (*name));
1235  if (t->name)
1236  {
1237  strcpy ((char *) t->name, *name);
1238  }
1239  else
1240  {
1241  db_free_query_format (*col_spec);
1242  *col_spec = NULL;
1243  return -1;
1244  }
1245 
1246  t->attr_name = NULL;
1247  t->src_domain = NULL;
1248  err = sm_att_info (class_mop, *name, &attrid, &tmp_dom, &shared, 0);
1249  t->domain = sm_domain_copy (tmp_dom);
1250  }
1251 
1252  if (err != NO_ERROR)
1253  {
1254  db_free_query_format (*col_spec);
1255  *col_spec = NULL;
1256  return -1;
1257  }
1258 
1259  return 0;
1260 }
1261 
1262 /*
1263  * db_object_fetch() - get the values of the named attributes of the given
1264  * object into a DB_QUERY_RESULT structure
1265  * return: int (non-zero in event of failure)
1266  * obj_mop(in): a DB_OBJECT in the workspace
1267  * num_attrs(in): number of names in attrs array
1268  * attrs(in): an array of null-terminated character strings
1269  * result(out): a new DB_QUERY_RESULT structure
1270  */
1271 
1272 int
1273 db_object_fetch (DB_OBJECT * obj_mop, int num_attrs, const char **attrs, DB_QUERY_RESULT ** result)
1274 {
1275  MOP class_mop;
1276  DB_QUERY_RESULT *r;
1277  DB_QUERY_TYPE *t;
1278  int k;
1279  const char **name;
1280  int err = NO_ERROR;
1281  DB_VALUE **v;
1282  bool r_inited = false;
1283 
1285 
1286  if (!result)
1287  {
1289  return -1;
1290  }
1291 
1292  *result = NULL;
1293  class_mop = sm_get_class (obj_mop);
1294  if (class_mop == NULL)
1295  {
1296  goto err_end;
1297  }
1298 
1299  r = *result = db_alloc_query_result (T_OBJFETCH, num_attrs);
1300  if (r == NULL)
1301  {
1302  goto err_end;
1303  }
1304  r_inited = true;
1305 
1307  r->type = T_OBJFETCH;
1308  r->col_cnt = num_attrs;
1309  r->oid_included = false;
1310 
1311  /* allocate and initialize type list */
1312  r->type_cnt = num_attrs;
1313  r->query_type = db_alloc_query_format (num_attrs);
1314  if (!r->query_type)
1315  {
1316  goto err_end;
1317  }
1318 
1319  r->res.o.crs_pos = C_BEFORE;
1320  for (k = 0, t = r->query_type, name = attrs, v = r->res.o.valptr_list;
1321  k < num_attrs && t && name && v && err == NO_ERROR; k++, t = t->next, name++, v++)
1322  {
1323  t->db_type = sm_att_type_id (class_mop, *name);
1325  t->name = (char *) malloc (1 + strlen (*name));
1326  if (t->name)
1327  {
1328  strcpy ((char *) t->name, *name);
1329  }
1330  else
1331  {
1332  goto err_end;
1333  }
1334 
1335  *v = pr_make_ext_value ();
1336  if (*v == NULL)
1337  {
1338  goto err_end;
1339  }
1340 
1341  err = obj_get (obj_mop, *name, *v);
1342  }
1343 
1344  if (err != NO_ERROR)
1345  {
1346  goto err_end;
1347  }
1348 
1349  err = 0;
1350  goto end;
1351 
1352 err_end:
1353  if (r_inited)
1354  {
1356  }
1357  *result = NULL;
1358  err = -1;
1359 
1360 end:
1361  return err;
1362 }
1363 
1364 /*
1365  * db_get_attribute () -
1366  * return:
1367  * obj(in):
1368  * name(in):
1369  */
1370 DB_ATTRIBUTE *
1371 db_get_attribute_force (DB_OBJECT * obj, const char *name)
1372 {
1373  SM_CLASS *class_;
1374  SM_ATTRIBUTE *att;
1375 
1376  att = NULL;
1377  if (au_fetch_class_force (obj, &class_, AU_FETCH_READ) == NO_ERROR)
1378  {
1379  att = classobj_find_attribute (class_, name, 0);
1380  if (att == NULL)
1381  {
1383  }
1384  }
1385 
1386  return ((DB_ATTRIBUTE *) att);
1387 }
1388 
1389 /*
1390  * db_get_attributes_force () -
1391  * return:
1392  * obj(in):
1393  */
1394 DB_ATTRIBUTE *
1396 {
1397  SM_CLASS *class_;
1398  SM_ATTRIBUTE *atts;
1399 
1400  atts = NULL;
1401  if (au_fetch_class_force ((DB_OBJECT *) obj, &class_, AU_FETCH_READ) == NO_ERROR)
1402  {
1403  atts = class_->ordered_attributes;
1404  if (atts == NULL)
1405  {
1407  }
1408  }
1409  return ((DB_ATTRIBUTE *) atts);
1410 }
1411 
1412 
1413 /*
1414  * pt_find_users_class () -
1415  * return: class object if found
1416  * parser(in):
1417  * name(in/out):
1418  */
1419 DB_OBJECT *
1421 {
1422  DB_OBJECT *object;
1423 
1424  object = db_find_class (name->info.name.original);
1425 
1426  if (!object)
1427  {
1429  name->info.name.original);
1430  }
1431  name->info.name.db_object = object;
1432 
1433  pt_check_user_owns_class (parser, name);
1434 
1435  return object;
1436 }
1437 
1438 /*
1439  * pt_is_server_insert_with_generated_keys () - check if an insert statement
1440  * has been executed on the server and it must
1441  * return the autogenerated keys.
1442  * return:
1443  * session(in) :
1444  * statement(in) :
1445  */
1446 int
1448 {
1449  if (statement && statement->node_type == PT_INSERT && parser && parser->flag.return_generated_keys
1451  {
1452  return 1;
1453  }
1454 
1455  return 0;
1456 }
DB_OBJECT * db_find_class(const char *name)
Definition: db_info.c:133
#define pt_is_expr_node(n)
Definition: parse_tree.h:261
#define QFILE_CLEAR_LIST_ID(list_id)
Definition: query_list.h:445
#define ER_LK_UNILATERALLY_ABORTED
Definition: error_code.h:130
PT_NODE * next
Definition: parse_tree.h:3447
PT_NAME_INFO name
Definition: parse_tree.h:3318
COL_VISIBLE_TYPE visible_type
Definition: db_query.h:64
#define NO_ERROR
Definition: error_code.h:46
PT_UNION_INFO union_
Definition: parse_tree.h:2782
SM_DOMAIN * src_domain
Definition: db_query.h:63
DB_QUERY_RESULT * db_alloc_query_result(DB_RESULT_TYPE r_type, int col_cnt)
Definition: db_query.c:868
PT_METHOD_CALL_INFO method_call
Definition: parse_tree.h:3316
void tp_domain_init(TP_DOMAIN *domain, DB_TYPE type_id)
void db_free_query_result(DB_QUERY_RESULT *r)
Definition: db_query.c:727
DB_OBJFETCH_RESULT o
Definition: db_query.h:126
PT_STATEMENT_INFO info
Definition: parse_tree.h:3487
CURSOR_ID cursor_id
Definition: db_query.h:74
void db_init_query_result(DB_QUERY_RESULT *r, DB_RESULT_TYPE r_type)
Definition: db_query.c:1011
int db_object_describe(DB_OBJECT *obj_mop, int num_attrs, const char **attrs, DB_QUERY_TYPE **col_spec)
int qmgr_end_query(QUERY_ID query_id)
static DB_QUERY_TYPE * pt_get_node_title(PARSER_CONTEXT *parser, const PT_NODE *col, const PT_NODE *from_list)
Definition: query_result.c:699
DB_TYPE
Definition: dbtype_def.h:670
#define pt_is_oid_name(n)
Definition: parse_tree.h:265
DB_TYPE db_type
Definition: db_query.h:60
DB_QUERY_TYPE * pt_get_titles(PARSER_CONTEXT *parser, PT_NODE *query)
Definition: query_result.c:642
PT_SPEC_INFO spec
Definition: parse_tree.h:3346
#define ER_IS_LOCK_TIMEOUT_ERROR(err)
PT_NODE * arg2
Definition: parse_tree.h:2664
#define PT_NODE_PRINT_TO_ALIAS(p, n, c)
Definition: parse_tree.h:578
char * original_name
Definition: db_query.h:59
enum pt_type_enum PT_TYPE_ENUM
Definition: parse_tree.h:962
int db_object_fetch(DB_OBJECT *obj_mop, int num_attrs, const char **attrs, DB_QUERY_RESULT **result)
#define ER_OBJ_NO_COMPONENTS
Definition: error_code.h:297
PT_MISC_TYPE meta_class
Definition: parse_tree.h:2552
PT_NODE * pt_get_end_path_node(PT_NODE *node)
PT_EXECUTE_INFO execute
Definition: parse_tree.h:3297
union pt_query_info::@124 q
bool tran_was_latest_query_ended(void)
#define cursor_free_self_list_id(list_id)
Definition: cursor.h:108
unsigned int custom_print
Definition: parse_tree.h:3556
SM_ATTRIBUTE * classobj_find_attribute(SM_CLASS *class_, const char *name, int class_attribute)
void pt_fixup_column_type(PT_NODE *col)
PT_ERROR_TYPE
Definition: parse_tree.h:1503
CACHE_TIME cache_time
Definition: db_query.h:75
int er_errid(void)
static char * pt_get_attr_name(PARSER_CONTEXT *parser, PT_NODE *node)
Definition: query_result.c:110
#define PT_NAME_INFO_IS_FLAGED(e, f)
Definition: parse_tree.h:2574
PT_NODE_LIST_INFO node_list
Definition: parse_tree.h:3320
DB_OBJECT * virt_object
Definition: parse_tree.h:2548
PT_NODE * data_type
Definition: parse_tree.h:3453
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
Definition: oid.h:63
struct parser_context::@134 flag
#define pt_is_dot_node(n)
Definition: parse_tree.h:260
PT_DOT_INFO dot
Definition: parse_tree.h:3287
PT_NODE * arg2
Definition: parse_tree.h:2086
TP_DOMAIN * pt_xasl_node_to_domain(PARSER_CONTEXT *parser, const PT_NODE *node)
SERVER_INSERT_ALLOWED server_allowed
Definition: parse_tree.h:2347
PT_TYPE_ENUM type_enum
Definition: parse_tree.h:3457
DB_TYPE pt_type_enum_to_db(const PT_TYPE_ENUM t)
Definition: parse_dbi.c:2314
#define ER_PT_SEMANTIC
Definition: error_code.h:581
char oids_included
Definition: parse_tree.h:2750
static DB_COL_TYPE pt_get_col_type(const PARSER_CONTEXT *parser, const PT_NODE *node)
Definition: query_result.c:146
PR_TYPE * pr_type_from_id(DB_TYPE id)
PT_NODE * arg1
Definition: parse_tree.h:2663
#define WS_CLASS_MOP(mop)
Definition: work_space.h:296
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int pr_mem_size(const PR_TYPE *type)
DB_SELECT_RESULT s
Definition: db_query.h:124
static void pt_set_domain_class(SM_DOMAIN *dom, const PT_NODE *nam, const DB_OBJECT *virt)
Definition: query_result.c:183
DB_OBJECT * db_object
Definition: parse_tree.h:2546
#define PT_ERRORmf2(parser, node, setNo, msgNo, arg1, arg2)
Definition: parse_tree.h:65
#define assert(x)
static int pt_arity_of_query_type(const DB_QUERY_TYPE *qt)
Definition: query_result.c:89
DB_COL_TYPE
Definition: dbtype_def.h:269
DB_QUERY_TYPE * query_type
Definition: db_query.h:119
char * spec_name
Definition: db_query.h:58
DB_VALUE db_value
Definition: parse_tree.h:3059
void pt_report_to_ersys_with_statement(PARSER_CONTEXT *parser, const PT_ERROR_TYPE error_type, PT_NODE *statement)
Definition: query_result.c:338
DB_VALUE ** valptr_list
Definition: db_query.h:88
char * name
Definition: db_query.h:56
PT_NODE * flat_entity_list
Definition: parse_tree.h:2140
#define ER_PT_SYNTAX
Definition: error_code.h:580
PT_NODE * method_name
Definition: parse_tree.h:2363
const char * original
Definition: parse_tree.h:2544
#define PT_IS_PARAMETERIZED_TYPE(t)
Definition: parse_tree.h:229
#define PT_NAME_INFO_STAR
Definition: parse_tree.h:2560
char * pt_print_alias(PARSER_CONTEXT *parser, const PT_NODE *node)
#define PT_NAME_INFO_DOT_STAR
Definition: parse_tree.h:2561
SM_DOMAIN * domain
Definition: db_query.h:62
PT_NODE_TYPE node_type
Definition: parse_tree.h:3439
DB_QUERY_RESULT * pt_make_cache_hit_result_descriptor(void)
CURSOR_POSITION crs_pos
Definition: db_query.h:87
DB_OBJECT * pt_find_users_class(PARSER_CONTEXT *parser, PT_NODE *name)
char * attr_name
Definition: db_query.h:57
PT_NODE * from
Definition: parse_tree.h:2686
VID_OID oid_info
Definition: work_space.h:120
UINTPTR spec_id
Definition: parse_tree.h:2543
QUERY_ID query_id
Definition: cursor.h:54
bool oid_included
Definition: db_query.h:118
#define DB_SIZEOF(val)
Definition: memory_alloc.h:54
struct db_query_type * next
Definition: db_query.h:54
SP_PARSER_CTX * parser
PT_NODE * pt_find_entity(PARSER_CONTEXT *parser, const PT_NODE *scope, UINTPTR id)
#define NULL
Definition: freelistheap.h:34
OID oid
Definition: work_space.h:65
struct pr_type * type
Definition: object_domain.h:76
CACHE_TIME cache_time
Definition: parse_tree.h:3458
CUBRID_STMT_TYPE pt_node_to_cmd_type(PT_NODE *node)
Definition: parse_dbi.c:2736
if(extra_options)
Definition: dynamic_load.c:958
DB_VALUE * pr_make_ext_value(void)
char * pt_append_string(const PARSER_CONTEXT *parser, const char *old_string, const char *new_tail)
Definition: parse_tree.c:980
#define err(fd,...)
Definition: porting.h:431
PT_ZZ_ERROR_MSG_INFO error_msg
Definition: parse_tree.h:3267
#define MSGCAT_SEMANTIC_CLASS_DOES_NOT_EXIST
int pt_is_server_insert_with_generated_keys(PARSER_CONTEXT *parser, PT_NODE *statement)
#define ER_OBJ_INVALID_ATTRIBUTE
Definition: error_code.h:273
int pt_check_path_eq(PARSER_CONTEXT *parser, const PT_NODE *p, const PT_NODE *q)
PT_NODE * select_list
Definition: parse_tree.h:2665
PT_NODE * arg1
Definition: parse_tree.h:2085
PT_QUERY_INFO query
Definition: parse_tree.h:3325
DB_QUERY_TYPE * db_alloc_query_format(int cnt)
Definition: db_query.c:807
unsigned is_holdable
Definition: parse_tree.h:3615
void db_free_query_format(DB_QUERY_TYPE *q)
Definition: db_query.c:154
static SM_DOMAIN * pt_get_src_domain(PARSER_CONTEXT *parser, const PT_NODE *s, const PT_NODE *specs)
Definition: query_result.c:247
#define ER_PT_EXECUTE
Definition: error_code.h:582
int pt_resolved(const PT_NODE *expr)
DB_TYPE sm_att_type_id(MOP classop, const char *name)
#define pt_is_value_node(n)
Definition: parse_tree.h:266
SM_DOMAIN * sm_domain_alloc()
static void error(const char *msg)
Definition: gencat.c:331
int sm_att_info(MOP classop, const char *name, int *idp, TP_DOMAIN **domainp, int *sharedp, int class_attr)
static void pt_fixup_select_columns_type(PT_NODE *columns)
Definition: query_result.c:624
#define ARG_FILE_LINE
Definition: error_manager.h:44
char * buffer
Definition: cursor.h:66
static PT_NODE * pt_get_from_list(const PARSER_CONTEXT *parser, const PT_NODE *query)
Definition: query_result.c:601
void parser_free_tree(PARSER_CONTEXT *parser, PT_NODE *tree)
void pt_free_query_etc_area(PARSER_CONTEXT *parser, PT_NODE *query)
QUERY_ID query_id
Definition: db_query.h:71
#define MSGCAT_SET_PARSER_SEMANTIC
QFILE_TUPLE_RECORD tuple_record
Definition: cursor.h:65
#define pt_is_name_node(n)
Definition: parse_tree.h:264
DB_COL_TYPE col_type
Definition: db_query.h:55
void pt_end_query(PARSER_CONTEXT *parser, QUERY_ID query_id_self)
#define free_and_init(ptr)
Definition: memory_alloc.h:147
#define PT_IS_COMPLEX_TYPE(t)
Definition: parse_tree.h:174
#define strlen(s1)
Definition: intl_support.c:43
DB_OBJECT * pt_check_user_owns_class(PARSER_CONTEXT *parser, PT_NODE *cls_ref)
#define ER_OBJ_INVALID_ARGUMENTS
Definition: error_code.h:275
DB_QUERY_TYPE * pt_fillin_type_size(PARSER_CONTEXT *parser, PT_NODE *query, DB_QUERY_TYPE *list, const int oids_included, bool want_spec_entity_name, bool fixup_columns_type)
Definition: query_result.c:893
static void pt_set_domain_class_list(SM_DOMAIN *dom, const PT_NODE *nam, const DB_OBJECT *virt)
Definition: query_result.c:219
DB_ATTRIBUTE * db_get_attributes_force(DB_OBJECT *obj)
int pt_is_attr(PT_NODE *node)
PT_TYPE_ENUM pt_common_type(PT_TYPE_ENUM arg1_type, PT_TYPE_ENUM arg2_type)
static int pt_find_size_from_dbtype(const DB_TYPE T_type)
Definition: query_result.c:64
DB_RESULT_TYPE type
Definition: db_query.h:115
void * etc
Definition: parse_tree.h:3450
PT_NODE * error_msgs
Definition: parse_tree.h:3550
char * parser_print_tree(PARSER_CONTEXT *parser, const PT_NODE *node)
#define MSGCAT_SEMANTIC_ARITY_MISMATCH
int i
Definition: dynamic_load.c:954
PT_VALUE_INFO value
Definition: parse_tree.h:3358
int pt_length_of_select_list(PT_NODE *list, int hidden_col)
int db_make_null(DB_VALUE *value)
PT_NODE * list
Definition: parse_tree.h:2685
MOP sm_get_class(MOP obj)
struct tp_domain * next
Definition: object_domain.h:74
QFILE_LIST_ID list_id
Definition: cursor.h:55
int obj_get(MOP op, const char *name, DB_VALUE *value)
char * strdup(const char *str)
Definition: porting.c:901
#define pt_is_function(n)
Definition: parse_tree.h:262
unsigned return_generated_keys
Definition: parse_tree.h:3622
#define PT_INTERNAL_ERROR(parser, what)
Definition: parse_tree.h:112
#define ER_IS_SERVER_DOWN_ERROR(err)
struct db_object * class_mop
Definition: object_domain.h:81
const char * alias_print
Definition: parse_tree.h:3455
const char * resolved
Definition: parse_tree.h:2545
void pt_report_to_ersys(const PARSER_CONTEXT *parser, const PT_ERROR_TYPE error_type)
Definition: query_result.c:287
SM_ATTRIBUTE * ordered_attributes
Definition: class_object.h:753
int pt_is_method_call(PT_NODE *node)
int pt_length_of_list(const PT_NODE *list)
CUBRID_STMT_TYPE stmt_type
Definition: parse_tree.h:3166
struct parser_node::@132 flag
PT_NODE * entity_name
Definition: parse_tree.h:2130
PT_SELECT_INFO select
Definition: parse_tree.h:2781
bool cursor_open(CURSOR_ID *cursor_id_p, QFILE_LIST_ID *list_id_p, bool updatable, bool is_oid_included)
Definition: cursor.c:1194
PT_INSERT_INFO insert
Definition: parse_tree.h:3309
#define PT_NAME_INFO_DOT_NAME
Definition: parse_tree.h:2559
PT_NODE * parser_copy_tree_list(PARSER_CONTEXT *parser, PT_NODE *tree)
QUERY_ID query_id
Definition: parse_tree.h:3559
int au_fetch_class_force(MOP op, SM_CLASS **class_, AU_FETCHMODE fetchmode)
DB_QUERY_RESULT * pt_new_query_result_descriptor(PARSER_CONTEXT *parser, PT_NODE *query)
#define PT_ERRORmf(parser, node, setNo, msgNo, arg1)
Definition: parse_tree.h:64
unsigned is_hidden_column
Definition: parse_tree.h:3470
PT_NODE * pt_get_select_list(PARSER_CONTEXT *parser, PT_NODE *query)
Definition: query_result.c:404
#define CHECK_CONNECT_ERROR()
Definition: db.h:88
SM_DOMAIN * sm_domain_copy(SM_DOMAIN *ptr)
union db_query_result::@47 res
PT_NODE * range_var
Definition: parse_tree.h:2135
DB_ATTRIBUTE * db_get_attribute_force(DB_OBJECT *obj, const char *name)