CUBRID Engine  latest
db_info.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  * db_info.c - API functions for accessing database information
21  * and browsing classes.
22  */
23 
24 #ident "$Id$"
25 
26 #include "config.h"
27 
28 #include "authenticate.h"
29 #include "boot_cl.h"
30 #include "class_object.h"
31 #include "db.h"
32 #include "dbtype.h"
33 #include "locator_cl.h"
34 #include "mem_block.hpp"
35 #include "network_interface_cl.h"
36 #include "object_accessor.h"
37 #include "object_primitive.h"
38 #include "object_print.h"
39 #include "object_printer.hpp"
40 #include "parser.h"
41 #include "schema_manager.h"
42 #include "schema_template.h"
43 #include "server_interface.h"
44 #include "set_object.h"
45 #include "storage_common.h"
46 #include "string_buffer.hpp"
47 #include "system_parameter.h"
48 #include "virtual_object.h"
49 
50 #include <assert.h>
51 #include <ctype.h>
52 #include <stdarg.h>
53 #include <stdio.h>
54 #include <stdlib.h>
55 
56 /*
57  * CLASS LOCATION
58  */
59 
60 /*
61  * db_find_class_of_index() - Find the name of the class that has a given
62  * index (specified by its name and type)
63  * return: class object or NULL on error
64  * index_name(in):
65  * index_type(in):
66  *
67  * note:
68  * Only constraint types that satisfy the DB_IS_CONSTRAINT_INDEX_FAMILY
69  * condition will be searched for.
70  * If several indexes with the same name and type are found, NULL is
71  * returned.
72  */
73 DB_OBJECT *
74 db_find_class_of_index (const char *const index_name, const DB_CONSTRAINT_TYPE index_type)
75 {
76  DB_OBJLIST *clslist = NULL;
77  SM_CLASS *smcls = NULL;
78  DB_OBJECT *retval = NULL;
79  int found = 0;
81 
83  CHECK_1ARG_NULL (index_name);
84 
85  if (!DB_IS_CONSTRAINT_INDEX_FAMILY (index_type))
86  {
88  goto end;
89  }
90 
91  for (found = 0, clslist = db_fetch_all_classes (DB_FETCH_READ); clslist != NULL; clslist = clslist->next)
92  {
93  if (au_fetch_class (clslist->op, &smcls, AU_FETCH_READ, AU_SELECT) != NO_ERROR)
94  {
95  retval = NULL;
96  goto end;
97  }
98 
99  if (classobj_find_class_constraint (smcls->constraints, smtype, index_name))
100  {
101  retval = clslist->op;
102  found++;
103  }
104 
105  if (found > 1)
106  {
107  break;
108  }
109  }
110  if (found == 0)
111  {
113  retval = NULL;
114  }
115  else if (found > 1)
116  {
118  retval = NULL;
119  }
120 
121  /* TODO should the list returned by db_fetch_all_classes be freed? */
122 end:
123  return retval;
124 }
125 
126 /*
127  * db_find_class()- This function searchs for a class in the database with a
128  * given name
129  * return : class object
130  * name(in): class name
131  */
132 DB_OBJECT *
133 db_find_class (const char *name)
134 {
135  DB_OBJECT *retval;
136 
138  CHECK_1ARG_NULL (name);
139 
140  retval = sm_find_class (name);
141 
142  return retval;
143 }
144 
145 /*
146  * db_find_class_with_purpose()- This function search for a class in the database
147  * with a given name
148  * return : class object
149  * name(in): class name
150  * for_update(in): true, if search the class for update purpose
151  */
152 DB_OBJECT *
153 db_find_class_with_purpose (const char *name, bool for_update)
154 {
155  DB_OBJECT *retval;
156 
158  CHECK_1ARG_NULL (name);
159 
160  retval = sm_find_class_with_purpose (name, for_update);
161 
162  return retval;
163 }
164 
165 /*
166  * db_fetch_all_objects() - This function fetches all objects fo given class
167  * for given purpose.
168  * return : list of objects
169  * op(in): class
170  * purpose(in): Fetch purpose
171  *
172  * note : This function was intended to support very early development,
173  * it should not be used in normal circumstances. This function could
174  * potentially bring in extremely large numbers of objects resulting in
175  * workspace overflow.
176  */
177 DB_OBJLIST *
179 {
180  DB_OBJLIST *retval;
181 
183  CHECK_1ARG_NULL (op);
184 
185  purpose =
186  ((purpose == DB_FETCH_READ) ? DB_FETCH_QUERY_READ : ((purpose == DB_FETCH_WRITE) ? DB_FETCH_QUERY_WRITE : purpose));
187 
188  /* This always allocates an external mop list ! */
189  retval = sm_fetch_all_objects (op, purpose);
190 
191  return retval;
192 }
193 
194 /*
195  * db_fetch_all_classes() - This function fetches all classes for given purpose
196  * return : an object list
197  * purpose(in): Fetch purpose
198  *
199  * Note: Authorization checking is not performed at this level so there may be
200  * MOPs in the list that you can't actually access.
201  */
202 DB_OBJLIST *
204 {
205  DB_OBJLIST *retval;
206 
208 
209  /* return external list of class MOPs */
210  retval = sm_fetch_all_classes (1, purpose);
211 
212  return retval;
213 }
214 
215 /*
216  * db_fetch_base_classes: This returns the list of classes
217  * that have no super classes.
218  * return : an object list
219  * purpose(in): Fetch purpose
220  *
221  */
222 DB_OBJLIST *
224 {
225  DB_OBJLIST *retval;
226 
228 
229  retval = sm_fetch_all_base_classes (1, purpose);
230 
231  return retval;
232 }
233 
234 /*
235  * db_get_all_objects() - This function fetches a list of all of the instances
236  * of a given class
237  * return : list of objects
238  * op(in): class
239  *
240  * note : This function was intended to support very early development,
241  * it should not be used in normal circumstances. This function could
242  * potentially bring in extremely large numbers of objects resulting in
243  * workspace overflow.
244  */
245 DB_OBJLIST *
247 {
248  DB_OBJLIST *retval;
249 
251  CHECK_1ARG_NULL (op);
252 
254 
255  return retval;
256 }
257 
258 /*
259  * db_get_all_classes() - This fetches a list of all of the class objects
260  * currently defined in the database.
261  * return : an object list
262  *
263  * note: Authorization checking is not performed at this level so there
264  * may be MOPs in the list that you can't actually access.
265  */
266 DB_OBJLIST *
268 {
269  DB_OBJLIST *retval;
270 
272 
274 
275  return retval;
276 }
277 
278 /*
279  * db_get_base_classes() - This function fetches the list of classes that have
280  * no super classes.
281  * return : an object list
282  */
283 DB_OBJLIST *
285 {
286  DB_OBJLIST *retval;
287 
289 
291 
292  return retval;
293 }
294 
295 /*
296  * OBJECT PREDICATES
297  */
298 
299 /*
300  * db_is_class() - This function is used to test if a particular object
301  * pointer (MOP) actually is a reference to a class object.
302  * return : < 0 if error, > 0 non-zero if object is a class, 0 otherwise
303  * obj(in): a pointer to a class or instance
304  *
305  * note : If it can be detected that the MOP has been deleted, this will
306  * return zero as well. This means that you can't simply use this to
307  * see if a MOP is an instance or not.
308  */
309 int
311 {
312  SM_CLASS *class_ = NULL;
313  int result = 0;
314 
316 
317  if (obj == NULL)
318  {
319  return 0;
320  }
321  result = locator_is_class (obj, DB_FETCH_READ);
322  if (result < 0)
323  {
324  return result;
325  }
326  if (!result)
327  {
328  return 0;
329  }
330  result = au_fetch_class_force (obj, &class_, AU_FETCH_READ);
331  if (result != NO_ERROR)
332  {
333  return result;
334  }
335 
336  assert (class_ != NULL);
337  if (sm_get_class_type (class_) != SM_CLASS_CT)
338  {
339  return 0;
340  }
341 
342  return 1;
343 }
344 
345 /*
346  * db_is_any_class() - This function is used to test if a particular object
347  * pointer (MOP) actually is a reference to a {class|vclass|view}
348  * object.
349  * return : non-zero if object is a {class|vclass|view}
350  * obj(in): a pointer to a class or instance
351  * note : If it can be detected that the MOP has been deleted, this will return
352  * zero as well. Note that this means that you can't simply use this to see
353  * if a MOP is an instance or not.
354  */
355 int
357 {
358  SM_CLASS *class_ = NULL;
359  int result = 0;
360 
362 
363  if (obj == NULL)
364  {
365  return 0;
366  }
367  result = locator_is_class (obj, DB_FETCH_READ);
368  if (result < 0)
369  {
370  return result;
371  }
372  if (!result)
373  {
374  return 0;
375  }
376  result = au_fetch_class_force (obj, &class_, AU_FETCH_READ);
377  if (result != NO_ERROR)
378  {
379  return result;
380  }
381 
382  assert (class_ != NULL);
383 
384  return 1;
385 }
386 
387 /*
388  * db_is_instance() - This function is used to test if an object MOP
389  * references an instance of a class rather than a class itself.
390  * return : non-zero if object is an instance
391  * obj(in): a pointer to a class or instance
392  */
393 int
395 {
396  int retval;
397 
399 
400  retval = obj_isinstance (obj);
401 
402  return retval;
403 }
404 
405 /*
406  * db_is_instance_of() - This function is used to test if "obj" is an
407  * instance of "class".
408  * return: non-zero if its an instance of the class
409  * obj(in): an instance being tested
410  * class(in): the class we're interested in
411  *
412  * note : For this to be true, the class must be exactly the class the instance
413  * was instantiated from, you cannot use this to see if an instance has
414  * a super class somewhere in its inheritance hierarchy.
415  */
416 int
417 db_is_instance_of (MOP obj, MOP class_)
418 {
419  int status = 0;
420 
422 
423  if (obj != NULL && class_ != NULL)
424  {
425  status = obj_is_instance_of (obj, class_);
426  if (status == -1)
427  {
428  /* access error, convert this to zero */
429  status = 0;
430  }
431  }
432 
433  return status;
434 }
435 
436 /*
437  * db_is_subclass() - This function is used to test if the classmop is a
438  * subclass of the supermop.
439  * return : 1 if classmop is subclass of supermop, 0 if classmop is not
440  * subclass if supermop, negative for errors.
441  * classmop(in): pointer to the class that might be a subclass
442  * supermop(in): pointer to the super class
443  */
444 int
445 db_is_subclass (MOP classmop, MOP supermop)
446 {
447  int retval;
448 
450  CHECK_2ARGS_ZERO (classmop, supermop);
451 
452  retval = sm_is_subclass (classmop, supermop);
453 
454  return retval;
455 }
456 
457 /*
458  * db_is_superclass() - This function is used to test if the supermop is a
459  * superclass of the classmop.
460  * return : 1 if classmop is subclass of supermop, 0 if classmop is not
461  * subclass if supermop, negative for errors.
462  * supermop(in): class pointer
463  * classmop(in): class pointer
464  */
465 int
466 db_is_superclass (MOP supermop, MOP classmop)
467 {
468  int retval;
469 
470  retval = db_is_subclass (classmop, supermop);
471 
472  return retval;
473 }
474 
475 /*
476  * db_is_partition () - This function is used to test if classobj is a
477  * partition of superobj
478  * return : greater than 0 if true, 0 if false, less than 0 for error
479  * classobj (in) : partition candidate
480  * superobj (in) : partitioned class
481  */
482 int
483 db_is_partition (DB_OBJECT * classobj, DB_OBJECT * superobj)
484 {
485  int retval;
486 
488  CHECK_1ARG_MINUSONE (classobj);
489 
490  retval = sm_is_partition (classobj, superobj);
491 
492  return retval;
493 }
494 
495 /*
496  * db_is_system_class() - This function is a convenience function to determine
497  * if a class is one of the system defined classes or a user defined class.
498  * return: true if op is system class
499  * op(in): class pointer
500  */
501 int
503 {
504  int retval;
505 
507  CHECK_1ARG_ZERO (op);
508 
509  retval = sm_is_system_class (op);
510 
511  return retval;
512 }
513 
514 /*
515  * db_is_deleted() - This function is used to determine whether or not the
516  * database object associated with an object handle has been deleted.
517  * return : status code
518  * 0 = The object is not deleted.
519  * >0 = The object is deleted.
520  * <0 = An error was detected, the state of the object is unknown and
521  * an error code is available through db_error_code().
522  * obj(in): object to examine
523  *
524  * note : It performs this test in a more optimal way than db_lock_read() by
525  * avoiding authorization checking, and testing the workspace state before
526  * calling the more expensive fetch & lock function. For speed, we're not
527  * checking for connections unless we have to attempt to fetch the object.
528  *
529  */
530 int
532 {
533  int error;
534 
535  CHECK_1ARG_ERROR (obj);
536 
537  if (WS_IS_DELETED (obj))
538  {
539  return 1;
540  }
541 
542  /* If we have obtained any lock except X_LOCK, that means it is real. However deleted bit is off and to hold X_LOCK
543  * does not guarantee it exists, wever deleted bit is off and to hold X_LOCK does not guarantee it exists, for
544  * instance, trigger action do server-side delete and trigger does not know it. Therefore we need to check it if we
545  * hold X_LOCK on the object. */
546  if (NULL_LOCK < obj->lock && obj->lock < X_LOCK)
547  {
548  return 0;
549  }
550 
551  /* couldn't figure it out from the MOP hints, we'll have to try fetching it, note that we're acquiring a read lock
552  * here, this may be bad if we really intend to update the object. */
553  error = obj_lock (obj, 0);
554 
555  if (!error)
556  {
557  return 0;
558  }
559 
560  /* if this is the deleted object error, then its deleted, the test for the MOP deleted flag should be unnecessary but
561  * be safe. */
562  if (error == ER_HEAP_UNKNOWN_OBJECT || WS_IS_DELETED (obj))
563  {
564  return 1;
565  }
566 
567  return error;
568 }
569 
570 /*
571  * CLASS INFORMATION
572  */
573 
574 /*
575  * db_get_class() - When given an object, this function returns the
576  * corresponding class object. This function can be used in cases where
577  * it is not known whether an object is an instance or a class, but in
578  * either case the class is desired. If the object is already a class
579  * object, it is simply returned.
580  * return : a class pointer
581  * obj(in): an instance or class
582  *
583  * note : Unlike most other functions that accept DB_OBJECT as an argument,
584  * this function does not check for select authorization on the class.
585  * Even users without authorization to examine the contents of a class
586  * can get a pointer to the class object by calling this function.
587  */
588 DB_OBJECT *
590 {
591  DB_OBJECT *retval;
592 
594 
595  retval = sm_get_class (obj);
596 
597  return retval;
598 }
599 
600 /*
601  * db_get_class_name() - This function is used to get the name of a class
602  * object and return it as a C string. A NULL is returned if an error
603  * is encountered
604  * return : name of the class
605  * class(in): class object
606  */
607 const char *
609 {
610  const char *retval;
611 
613  CHECK_1ARG_NULL (class_);
614 
615  retval = sm_get_ch_name (class_);
616 
617  return (retval);
618 }
619 
620 /*
621  * db_get_superclasses() - This function returns a list of all of the super
622  * classes defined for a class.
623  * return : an object list
624  * obj(in): a class or instance
625  *
626  * note : This list may be NULL if the class has no super classes.
627  * Only the immediate super classes are returned.
628  */
629 DB_OBJLIST *
631 {
632  DB_OBJLIST *supers;
633  SM_CLASS *class_;
634 
636  CHECK_1ARG_NULL (obj);
637 
638  supers = NULL;
639  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
640  {
641  supers = class_->inheritance;
642  if (supers == NULL)
643  {
645  }
646  }
647 
648 
649  return (supers);
650 }
651 
652 /*
653  * db_get_subclasses() - This function returns a list of the immediate
654  * subclasses of the specified class.
655  * return : an object list
656  * obj(in): class or instance
657  */
658 DB_OBJLIST *
660 {
661  DB_OBJLIST *subs;
662  SM_CLASS *class_;
663 
665  CHECK_1ARG_NULL (obj);
666 
667  subs = NULL;
668  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
669  {
670  subs = class_->users;
671  if (subs == NULL)
672  {
674  }
675  }
676 
677  return (subs);
678 }
679 
680 /*
681  * db_class_has_instance() -
682  * return : an object list
683  * classobj(in): class object
684  */
685 int
687 {
688  DB_OBJLIST *sub_list;
689  int has_instance;
690 
691  sub_list = db_get_subclasses (classobj);
692  if (sub_list)
693  {
694  for (; sub_list; sub_list = sub_list->next)
695  {
696  has_instance = db_class_has_instance (sub_list->op);
697  if (has_instance < 0)
698  {
699  return has_instance;
700  }
701  else if (has_instance > 0)
702  {
703  return 1;
704  }
705  }
706  }
707  else
708  {
709  return heap_has_instance (sm_get_ch_heap (classobj), WS_OID (classobj), 1);
710  }
711 
712  return 0;
713 }
714 
715 /*
716  * db_get_type_name() - This function maps a type identifier constant to a
717  * printable string containing the type name.
718  * return : string containing type name (or NULL if error)
719  * type_id(in): an integer type identifier (DB_TYPE enumeration)
720  */
721 const char *
723 {
724  const char *name = NULL;
725 
726  name = pr_type_name (type_id);
727  if (name == NULL)
728  {
729  name = "unknown primitive type identifier";
730  }
731 
732  return (name);
733 }
734 
735 /*
736  * db_type_from_string() - This function checks a string to determine whether
737  * it matches a type.
738  * return : a type identifier constant
739  * name(in): a type name
740  */
741 DB_TYPE
742 db_type_from_string (const char *name)
743 {
744  DB_TYPE typeid_ = DB_TYPE_UNKNOWN;
745  PR_TYPE *type;
746  DB_DOMAIN *domain = (DB_DOMAIN *) 0;
747 
748  if (name != NULL)
749  {
750  type = pr_find_type (name);
752  {
753  domain = pt_string_to_db_domain (name, NULL);
754  if (domain)
755  {
756  type = domain->type;
757  }
758  }
759  if (type != NULL)
760  {
761  typeid_ = type->id;
762  if (type->id != DB_TYPE_VARIABLE && type->id != DB_TYPE_SUB)
763  {
764  typeid_ = type->id;
765  }
766  }
767  if (domain)
768  {
769  tp_domain_free (domain);
770  }
771  }
772 
773  return (typeid_);
774 }
775 
776 /*
777  * ATTRIBUTE ACCESSORS
778  */
779 
780 /*
781  * db_get_attribute() - This function returns a structure that describes the
782  * definition of an attribute.
783  * return : an attribute descriptor
784  * obj(in): class or instance
785  * name(in): attribute name
786  *
787  * note : returned structure can be examined by using the db_attribute_
788  * functions.
789  */
790 DB_ATTRIBUTE *
791 db_get_attribute (DB_OBJECT * obj, const char *name)
792 {
793  SM_CLASS *class_;
794  SM_ATTRIBUTE *att;
795 
797  CHECK_2ARGS_NULL (obj, name);
798 
799  att = NULL;
800  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
801  {
802  att = classobj_find_attribute (class_, name, 0);
803  if (att == NULL)
804  {
806  }
807  }
808 
809  return ((DB_ATTRIBUTE *) att);
810 }
811 
812 /*
813  * db_get_attribute_by_name() - This function returns a structure that
814  * describes the definition of an attribute.
815  * return : an attribute descriptor
816  * class_name(in): class name
817  * name(in): attribute name
818  *
819  * note : returned structure can be examined by using the db_attribute_
820  * functions.
821  */
822 DB_ATTRIBUTE *
823 db_get_attribute_by_name (const char *class_name, const char *attribute_name)
824 {
825  DB_OBJECT *db_obj = NULL;
826  if (class_name == NULL || attribute_name == NULL)
827  {
828  return NULL;
829  }
830 
831  db_obj = db_find_class (class_name);
832  if (db_obj == NULL)
833  {
834  return NULL;
835  }
836 
837  return db_get_attribute (db_obj, attribute_name);
838 }
839 
840 
841 /*
842  * db_get_shared_attribute() - This function returns a structure that describes
843  * the definition of an shared attribute.
844  * return : attribute descriptor
845  * obj(in): class or instance
846  * name(in): shared attribute name
847  */
848 DB_ATTRIBUTE *
849 db_get_shared_attribute (DB_OBJECT * obj, const char *name)
850 {
851  SM_CLASS *class_;
852  SM_ATTRIBUTE *att;
853 
855  CHECK_2ARGS_NULL (obj, name);
856 
857  att = NULL;
858  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
859  {
860  att = classobj_find_attribute (class_, name, 0);
861  if (att == NULL || att->header.name_space != ID_SHARED_ATTRIBUTE)
862  {
864  }
865  }
866 
867  return ((DB_ATTRIBUTE *) att);
868 }
869 
870 /*
871  * db_get_class_attribute() - This function returns a structure that describes
872  * the definition of an class attribute.
873  * return : attribute descriptor
874  * obj(in): class or instance
875  * name(in): class attribute name
876  */
877 DB_ATTRIBUTE *
878 db_get_class_attribute (DB_OBJECT * obj, const char *name)
879 {
880  SM_CLASS *class_;
881  SM_ATTRIBUTE *att;
882 
884  CHECK_2ARGS_NULL (obj, name);
885 
886  att = NULL;
887  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
888  {
889  att = classobj_find_attribute (class_, name, 1);
890  if (att == NULL)
891  {
893  }
894  }
895 
896  return ((DB_ATTRIBUTE *) att);
897 }
898 
899 /*
900  * db_get_attributes() - This function Returns descriptors for all of the
901  * attributes of a class. The attribute descriptors are maintained in
902  * a linked list so you can iterate through them using the db_attribute_next
903  * function.
904  * return : attribute descriptor (in a list)
905  * obj(in): class or instance
906  */
907 DB_ATTRIBUTE *
909 {
910  SM_CLASS *class_;
911  SM_ATTRIBUTE *atts;
912 
914  CHECK_1ARG_NULL (obj);
915 
916  atts = NULL;
917  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
918  {
919  /* formerly returned the non-shared attribute list */
920  /* atts = class_->attributes; */
921  atts = class_->ordered_attributes;
922  if (atts == NULL)
923  {
925  }
926  }
927 
928  return ((DB_ATTRIBUTE *) atts);
929 }
930 
931 /*
932  * db_get_class_attributes() - This function returns descriptors for all of the
933  * class attribute of a class. The descriptors are maintained on a linked
934  * list so you can iterate through them using the db_attribute_next function
935  * return : attribute descriptor list
936  * obj(in): class or instance
937  */
938 DB_ATTRIBUTE *
940 {
941  SM_CLASS *class_;
942  SM_ATTRIBUTE *atts;
943 
945  CHECK_1ARG_NULL (obj);
946 
947  atts = NULL;
948  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
949  {
950  atts = class_->class_attributes;
951  if (atts == NULL)
952  {
954  }
955  }
956 
957  return ((DB_ATTRIBUTE *) atts);
958 }
959 
960 /*
961  * db_get_ordered_attributes() - This function returns descriptors for the
962  * instance and shared attributes of a class. The attributes are ordered
963  * in definition order.
964  * return : attribute descriptor (in a list)
965  * obj(in): class or instance
966  *
967  * note : To traverse this list, you must use db_attribute_order_next
968  * rather than db_attribute_next.
969  */
970 DB_ATTRIBUTE *
972 {
973  SM_CLASS *class_;
974  SM_ATTRIBUTE *atts;
975 
977  CHECK_1ARG_NULL (obj);
978 
979 
980  atts = NULL;
981  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
982  {
983  atts = class_->ordered_attributes;
984  if (atts == NULL)
985  {
987  }
988  }
989 
990  return ((DB_ATTRIBUTE *) atts);
991 }
992 
993 /*
994  * db_attribute_type() - This function returns the basic type constant
995  * for an attribute.
996  * return : type identifier constant
997  * attribute(in): attribute descriptor
998  */
999 DB_TYPE
1001 {
1002  DB_TYPE type = DB_TYPE_NULL;
1003 
1004  if (attribute != NULL)
1005  {
1006  type = attribute->type->id;
1007  }
1008 
1009  return (type);
1010 }
1011 
1012 /*
1013  * db_attribute_next() - This function is used to iterate through a list of
1014  * attribute descriptors such as that returned from the db_get_attributes()
1015  * function.
1016  * return : attribute descriptor (or NULL if end of list)
1017  * attribute(in): attribute descriptor
1018  */
1019 DB_ATTRIBUTE *
1021 {
1022  DB_ATTRIBUTE *next = NULL;
1023 
1024  if (attribute != NULL)
1025  {
1026  if (attribute->header.name_space == ID_CLASS_ATTRIBUTE)
1027  {
1028  next = (DB_ATTRIBUTE *) attribute->header.next;
1029  }
1030  else
1031  {
1032  next = attribute->order_link;
1033  }
1034  }
1035 
1036  return (next);
1037 }
1038 
1039 /*
1040  * db_attribute_ordered_next() - This function is used to iterate through a
1041  * list of attribute descriptors that was returned by
1042  * db_get_ordered_attributes.
1043  * return : attribute descriptor (or NULL if end of list)
1044  * attribute(in): attribute descriptor
1045  */
1046 DB_ATTRIBUTE *
1048 {
1049  DB_ATTRIBUTE *next = NULL;
1050 
1051  if (attribute != NULL)
1052  {
1053  next = attribute->order_link;
1054  }
1055 
1056  return (next);
1057 }
1058 
1059 /*
1060  * db_attribute_name() - This function gets the name string from an attribute.
1061  * return : C string containing name
1062  * attribute(in): attribute descriptor
1063  */
1064 const char *
1066 {
1067  const char *name = NULL;
1068 
1069  if (attribute != NULL)
1070  {
1071  name = attribute->header.name;
1072  }
1073 
1074  return (name);
1075 }
1076 
1077 /*
1078  * db_attribute_comment() - This function gets the comment string from an attribute.
1079  * return : C string containing comment
1080  * attribute(in): attribute descriptor
1081  */
1082 const char *
1084 {
1085  const char *comment = NULL;
1086 
1087  if (attribute != NULL)
1088  {
1089  comment = attribute->comment;
1090  }
1091 
1092  return (comment);
1093 }
1094 
1095 /*
1096  * db_attribute_length() - This function gets the precision from an
1097  * attribute if any.
1098  * return : precision of attribute
1099  * attribute(in): attribute descriptor
1100  */
1101 int
1103 {
1104  int length = 0;
1105 
1106  if (attribute && attribute->domain)
1107  {
1108  length = attribute->domain->precision;
1109  }
1110 
1111  return (length);
1112 }
1113 
1114 /*
1115  * db_attribute_id() - This function returns the ID for an attribute.
1116  * return : internal attribute identifier
1117  * attribute(in): attribute descriptor
1118  *
1119  * note : The internal attribute identifier is guaranteed to be unique
1120  * for all of the attributes of this class, it has little utility to
1121  * an application program but might be useful for fast searching etc.
1122  */
1123 int
1125 {
1126  int id = -1;
1127 
1128  if (attribute != NULL)
1129  {
1130  id = attribute->id;
1131  }
1132 
1133  return (id);
1134 }
1135 
1136 /*
1137  * db_attribute_order() - This function returns the position of an attribute
1138  * within the attribute list for the class. This list is ordered according
1139  * to the original class definition.
1140  * return : internal attribute identifier
1141  * attribute(in): attribute descriptor
1142  */
1143 int
1145 {
1146  int order = -1;
1147 
1148  if (attribute != NULL)
1149  {
1150  order = attribute->order;
1151  }
1152 
1153  return (order);
1154 }
1155 
1156 /*
1157  * db_attribute_domain() - This function returns the complete domain descriptor
1158  * for an attribute.
1159  * return : domain descriptor
1160  * attribute(in): attribute descriptor
1161  *
1162  * note : The domain information is examined using the db_domain_ functions.
1163  */
1164 DB_DOMAIN *
1166 {
1167  DB_DOMAIN *domain = NULL;
1168 
1169  if (attribute != NULL)
1170  {
1171  domain = attribute->domain;
1172 
1173  /* always filter the domain before returning to the higher levels */
1174  sm_filter_domain (domain, NULL);
1175  }
1176 
1177  return (domain);
1178 }
1179 
1180 /*
1181  * db_attribute_class() - This function returns a pointer to the class that is
1182  * the source of this attribute in the class hierarchy. This can be used to
1183  * see if an attribute was inherited from another class or if it was defined
1184  * against the current class.
1185  * return : a pointer to a class
1186  * attribute(in): an attribute descriptor
1187  */
1188 DB_OBJECT *
1190 {
1191  DB_OBJECT *class_mop = NULL;
1192 
1193  if (attribute != NULL)
1194  {
1195  class_mop = attribute->class_mop;
1196  }
1197 
1198  return (class_mop);
1199 }
1200 
1201 /*
1202  * db_attribute_default() - This function returns the default value of
1203  * an attribute. If the attribute was a shared or class attribute this
1204  * will actually be the current value.
1205  * return : a value container
1206  * attribute(in): attribute descriptor
1207  */
1208 DB_VALUE *
1210 {
1211  DB_VALUE *value = NULL;
1212 
1213  if (attribute != NULL)
1214  {
1215  value = &attribute->default_value.value;
1216  }
1217 
1218  return (value);
1219 }
1220 
1221 /*
1222  * db_attribute_is_unique() - This function tests the status of the UNIQUE
1223  * integrity constraint for an attribute.
1224  * return : non-zero if unique is defined
1225  * attribute(in): attribute descriptor
1226  */
1227 int
1229 {
1230  int status = 0;
1231 
1232  if (attribute != NULL)
1233  {
1234  SM_CONSTRAINT *con;
1235 
1236  for (con = attribute->constraints; con != NULL && !status; con = con->next)
1237  {
1239  {
1240  status = 1;
1241  }
1242  }
1243  }
1244 
1245  return (status);
1246 }
1247 
1248 /*
1249  * db_attribute_is_primary_key() - This function tests the status of the
1250  * PRIMARY KEY integrity constraint for an attribute.
1251  * return : non-zero if primary key is defined
1252  * attribute(in): attribute descriptor
1253  */
1254 int
1256 {
1257  int status = 0;
1258 
1259  if (attribute != NULL)
1260  {
1261  SM_CONSTRAINT *con;
1262 
1263  for (con = attribute->constraints; con != NULL && !status; con = con->next)
1264  {
1265  if (con->type == SM_CONSTRAINT_PRIMARY_KEY)
1266  {
1267  status = 1;
1268  }
1269  }
1270  }
1271 
1272  return (status);
1273 }
1274 
1275 /*
1276  * db_attribute_is_foreign_key() - This function tests the status of the
1277  * FOREIGN KEY integrity constraint for an attribute.
1278  * return : non-zero if foreign key is defined
1279  * attribute(in): attribute descriptor
1280  */
1281 int
1283 {
1284  int status = 0;
1285 
1286  if (attribute != NULL)
1287  {
1288  SM_CONSTRAINT *con;
1289 
1290  for (con = attribute->constraints; con != NULL && !status; con = con->next)
1291  {
1292  if (con->type == SM_CONSTRAINT_FOREIGN_KEY)
1293  {
1294  status = 1;
1295  }
1296  }
1297  }
1298 
1299  return (status);
1300 }
1301 
1302 /*
1303  * db_attribute_is_auto_increment() - This funciton tests if attribute is
1304  * defined as auto increment
1305  * return : non-zero if auto increment is defined.
1306  * attribute(in): attribute descriptor
1307  */
1308 int
1310 {
1311  int status = 0;
1312 
1313  if (attribute != NULL)
1314  {
1315  status = (attribute->flags & SM_ATTFLAG_AUTO_INCREMENT) ? 1 : 0;
1316  }
1317 
1318  return (status);
1319 }
1320 
1321 /*
1322  * db_attribute_is_reverse_unique() - This function tests the status of the
1323  * reverse UNIQUE for an attribute.
1324  * return : non-zero if reverse unique is defined.
1325  * attribute(in): attribute descriptor
1326  */
1327 int
1329 {
1330  int status = 0;
1331 
1332  if (attribute != NULL)
1333  {
1334  SM_CONSTRAINT *con;
1335 
1336  for (con = attribute->constraints; con != NULL && !status; con = con->next)
1337  {
1338  if (con->type == SM_CONSTRAINT_REVERSE_UNIQUE)
1339  {
1340  status = 1;
1341  }
1342  }
1343  }
1344 
1345  return (status);
1346 }
1347 
1348 /*
1349  * db_attribute_is_non_null() - This function tests the status of the NON_NULL
1350  * integrity constraint for an attribute.
1351  * return : non-zero if non_null is defined.
1352  * attribute(in): attribute descriptor
1353  */
1354 int
1356 {
1357  int status = 0;
1358 
1359  if (attribute != NULL)
1360  {
1361  status = attribute->flags & SM_ATTFLAG_NON_NULL;
1362  }
1363 
1364  return (status);
1365 }
1366 
1367 /*
1368  * db_attribute_is_indexed() - This function tests to see if an attribute is
1369  * indexed. Similar to db_is_indexed but works directly off the attribute
1370  * descriptor structure.
1371  * return: non-zero if attribute is indexed
1372  * attributre(in): attribute descriptor
1373  */
1374 int
1376 {
1377  int status = 0;
1378 
1379  if (attribute != NULL)
1380  {
1381  SM_CONSTRAINT *con;
1382 
1383  for (con = attribute->constraints; con != NULL && !status; con = con->next)
1384  {
1386  {
1387  status = 1;
1388  }
1389  }
1390  }
1391 
1392  return (status);
1393 }
1394 
1395 /*
1396  * db_attribute_is_reverse_indexed() - This function tests to see if an attribute is
1397  * reverse_indexed.
1398  * return: non-zero if attribute is indexed
1399  * attributre(in): attribute descriptor
1400  */
1401 int
1403 {
1404  int status = 0;
1405 
1406  if (attribute != NULL)
1407  {
1408  SM_CONSTRAINT *con;
1409 
1410  for (con = attribute->constraints; con != NULL && !status; con = con->next)
1411  {
1413  {
1414  status = 1;
1415  }
1416  }
1417  }
1418 
1419  return (status);
1420 }
1421 
1422 /*
1423  * db_attribute_is_shared() - This function tests to see if an attribute was
1424  * defined as SHARED.
1425  * return: non-zero if shared is defined
1426  * attribute: attribute descriptor
1427  */
1428 int
1430 {
1431  int status = 0;
1432 
1433  if (attribute != NULL)
1434  {
1435  status = attribute->header.name_space == ID_SHARED_ATTRIBUTE;
1436  }
1437 
1438  return (status);
1439 }
1440 
1441 /*
1442  * METHOD ACCESSORS
1443  */
1444 
1445 /*
1446  * db_get_method() - This function returns a method descriptor that contains
1447  * information about the method. The descriptor can be examined using the
1448  * db_method_ functions.
1449  * return : method descriptor
1450  * obj(in): class or instance
1451  * name(in): method name
1452  */
1453 DB_METHOD *
1454 db_get_method (DB_OBJECT * obj, const char *name)
1455 {
1456  SM_CLASS *class_;
1457  SM_METHOD *method;
1458 
1459  CHECK_CONNECT_NULL ();
1460  CHECK_2ARGS_NULL (obj, name);
1461 
1462  method = NULL;
1463  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
1464  {
1465  method = classobj_find_method (class_, name, 0);
1466  if (method == NULL)
1467  {
1469  }
1470  }
1471 
1472  return ((DB_METHOD *) method);
1473 }
1474 
1475 /*
1476  * db_get_class_method() - This function returns a method descriptor for the
1477  * class method that contains information about the method. The descriptor
1478  * can be examined using the db_method_ functions.
1479  * return : method descriptor
1480  * obj(in): class or instance
1481  * name(in): class method name
1482  */
1483 DB_METHOD *
1484 db_get_class_method (DB_OBJECT * obj, const char *name)
1485 {
1486  SM_CLASS *class_;
1487  SM_METHOD *method;
1488 
1489  CHECK_CONNECT_NULL ();
1490  CHECK_2ARGS_NULL (obj, name);
1491 
1492  method = NULL;
1493  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
1494  {
1495  method = classobj_find_method (class_, name, 1);
1496  if (method == NULL)
1497  {
1499  }
1500  }
1501 
1502  return ((DB_METHOD *) method);
1503 }
1504 
1505 /*
1506  * db_get_methods() - This function returns a list of descriptors for all of
1507  * the methods defined for a class. The list can be traversed using the
1508  * db_method_next() function.
1509  * return : method descriptor list
1510  * obj(in): class or instance
1511  */
1512 DB_METHOD *
1514 {
1515  SM_CLASS *class_;
1516  SM_METHOD *methods;
1517 
1518  CHECK_CONNECT_NULL ();
1519  CHECK_1ARG_NULL (obj);
1520 
1521  methods = NULL;
1522  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
1523  {
1524  methods = class_->methods;
1525  if (methods == NULL)
1526  {
1528  }
1529  }
1530 
1531  return ((DB_METHOD *) methods);
1532 }
1533 
1534 /*
1535  * db_get_class_methods() - This function returns a list of descriptors for all
1536  * of the class methods defined for a class. The list can be traversed by
1537  * using the db_method_next() function.
1538  * return : method descriptor list
1539  * obj(in): class or instance
1540  */
1541 DB_METHOD *
1543 {
1544  SM_CLASS *class_;
1545  SM_METHOD *methods;
1546 
1547  CHECK_CONNECT_NULL ();
1548  CHECK_1ARG_NULL (obj);
1549 
1550  methods = NULL;
1551  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
1552  {
1553  methods = class_->class_methods;
1554  if (methods == NULL)
1555  {
1557  }
1558  }
1559 
1560  return ((DB_METHOD *) methods);
1561 }
1562 
1563 /*
1564  * db_method_next() - This function gets the next method descriptor in the list
1565  * return : method descriptor(or NULL if at end of list)
1566  * method(in): method descriptor
1567  */
1568 DB_METHOD *
1570 {
1571  DB_METHOD *next = NULL;
1572 
1573  if (method != NULL)
1574  {
1575  next = (DB_METHOD *) method->header.next;
1576  }
1577 
1578  return (next);
1579 }
1580 
1581 /*
1582  * db_method_name() - This function gets the method name from a descriptor.
1583  * return: method name string
1584  * method(in): method descriptor
1585  */
1586 const char *
1588 {
1589  const char *name = NULL;
1590 
1591  if (method != NULL)
1592  {
1593  name = method->header.name;
1594  }
1595 
1596  return (name);
1597 }
1598 
1599 /*
1600  * db_method_function() - This function gets the function name that
1601  * implements a method.
1602  * return: method function name
1603  * method(in): method descriptor
1604  */
1605 const char *
1607 {
1608  const char *function = NULL;
1609 
1610  if (method != NULL && method->signatures != NULL && method->signatures->function_name != NULL)
1611  {
1612  function = method->signatures->function_name;
1613  }
1614 
1615  return (function);
1616 }
1617 
1618 /*
1619  * db_method_class() - This function gets the class that was the source of this
1620  * method in the class hierarchy. This can be used to determine if a method
1621  * was inherited or defined against the current class.
1622  * return : class pointer
1623  * method(in): method descriptor
1624  */
1625 DB_OBJECT *
1627 {
1628  DB_OBJECT *class_mop = NULL;
1629 
1630  if (method != NULL)
1631  {
1632  class_mop = method->class_mop;
1633  }
1634 
1635  return (class_mop);
1636 }
1637 
1638 /*
1639  * db_method_return_domain() - This function Returns the domain descriptor for
1640  * the return value of a method. This may be NULL if no signature
1641  * information was specified when the method was defined.
1642  * return : domain descriptor list
1643  * method(in): method descriptor
1644  */
1645 DB_DOMAIN *
1647 {
1648  DB_DOMAIN *domain = NULL;
1649 
1650  if (method != NULL && method->signatures != NULL && method->signatures->value != NULL)
1651  {
1652  domain = method->signatures->value->domain;
1653  sm_filter_domain (domain, NULL);
1654  }
1655 
1656  return (domain);
1657 }
1658 
1659 /*
1660  * db_method_arg_domain() - This function returns the domain descriptor for one
1661  * of the method arguments.
1662  * return : domain descriptor list
1663  * method(in): method descriptor
1664  * arg(in): argument index
1665  * note : This is formatted the same way as an attribute domain list and may be
1666  * hierarchical if the domain entries are sets. This list may be NULL if
1667  * there was no signature definition in the original CUBRID definition of
1668  * the method.
1669  */
1670 DB_DOMAIN *
1671 db_method_arg_domain (DB_METHOD * method, int arg)
1672 {
1673  DB_DOMAIN *domain = NULL;
1674  DB_METHARG *marg;
1675 
1676  if (method != NULL && method->signatures != NULL && arg <= method->signatures->num_args)
1677  {
1678  /* argument zero is return value. Note that this behavior eliminates the need for db_method_return_value() */
1679  if (arg == 0)
1680  {
1681  if (method->signatures->value != NULL)
1682  {
1683  domain = method->signatures->value->domain;
1684  sm_filter_domain (domain, NULL);
1685  }
1686  }
1687  else
1688  {
1689  for (marg = method->signatures->args; marg != NULL && domain == NULL; marg = marg->next)
1690  {
1691  if (marg->index == arg)
1692  {
1693  domain = marg->domain;
1694  sm_filter_domain (domain, NULL);
1695  }
1696  }
1697  }
1698  }
1699 
1700  return (domain);
1701 }
1702 
1703 /*
1704  * db_method_arg_count() - This function returns the number of arguments
1705  * defined for a method.
1706  * return : number of arguments defined for a method.
1707  * method(in): method descriptor
1708  */
1709 int
1711 {
1712  int count = 0;
1713 
1714  if (method != NULL && method->signatures != NULL)
1715  {
1716  count = method->signatures->num_args;
1717  }
1718 
1719  return (count);
1720 }
1721 
1722 /*
1723  * CONFLICT RESOLUTION ACCESSORS
1724  */
1725 
1726 /*
1727  * db_get_resolutions() - This function returns a list of all of the
1728  * instance-level resolution descriptors for a class. This list includes
1729  * resolutions for both attributes and methods. The list can be traversed
1730  * with the db_resolution_next() function.
1731  * return: resolution descriptor
1732  * obj(in): class or instance
1733  */
1734 DB_RESOLUTION *
1736 {
1737  SM_RESOLUTION *res;
1738  SM_CLASS *class_;
1739 
1740  CHECK_CONNECT_NULL ();
1741  CHECK_1ARG_NULL (obj);
1742 
1743  res = NULL;
1744  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
1745  {
1746 
1747  res = class_->resolutions;
1748  while (res != NULL && res->name_space == ID_CLASS)
1749  res = res->next;
1750 
1751  if (res == NULL)
1752  {
1754  }
1755  }
1756 
1757  return ((DB_RESOLUTION *) res);
1758 }
1759 
1760 /*
1761  * db_get_class_resolutions() - This function returns a list of all the
1762  * class-level resolution descriptors for a class.
1763  * return : resolution descriptor
1764  * obj(in): class or instance
1765  */
1766 DB_RESOLUTION *
1768 {
1769  SM_RESOLUTION *res;
1770  SM_CLASS *class_;
1771 
1772  CHECK_CONNECT_NULL ();
1773  CHECK_1ARG_NULL (obj);
1774 
1775  res = NULL;
1776  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
1777  {
1778 
1779  res = class_->resolutions;
1780  while (res != NULL && res->name_space != ID_CLASS)
1781  {
1782  res = res->next;
1783  }
1784 
1785  if (res == NULL)
1787  }
1788 
1789  return ((DB_RESOLUTION *) res);
1790 }
1791 
1792 /*
1793  * db_resolution_next() - This function gets the next resolution descriptor in
1794  * the list.
1795  * return : resolution descriptor (or NULL if at end of list)
1796  * resolution(in): resolution descriptor
1797  */
1798 DB_RESOLUTION *
1800 {
1801  DB_RESOLUTION *next = NULL;
1802  SM_NAME_SPACE name_space;
1803 
1804  /* advance to the next resolution of the current type */
1805  if (resolution != NULL)
1806  {
1807  name_space = resolution->name_space;
1808  next = resolution->next;
1809  while (next != NULL && next->name_space != name_space)
1810  next = next->next;
1811  }
1812 
1813  return (next);
1814 }
1815 
1816 /*
1817  * db_resolution_class() - Returns the class that was referenced in
1818  * the resolution definition (through the "inherit from" statement in SQL).
1819  * return : class pointer
1820  * resolution(in) : resolution descriptor
1821  */
1822 DB_OBJECT *
1824 {
1825  DB_OBJECT *class_mop = NULL;
1826 
1827 
1828  if (resolution != NULL)
1829  {
1830  class_mop = resolution->class_mop;
1831  }
1832 
1833  return (class_mop);
1834 }
1835 
1836 /*
1837  * db_resolution_name() - This function returns the name of the attribute or
1838  * method in the resolution definition.
1839  * return : C string
1840  * resolution: resolution descriptor
1841  */
1842 const char *
1844 {
1845  const char *name = NULL;
1846 
1847  if (resolution != NULL)
1848  {
1849  name = resolution->name;
1850  }
1851 
1852  return (name);
1853 }
1854 
1855 /*
1856  * db_resolution_alias() - This function returns the alias name if one was
1857  * defined. The alias name is optional and may be NULL.
1858  * return : C string (or NULL if no alias)
1859  * resolution(in): resolution descriptor
1860  */
1861 const char *
1863 {
1864  const char *alias = NULL;
1865 
1866  if (resolution != NULL)
1867  {
1868  alias = resolution->alias;
1869  }
1870 
1871  return (alias);
1872 }
1873 
1874 /*
1875  * db_resolution_isclass() - This function can be called when you are uncertain
1876  * whether the resolution descriptor in question is an instance- or
1877  * class-level resolution.
1878  * return : non-zero if this is a class level resolution
1879  * resolution(in): resolution descriptor
1880  */
1881 int
1883 {
1884  int isclass = 0;
1885 
1886  if (resolution != NULL && resolution->name_space == ID_CLASS)
1887  {
1888  isclass = 1;
1889  }
1890 
1891  return (isclass);
1892 }
1893 
1894 
1895 /*
1896  * CONSTRAINT ACCESSORS
1897  */
1898 
1899 /*
1900  * db_get_constraints() - This function returns descriptors for all of the
1901  * constraints of a class. The constraint descriptors are maintained in
1902  * a linked list so that you can iterate through them using the
1903  * db_constraint_next() function.
1904  * return : constraint descriptor list (or NULL if the object does not
1905  * contain any constraints)
1906  * obj(in): class or instance
1907  */
1908 DB_CONSTRAINT *
1910 {
1911  SM_CLASS *class_;
1912  SM_CLASS_CONSTRAINT *constraints;
1913 
1914  CHECK_CONNECT_NULL ();
1915  CHECK_1ARG_NULL (obj);
1916 
1917  constraints = NULL;
1918  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
1919  {
1920  constraints = class_->constraints;
1921  if (constraints == NULL)
1922  {
1924  }
1925  }
1926 
1927  return ((DB_CONSTRAINT *) constraints);
1928 }
1929 
1930 
1931 /*
1932  * db_constraint_next() - This function is used to iterate through a list of
1933  * constraint descriptors returned by the db_get_constraint() function.
1934  * return:constraint descriptor (or NULL if end of list)
1935  * constraint(in): constraint descriptor
1936  */
1937 DB_CONSTRAINT *
1939 {
1940  DB_CONSTRAINT *next = NULL;
1941 
1942  if (constraint != NULL)
1943  {
1944  next = constraint->next;
1945  }
1946 
1947  return (next);
1948 }
1949 
1950 /*
1951  * db_constraint_find_primary_key()- This function is used to return primary key constraint
1952  * return : constraint descriptor (or NULL if not found)
1953  * constraint(in): constraint descriptor
1954  */
1955 DB_CONSTRAINT *
1957 {
1958  while (constraint != NULL)
1959  {
1960  if (constraint->type == SM_CONSTRAINT_PRIMARY_KEY)
1961  {
1962  break;
1963  }
1964 
1965  constraint = db_constraint_next (constraint);
1966  }
1967 
1968  return constraint;
1969 }
1970 
1971 
1972 /*
1973  * db_constraint_type()- This function is used to return the type of constraint
1974  * return : internal constraint identifier
1975  * constraint(in): constraint descriptor
1976  */
1978 db_constraint_type (const DB_CONSTRAINT * constraint)
1979 {
1981 
1982  if (constraint != NULL)
1983  {
1984  if (constraint->type == SM_CONSTRAINT_UNIQUE)
1985  {
1986  type = DB_CONSTRAINT_UNIQUE;
1987  }
1988  else if (constraint->type == SM_CONSTRAINT_INDEX)
1989  {
1990  type = DB_CONSTRAINT_INDEX;
1991  }
1992  else if (constraint->type == SM_CONSTRAINT_NOT_NULL)
1993  {
1994  type = DB_CONSTRAINT_NOT_NULL;
1995  }
1996  else if (constraint->type == SM_CONSTRAINT_REVERSE_UNIQUE)
1997  {
1999  }
2000  else if (constraint->type == SM_CONSTRAINT_REVERSE_INDEX)
2001  {
2003  }
2004  else if (constraint->type == SM_CONSTRAINT_PRIMARY_KEY)
2005  {
2007  {
2008  type = DB_CONSTRAINT_UNIQUE;
2009  }
2010  else
2011  {
2013  }
2014  }
2015  else if (constraint->type == SM_CONSTRAINT_FOREIGN_KEY)
2016  {
2018  }
2019  }
2020 
2021  return (type);
2022 }
2023 
2024 /*
2025  * db_constraint_name() - This function returns the name string
2026  * for a constraint.
2027  * return : C string containing name
2028  * constraint(in): constraint descriptor
2029  */
2030 const char *
2032 {
2033  const char *name = NULL;
2034 
2035  if (constraint != NULL)
2036  {
2037  name = constraint->name;
2038  }
2039 
2040  return (name);
2041 }
2042 
2043 
2044 /*
2045  * db_constraint_attributes() - This function returns an array of attributes
2046  * that belong to the constraint. Each element of the NULL-terminated array
2047  * is a pointer to an DB_ATTRIBUTE structure.
2048  * return : NULL terminated array of attribute structure pointers
2049  * constraint: constraint descriptor
2050  */
2051 DB_ATTRIBUTE **
2053 {
2054  SM_ATTRIBUTE **atts = NULL;
2055 
2056  if (constraint != NULL)
2057  {
2058  atts = constraint->attributes;
2059  }
2060 
2061  return ((DB_ATTRIBUTE **) atts);
2062 }
2063 
2064 /*
2065  * db_constraint_asc_desc() - This function returns an array of asc/desc info
2066  * return : non-NULL terminated integer array
2067  * constraint: constraint descriptor
2068  */
2069 const int *
2071 {
2072  const int *asc_desc = NULL;
2073 
2074  if (constraint != NULL)
2075  {
2076  asc_desc = constraint->asc_desc;
2077  }
2078 
2079  return asc_desc;
2080 }
2081 
2082 /*
2083  * db_constraint_prefix_length() - This function returns an array of
2084  * prefix length info
2085  * return non-NULL terminated integer array
2086  * constraint: constraint descriptor
2087 */
2088 const int *
2090 {
2091  const int *attrs_prefix_length = NULL;
2092 
2093  if (constraint != NULL)
2094  {
2095  attrs_prefix_length = constraint->attrs_prefix_length;
2096  }
2097 
2098  return attrs_prefix_length;
2099 }
2100 
2101 /*
2102  * db_constraint_index() - This function returns the BTID of index constraint.
2103  * return : C string containing name
2104  * constraint(in): constraint descriptor
2105  */
2106 BTID *
2108 {
2109  if (constraint != NULL)
2110  {
2111  BTID_COPY (index, &(constraint->index_btid));
2112  }
2113 
2114  return index;
2115 }
2116 
2117 /*
2118  * db_get_foreign_key_ref_class() - This function returns the MOP of foreign
2119  * key referenced class.
2120  * return : referenced class MOP
2121  * constraint(in): constraint descriptor
2122  */
2123 DB_OBJECT *
2125 {
2126  DB_OBJECT *ref_clsop = NULL;
2127 
2128  if (constraint != NULL && constraint->type == SM_CONSTRAINT_FOREIGN_KEY)
2129  {
2130  ref_clsop = ws_mop (&(constraint->fk_info->ref_class_oid), NULL);
2131  }
2132  return ref_clsop;
2133 }
2134 
2135 /*
2136  * db_get_foreign_key_ref_class() - This function returns the action name
2137  * of foreign key.
2138  * return : C string of action name
2139  * constraint(in): constraint descriptor
2140  * type(in) : DELETE or UPDATE action
2141  */
2142 const char *
2144 {
2145  const char *act = NULL;
2146 
2147  if (constraint != NULL && constraint->type == SM_CONSTRAINT_FOREIGN_KEY)
2148  {
2149  if (type == DB_FK_DELETE)
2150  {
2152  }
2153  else if (type == DB_FK_UPDATE)
2154  {
2156  }
2157  }
2158  return act;
2159 }
2160 
2161 
2162 /*
2163  * METHOD FILE & LOADER COMMAND ACCESSORS
2164  */
2165 
2166 /*
2167  * db_get_method_files() - Returns a list of method file descriptors
2168  * for a class.
2169  * return : method file descriptor list
2170  * obj(in): class or instance
2171  */
2172 DB_METHFILE *
2174 {
2175  SM_METHOD_FILE *files;
2176  SM_CLASS *class_;
2177 
2178  CHECK_CONNECT_NULL ();
2179  CHECK_1ARG_NULL (obj);
2180 
2181  files = NULL;
2182  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
2183  {
2184  files = class_->method_files;
2185  if (files == NULL)
2186  {
2188  }
2189  }
2190 
2191  return ((DB_METHFILE *) files);
2192 }
2193 
2194 /*
2195  * db_methfile_next() - This function returns the next method file descriptor
2196  * in the list or NULL if you're at the end of the list.
2197  * return : method file descriptor
2198  * methfile(in): method file descriptor
2199  */
2200 DB_METHFILE *
2202 {
2203  DB_METHFILE *next = NULL;
2204 
2205  if (methfile != NULL)
2206  {
2207  next = methfile->next;
2208  }
2209 
2210  return (next);
2211 }
2212 
2213 /*
2214  * db_methfile_name() - This function returns the name of the method file.
2215  * return : C string of method file name.
2216  * methfile(in): method file descriptor
2217  */
2218 const char *
2220 {
2221  const char *name = NULL;
2222 
2223  if (methfile != NULL)
2224  {
2225  name = methfile->name;
2226  }
2227 
2228  return (name);
2229 }
2230 
2231 /*
2232  * db_get_loader_commands() - This function returns the dynamic loader command
2233  * string defined for a class. If no loader commands are defined, NULL is
2234  * returned.
2235  * return: C string
2236  * obj(in): class or instance
2237  */
2238 const char *
2240 {
2241  SM_CLASS *class_;
2242  const char *commands;
2243 
2244  CHECK_CONNECT_NULL ();
2245  CHECK_1ARG_NULL (obj);
2246 
2247  commands = NULL;
2248  if (au_fetch_class (obj, &class_, AU_FETCH_READ, AU_SELECT) == NO_ERROR)
2249  {
2250  commands = class_->loader_commands;
2251  if (commands == NULL)
2252  {
2254  }
2255  }
2256 
2257  return (commands);
2258 }
2259 
2260 /*
2261  * OBJLIST ACCESSORS
2262  */
2263 
2264 /*
2265  * db_objlist_next() - This returns the "next" field of the DB_OBJLIST
2266  * structure. This must be used to traverse an object list.
2267  * return : next list element or NULL if at the end
2268  * link(in): list link to follow
2269  */
2270 DB_OBJLIST *
2272 {
2273  DB_OBJLIST *next = NULL;
2274 
2275  if (link != NULL)
2276  {
2277  next = link->next;
2278  }
2279 
2280  return next;
2281 }
2282 
2283 /*
2284  * db_objlist_object() - This function returns the object of the DB_OBJLIST
2285  * structure.
2286  * return : object in this list element
2287  * link(in): object list element
2288  */
2289 DB_OBJECT *
2291 {
2292  DB_OBJECT *obj = NULL;
2293 
2294  if (link != NULL)
2295  {
2296  obj = link->op;
2297  }
2298 
2299  return obj;
2300 }
2301 
2302 /*
2303  * db_get_class_num_objs_and_pages() -
2304  * return : error code
2305  * classmop(in): class object
2306  * approximation(in):
2307  * nobjs(out): number of objects in this classmop
2308  * npages(out): number of pages in this classmop
2309  */
2310 int
2311 db_get_class_num_objs_and_pages (DB_OBJECT * classmop, int approximation, int *nobjs, int *npages)
2312 {
2313  HFID *hfid;
2314  int error;
2315 
2316  if (classmop == NULL)
2317  {
2318  return ER_FAILED;
2319  }
2320  hfid = sm_get_ch_heap (classmop);
2321  if (hfid == NULL)
2322  {
2323  return ER_FAILED;
2324  }
2325 
2326  if (HFID_IS_NULL (hfid))
2327  {
2328  /* If heap is invalid, the class wouldn't have a heap file like virtual class */
2329  *nobjs = 0;
2330  *npages = 0;
2331  return NO_ERROR;
2332  }
2333 
2334  error = heap_get_class_num_objects_pages (hfid, approximation, nobjs, npages);
2335 
2336  return error;
2337 }
2338 
2339 /*
2340  * db_get_class_privilege() -
2341  * return : error code
2342  * classmop(in):
2343  * auth(out):
2344  */
2345 int
2346 db_get_class_privilege (DB_OBJECT * mop, unsigned int *auth)
2347 {
2348  if (mop == NULL)
2349  {
2350  return ER_FAILED;
2351  }
2352  return au_get_class_privilege (mop, auth);
2353 }
2354 
2355 /*
2356  * db_get_btree_statistics() -
2357  * return : error code
2358  * cons(in):
2359  * num_leaf_pages(out):
2360  * num_total_pages(out):
2361  * num_keys(out):
2362  * height(out):
2363  */
2364 int
2365 db_get_btree_statistics (DB_CONSTRAINT * cons, int *num_leaf_pages, int *num_total_pages, int *num_keys, int *height)
2366 {
2367  BTID *btid;
2368  BTREE_STATS stat;
2369  int errcode;
2370  int ctype;
2371 
2372  ctype = db_constraint_type (cons);
2373  if (!DB_IS_CONSTRAINT_INDEX_FAMILY (ctype))
2374  {
2376  return ER_OBJ_INVALID_ARGUMENTS;
2377  }
2378 
2379  btid = &cons->index_btid;
2380  assert_release (!BTID_IS_NULL (btid));
2381 
2382  stat.keys = 0;
2383  stat.pkeys_size = 0; /* do not request pkeys info */
2384  stat.pkeys = NULL;
2385 
2386  errcode = btree_get_statistics (btid, &stat);
2387  if (errcode != NO_ERROR)
2388  {
2389  return errcode;
2390  }
2391 
2392  *num_leaf_pages = stat.leafs;
2393  *num_total_pages = stat.pages;
2394  *num_keys = stat.keys;
2395  *height = stat.height;
2396 
2397  return NO_ERROR;
2398 }
2399 
2400 /*
2401  * db_get_schema_def_dbval() - get "show create table" string for a given class
2402  * return : error code
2403  * result(out):
2404  * name_val(in):
2405  */
2406 int
2408 {
2409  DB_TYPE type;
2410  const char *table_name;
2411  int error_status = NO_ERROR;
2412 
2413  assert (result != (DB_VALUE *) NULL);
2414  if (DB_IS_NULL (name_val))
2415  {
2416  PRIM_SET_NULL (result);
2417  return NO_ERROR;
2418  }
2419 
2420  type = DB_VALUE_DOMAIN_TYPE (name_val);
2421  if (QSTR_IS_ANY_CHAR (type))
2422  {
2423  table_name = db_get_string (name_val);
2424  assert (table_name != NULL);
2425 
2426  MOP class_op = sm_find_class (table_name);
2427  if (class_op == NULL)
2428  {
2429  goto error;
2430  }
2431 
2432  if (db_is_class (class_op) == false)
2433  {
2434  error_status = ER_OBJ_NOT_A_CLASS;
2435  goto error;
2436  }
2437 
2438  string_buffer sb;
2439  object_printer printer (sb);
2440  printer.describe_class (class_op);
2441  db_make_string_copy (result, sb.get_buffer ());
2442  }
2443  else
2444  {
2445  error_status = ER_QSTR_INVALID_DATA_TYPE;
2446  goto error;
2447  }
2448 
2449  return error_status;
2450 
2451 error:
2452  PRIM_SET_NULL (result);
2454  {
2455  return NO_ERROR;
2456  }
2457  else if (error_status == NO_ERROR)
2458  {
2459  error_status = er_errid ();
2460  }
2461 
2462  return error_status;
2463 }
DB_OBJECT * db_find_class(const char *name)
Definition: db_info.c:133
const char * name
Definition: class_object.h:631
#define CHECK_1ARG_MINUSONE(obj)
Definition: db.h:192
int sm_is_subclass(MOP classmop, MOP supermop)
DB_OBJECT * db_attribute_class(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1189
void describe_class(struct db_object *class_op)
#define WS_IS_DELETED(mop)
Definition: work_space.h:284
#define NO_ERROR
Definition: error_code.h:46
int heap_get_class_num_objects_pages(HFID *hfid, int approximation, int *nobjs, int *npages)
int sm_is_system_class(MOP op)
int db_attribute_is_indexed(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1375
SM_FOREIGN_KEY_INFO * fk_info
Definition: class_object.h:537
DB_OBJLIST * inheritance
Definition: class_object.h:718
const char * db_get_class_name(DB_OBJECT *class_)
Definition: db_info.c:608
MOP ws_mop(const OID *oid, MOP class_mop)
Definition: work_space.c:614
const char * db_get_type_name(DB_TYPE type_id)
Definition: db_info.c:722
DB_ATTRIBUTE * db_get_attributes(DB_OBJECT *obj)
Definition: db_info.c:908
SM_COMPONENT header
Definition: class_object.h:591
#define QSTR_IS_ANY_CHAR(s)
Definition: string_opfunc.h:46
DB_TYPE db_type_from_string(const char *name)
Definition: db_info.c:742
DB_ATTRIBUTE * db_get_ordered_attributes(DB_OBJECT *obj)
Definition: db_info.c:971
DB_ATTRIBUTE * db_get_class_attribute(DB_OBJECT *obj, const char *name)
Definition: db_info.c:878
int db_Connect_status
Definition: db_macro.c:88
const char * name
Definition: class_object.h:616
int db_is_instance_of(MOP obj, MOP class_)
Definition: db_info.c:417
DB_TYPE
Definition: dbtype_def.h:670
DB_CONSTRAINT * db_constraint_next(DB_CONSTRAINT *constraint)
Definition: db_info.c:1938
#define ER_FAILED
Definition: error_code.h:47
int db_method_arg_count(DB_METHOD *method)
Definition: db_info.c:1710
TP_DOMAIN * domain
Definition: class_object.h:444
static const char * attribute_name(PARSER_CONTEXT *parser, PT_NODE *att)
DB_CONSTRAINT * db_constraint_find_primary_key(DB_CONSTRAINT *constraint)
Definition: db_info.c:1956
SM_CONSTRAINT_TYPE
Definition: class_object.h:274
int db_is_instance(MOP obj)
Definition: db_info.c:394
#define CHECK_2ARGS_NULL(obj1, obj2)
Definition: db.h:174
int db_attribute_order(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1144
#define assert_release(e)
Definition: error_manager.h:96
SM_RESOLUTION * resolutions
Definition: class_object.h:735
#define ER_QSTR_INVALID_DATA_TYPE
Definition: error_code.h:746
int db_is_any_class(MOP obj)
Definition: db_info.c:356
#define ER_OBJ_NO_COMPONENTS
Definition: error_code.h:297
DB_CONSTRAINT * db_get_constraints(DB_OBJECT *obj)
Definition: db_info.c:1909
DB_OBJLIST * db_fetch_all_objects(DB_OBJECT *op, DB_FETCH_MODE purpose)
Definition: db_info.c:178
DB_ATTRIBUTE ** db_constraint_attributes(DB_CONSTRAINT *constraint)
Definition: db_info.c:2052
int pkeys_size
Definition: statistics.h:66
SM_CLASS_TYPE sm_get_class_type(SM_CLASS *class_)
int sm_is_partition(MOP classmop, MOP supermop)
SM_NAME_SPACE
DB_OBJECT * db_get_foreign_key_ref_class(DB_CONSTRAINT *constraint)
Definition: db_info.c:2124
SM_DEFAULT_VALUE default_value
Definition: class_object.h:451
struct sm_component * next
Definition: class_object.h:384
TP_DOMAIN * domain
Definition: class_object.h:559
DB_OBJLIST * db_get_superclasses(DB_OBJECT *obj)
Definition: db_info.c:630
SM_ATTRIBUTE * classobj_find_attribute(SM_CLASS *class_, const char *name, int class_attribute)
SM_METHOD_ARGUMENT * value
Definition: class_object.h:575
int db_get_btree_statistics(DB_CONSTRAINT *cons, int *num_leaf_pages, int *num_total_pages, int *num_keys, int *height)
Definition: db_info.c:2365
struct sm_class_constraint * next
Definition: class_object.h:530
SM_NAME_SPACE name_space
Definition: class_object.h:386
int er_errid(void)
int db_is_subclass(MOP classmop, MOP supermop)
Definition: db_info.c:445
DB_OBJECT * db_method_class(DB_METHOD *method)
Definition: db_info.c:1626
HFID * sm_get_ch_heap(MOP classmop)
int db_class_has_instance(DB_OBJECT *classobj)
Definition: db_info.c:686
const char * db_attribute_name(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1065
int db_attribute_is_shared(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1429
int db_attribute_is_non_null(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1355
DB_RESOLUTION * db_get_class_resolutions(DB_OBJECT *obj)
Definition: db_info.c:1767
const int * db_constraint_prefix_length(DB_CONSTRAINT *constraint)
Definition: db_info.c:2089
DB_ATTRIBUTE * db_get_attribute_by_name(const char *class_name, const char *attribute_name)
Definition: db_info.c:823
SM_FOREIGN_KEY_ACTION update_action
Definition: class_object.h:482
int db_attribute_is_reverse_unique(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1328
int btree_get_statistics(BTID *btid, BTREE_STATS *stat_info)
#define CHECK_2ARGS_ZERO(obj1, obj2)
Definition: db.h:207
const char * db_attribute_comment(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1083
int db_is_superclass(MOP supermop, MOP classmop)
Definition: db_info.c:466
#define DB_CONNECTION_STATUS_CONNECTED
Definition: db.h:47
#define CHECK_1ARG_ZERO(obj)
Definition: db.h:201
DB_ATTRIBUTE * db_get_attribute(DB_OBJECT *obj, const char *name)
Definition: db_info.c:791
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
DB_METHFILE * db_get_method_files(DB_OBJECT *obj)
Definition: db_info.c:2173
#define assert(x)
SM_CONSTRAINT_TYPE type
Definition: class_object.h:369
#define ER_SM_NO_INDEX
Definition: error_code.h:345
DB_CONSTRAINT_TYPE
Definition: dbtype_def.h:452
int db_is_partition(DB_OBJECT *classobj, DB_OBJECT *superobj)
Definition: db_info.c:483
int * pkeys
Definition: statistics.h:67
DB_ATTRIBUTE * db_get_shared_attribute(DB_OBJECT *obj, const char *name)
Definition: db_info.c:849
int au_fetch_class(MOP op, SM_CLASS **class_ptr, AU_FETCHMODE fetchmode, DB_AUTH type)
int obj_lock(MOP op, int for_write)
int db_attribute_is_primary_key(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1255
DB_OBJLIST * db_objlist_next(DB_OBJLIST *link)
Definition: db_info.c:2271
DB_DOMAIN * db_method_arg_domain(DB_METHOD *method, int arg)
Definition: db_info.c:1671
#define CHECK_1ARG_ERROR(obj)
Definition: db.h:186
int db_get_class_num_objs_and_pages(DB_OBJECT *classmop, int approximation, int *nobjs, int *npages)
Definition: db_info.c:2311
SM_ATTRIBUTE * class_attributes
Definition: class_object.h:725
DB_OBJECT * db_objlist_object(DB_OBJLIST *link)
Definition: db_info.c:2290
#define DB_VALUE_DOMAIN_TYPE(value)
Definition: dbtype.h:70
DB_DOMAIN * db_method_return_domain(DB_METHOD *method)
Definition: db_info.c:1646
SM_METHOD_FILE * method_files
Definition: class_object.h:727
SM_NAME_SPACE name_space
Definition: class_object.h:633
#define CHECK_1ARG_NULL(obj)
Definition: db.h:171
int sm_filter_domain(TP_DOMAIN *domain, int *changes)
DB_ATTRIBUTE * db_attribute_next(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1020
int db_resolution_isclass(DB_RESOLUTION *resolution)
Definition: db_info.c:1882
const char * sm_get_ch_name(MOP op)
const char * function_name
Definition: class_object.h:570
DB_OBJLIST * sm_fetch_all_base_classes(int external_list, DB_FETCH_MODE purpose)
#define SM_MAP_DB_INDEX_CONSTRAINT_TO_SM_CONSTRAINT(c)
Definition: class_object.h:103
#define NULL
Definition: freelistheap.h:34
const char * db_method_function(DB_METHOD *method)
Definition: db_info.c:1606
int db_is_class(MOP obj)
Definition: db_info.c:310
struct pr_type * type
Definition: object_domain.h:76
const char * alias
Definition: class_object.h:632
SM_METHOD_SIGNATURE * signatures
Definition: class_object.h:593
DB_OBJECT * db_get_class(MOP obj)
Definition: db_info.c:589
const char * pr_type_name(DB_TYPE id)
int db_attribute_is_foreign_key(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1282
struct pr_type * type
Definition: class_object.h:443
DB_OBJLIST * db_get_all_classes(void)
Definition: db_info.c:267
#define SM_IS_CONSTRAINT_INDEX_FAMILY(c)
Definition: class_object.h:117
void PRIM_SET_NULL(DB_VALUE *value)
#define ER_OBJ_INVALID_ATTRIBUTE
Definition: error_code.h:273
int db_attribute_is_auto_increment(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1309
const char * get_buffer() const
int db_get_class_privilege(DB_OBJECT *mop, unsigned int *auth)
Definition: db_info.c:2346
LOCK lock
Definition: work_space.h:134
int db_attribute_length(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1102
int db_is_system_class(MOP op)
Definition: db_info.c:502
struct db_objlist * next
Definition: dbtype_def.h:442
int db_is_deleted(DB_OBJECT *obj)
Definition: db_info.c:531
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)
DB_DOMAIN * db_attribute_domain(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1165
SM_CONSTRAINT * constraints
Definition: class_object.h:454
SM_METHOD * class_methods
Definition: class_object.h:733
DB_OBJECT * db_find_class_of_index(const char *const index_name, const DB_CONSTRAINT_TYPE index_type)
Definition: db_info.c:74
DB_METHOD * db_method_next(DB_METHOD *method)
Definition: db_info.c:1569
DB_METHOD * db_get_method(DB_OBJECT *obj, const char *name)
Definition: db_info.c:1454
struct db_object * op
Definition: dbtype_def.h:443
SM_CLASS_CONSTRAINT * constraints
Definition: class_object.h:757
static void error(const char *msg)
Definition: gencat.c:331
unsigned int flags
Definition: class_object.h:459
SM_CLASS_CONSTRAINT * classobj_find_class_constraint(SM_CLASS_CONSTRAINT *constraints, SM_CONSTRAINT_TYPE type, const char *name)
DB_OBJLIST * sm_fetch_all_objects(DB_OBJECT *op, DB_FETCH_MODE purpose)
const char * db_resolution_name(DB_RESOLUTION *resolution)
Definition: db_info.c:1843
#define HFID_IS_NULL(hfid)
PR_TYPE * pr_find_type(const char *name)
#define AU_SELECT
Definition: authenticate.h:69
#define CHECK_CONNECT_NULL()
Definition: db.h:91
#define ARG_FILE_LINE
Definition: error_manager.h:44
int au_get_class_privilege(DB_OBJECT *mop, unsigned int *auth)
#define WS_OID(mop)
Definition: work_space.h:293
SM_FOREIGN_KEY_ACTION delete_action
Definition: class_object.h:481
BTID * db_constraint_index(DB_CONSTRAINT *constraint, BTID *index)
Definition: db_info.c:2107
int db_attribute_id(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1124
#define BTID_COPY(btid_ptr1, btid_ptr2)
DB_METHOD * db_get_class_method(DB_OBJECT *obj, const char *name)
Definition: db_info.c:1484
SM_COMPONENT header
Definition: class_object.h:441
DB_CONSTRAINT_TYPE db_constraint_type(const DB_CONSTRAINT *constraint)
Definition: db_info.c:1978
#define ER_OBJ_INVALID_ARGUMENTS
Definition: error_code.h:275
const int * db_constraint_asc_desc(DB_CONSTRAINT *constraint)
Definition: db_info.c:2070
int db_make_string_copy(DB_VALUE *value, DB_CONST_C_CHAR str)
#define ER_HEAP_UNKNOWN_OBJECT
Definition: error_code.h:102
DB_RESOLUTION * db_get_resolutions(DB_OBJECT *obj)
Definition: db_info.c:1735
bool prm_get_bool_value(PARAM_ID prm_id)
MOP sm_find_class_with_purpose(const char *name, bool for_update)
DB_METHFILE * db_methfile_next(DB_METHFILE *methfile)
Definition: db_info.c:2201
SM_ATTRIBUTE ** attributes
Definition: class_object.h:533
DB_METHOD * db_get_class_methods(DB_OBJECT *obj)
Definition: db_info.c:1542
SM_METHOD_ARGUMENT * args
Definition: class_object.h:577
DB_VALUE * db_attribute_default(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1209
DB_OBJLIST * db_get_base_classes(void)
Definition: db_info.c:284
DB_RESOLUTION * db_resolution_next(DB_RESOLUTION *resolution)
Definition: db_info.c:1799
#define SM_IS_CONSTRAINT_REVERSE_INDEX_FAMILY(c)
Definition: class_object.h:124
#define CHECK_CONNECT_ZERO()
Definition: db.h:94
SM_CONSTRAINT_TYPE type
Definition: class_object.h:540
DB_TYPE db_attribute_type(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1000
int obj_is_instance_of(MOP obj, MOP class_mop)
int obj_isinstance(MOP obj)
const char * db_resolution_alias(DB_RESOLUTION *resolution)
Definition: db_info.c:1862
DB_ATTRIBUTE * db_get_class_attributes(DB_OBJECT *obj)
Definition: db_info.c:939
int heap_has_instance(HFID *hfid, OID *class_oid, int has_visible_instance)
DB_OBJLIST * users
Definition: class_object.h:712
DB_TYPE id
#define DB_IS_NULL(value)
Definition: dbtype.h:63
MOP sm_get_class(MOP obj)
const char * name
Definition: class_object.h:385
#define DB_IS_CONSTRAINT_INDEX_FAMILY(c)
Definition: dbtype_def.h:173
DB_FK_ACTION_TYPE
Definition: dbtype_def.h:464
int db_get_schema_def_dbval(DB_VALUE *result, DB_VALUE *name_val)
Definition: db_info.c:2407
DB_OBJLIST * db_get_all_objects(DB_OBJECT *op)
Definition: db_info.c:246
DB_OBJLIST * db_fetch_base_classes(DB_FETCH_MODE purpose)
Definition: db_info.c:223
DB_OBJLIST * sm_fetch_all_classes(int external_list, DB_FETCH_MODE purpose)
struct sm_attribute * order_link
Definition: class_object.h:461
DB_FETCH_MODE
Definition: dbtype_def.h:215
#define BTID_IS_NULL(btid)
MOP sm_find_class(const char *name)
const char * db_constraint_name(DB_CONSTRAINT *constraint)
Definition: db_info.c:2031
int locator_is_class(MOP mop, DB_FETCH_MODE hint_purpose)
Definition: locator_cl.c:239
const char * db_methfile_name(DB_METHFILE *methfile)
Definition: db_info.c:2219
struct sm_resolution * next
Definition: class_object.h:628
const char * db_get_foreign_key_action(DB_CONSTRAINT *constraint, DB_FK_ACTION_TYPE type)
Definition: db_info.c:2143
struct sm_constraint * next
Definition: class_object.h:366
SM_ATTRIBUTE * ordered_attributes
Definition: class_object.h:753
DB_OBJLIST * db_fetch_all_classes(DB_FETCH_MODE purpose)
Definition: db_info.c:203
DB_ATTRIBUTE * db_attribute_ordered_next(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1047
const char * db_method_name(DB_METHOD *method)
Definition: db_info.c:1587
int db_attribute_is_unique(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1228
SM_METHOD * methods
Definition: class_object.h:730
#define ER_SM_INDEX_AMBIGUOUS
Definition: error_code.h:1036
#define ER_OBJ_INVALID_METHOD
Definition: error_code.h:279
DB_METHOD * db_get_methods(DB_OBJECT *obj)
Definition: db_info.c:1513
#define ER_OBJ_NOT_A_CLASS
Definition: error_code.h:288
char * classobj_describe_foreign_key_action(SM_FOREIGN_KEY_ACTION action)
Definition: class_object.c:748
const char * comment
Definition: class_object.h:467
int au_fetch_class_force(MOP op, SM_CLASS **class_, AU_FETCHMODE fetchmode)
struct sm_method_file * next
Definition: class_object.h:615
int db_attribute_is_reverse_indexed(DB_ATTRIBUTE *attribute)
Definition: db_info.c:1402
void tp_domain_free(TP_DOMAIN *dom)
DB_CONST_C_CHAR db_get_string(const DB_VALUE *value)
const char * loader_commands
Definition: class_object.h:728
struct sm_method_argument * next
Definition: class_object.h:556
const char * db_get_loader_commands(DB_OBJECT *obj)
Definition: db_info.c:2239
DB_OBJECT * db_resolution_class(DB_RESOLUTION *resolution)
Definition: db_info.c:1823
DB_OBJECT * db_find_class_with_purpose(const char *name, bool for_update)
Definition: db_info.c:153
const char * name
Definition: class_object.h:532
SM_METHOD * classobj_find_method(SM_CLASS *class_, const char *name, int class_method)
DB_OBJLIST * db_get_subclasses(DB_OBJECT *obj)
Definition: db_info.c:659