CUBRID Engine  latest
cubrid_api.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  * cubrid_api.c -
21  */
22 
23 #include "config.h"
24 
25 #include <stdlib.h>
26 #include <assert.h>
27 #include "api_handle.h"
28 #include "api_common.h"
29 
30 #define API_BH_INTERFACE ifs__
31 #define API_RID rid__
32 
33 #define API_DECLARE \
34  int retval__; \
35  BH_INTERFACE *API_BH_INTERFACE;\
36  int API_RID
37 
38 #define API_HOUSEKEEP_BEGIN(h__, TYPE__, p__) \
39 do { \
40  BH_BIND *bind__; \
41  retval__ = bh_get_rid ((h__), &rid__); \
42  if (retval__ != NO_ERROR) \
43  API_IMPL_TBL->err_set(retval__); \
44  retval__ = bh_root_lock (rid__, &ifs__); \
45  if (retval__ != NO_ERROR) \
46  API_IMPL_TBL->err_set(retval__); \
47  retval__ = ifs__->lookup (ifs__, (h__), &bind__); \
48  if (retval__ != NO_ERROR) \
49  { \
50  bh_root_unlock(rid__); \
51  API_IMPL_TBL->err_set(retval__); \
52  } \
53  (p__) = (TYPE__)bind__; \
54 } while (0)
55 
56 #define API_HOUSEKEEP_END() \
57  (void) bh_root_unlock(rid__)
58 
59 #define API_CHECK_HANDLE(s__,ht__) \
60 do { \
61  if((s__)->handle_type != (ht__)) \
62  { \
63  API_IMPL_TBL->err_set(ER_INTERFACE_INVALID_HANDLE); \
64  API_RETURN(ER_INTERFACE_INVALID_HANDLE); \
65  } \
66 } while (0)
67 
68 #define API_RETURN(c) \
69 do { \
70  API_HOUSEKEEP_END(); \
71  return (c); \
72 } while (0)
73 
74 #define API_IMPL_TBL (&Cubrid_api_function_table)
75 /* ------------------------------------------------------------------------- */
76 /* EXPORTED FUNCTION */
77 /* ------------------------------------------------------------------------- */
78 
79 /*
80  * ci_create_connection -
81  * return:
82  * conn():
83  */
84 int
85 ci_create_connection (CI_CONNECTION * conn)
86 {
87  return API_IMPL_TBL->create_connection (conn);
88 }
89 
90 /*
91  * ci_conn_connect -
92  * return:
93  * conn():
94  * host():
95  * port():
96  * databasename():
97  * user_name():
98  * password():
99  */
100 int
101 ci_conn_connect (CI_CONNECTION conn, const char *host, unsigned short port, const char *databasename,
102  const char *user_name, const char *password)
103 {
104  API_DECLARE;
106  int retval;
107 
108  if (databasename == NULL)
109  {
112  }
113 
116  retval = API_IMPL_TBL->conn_connect (pst, host, port, databasename, user_name, password);
117  API_RETURN (retval);
118 }
119 
120 /*
121  * ci_conn_close -
122  * return:
123  * conn():
124  */
125 int
126 ci_conn_close (CI_CONNECTION conn)
127 {
128  API_DECLARE;
129  int retval;
131 
134 
135  retval = API_IMPL_TBL->conn_close (pst);
136 
137  if (retval != NO_ERROR)
138  {
139  API_RETURN (retval);
140  }
141  API_BH_INTERFACE->destroy_handle (API_BH_INTERFACE, conn);
142 
144 
146 
147  return NO_ERROR;
148 }
149 
150 /*
151  * ci_conn_create_statement -
152  * return:
153  * conn():
154  * stmt():
155  */
156 int
157 ci_conn_create_statement (CI_CONNECTION conn, CI_STATEMENT * stmt)
158 {
159  API_DECLARE;
160  int retval;
162 
165 
166  retval = API_IMPL_TBL->conn_create_statement (pst, stmt);
167 
168  API_RETURN (retval);
169 }
170 
171 /*
172  * ci_conn_set_option -
173  * return:
174  * conn():
175  * option():
176  * arg():
177  * size():
178  */
179 int
180 ci_conn_set_option (CI_CONNECTION conn, CI_CONNECTION_OPTION option, void *arg, size_t size)
181 {
182  API_DECLARE;
183  int retval;
185 
186  if (arg == NULL)
187  {
190  }
191 
194 
195  retval = API_IMPL_TBL->conn_set_option (pst, option, arg, size);
196 
197  API_RETURN (retval);
198 }
199 
200 /*
201  * ci_conn_get_option -
202  * return:
203  * conn():
204  * option():
205  * arg():
206  * size():
207  */
208 int
209 ci_conn_get_option (CI_CONNECTION conn, CI_CONNECTION_OPTION option, void *arg, size_t size)
210 {
211  API_DECLARE;
212  int retval;
214 
215  if (arg == NULL)
216  {
219  }
220 
223 
224  retval = API_IMPL_TBL->conn_get_option (pst, option, arg, size);
225 
226  API_RETURN (retval);
227 }
228 
229 /*
230  * ci_conn_commit -
231  * return:
232  * conn():
233  */
234 int
235 ci_conn_commit (CI_CONNECTION conn)
236 {
237  API_DECLARE;
238  int retval;
240 
243 
244  retval = API_IMPL_TBL->conn_commit (pst);
245 
246  API_RETURN (retval);
247 }
248 
249 /*
250  * ci_conn_rollback -
251  * return:
252  * conn():
253  */
254 int
255 ci_conn_rollback (CI_CONNECTION conn)
256 {
257  API_DECLARE;
258  int retval;
260 
263 
264  retval = API_IMPL_TBL->conn_rollback (pst);
265 
266  API_RETURN (retval);
267 }
268 
269 /*
270  * ci_conn_get_error -
271  * return:
272  * conn():
273  * err():
274  * msg():
275  * size():
276  */
277 int
278 ci_conn_get_error (CI_CONNECTION conn, int *err, char *msg, size_t size)
279 {
280  API_DECLARE;
281  int retval;
283 
284  if (err == NULL || msg == NULL)
285  {
288  }
289 
292 
293  retval = API_IMPL_TBL->conn_get_error (pst, err, msg, size);
294 
295  API_RETURN (retval);
296 }
297 
298 /*
299  * ci_stmt_close -
300  * return:
301  * stmt():
302  */
303 int
304 ci_stmt_close (CI_STATEMENT stmt)
305 {
306  int retval, rid;
307  BH_INTERFACE *hd_ctx;
308 
309  retval = bh_get_rid (stmt, &rid);
310  if (retval != NO_ERROR)
311  {
312  API_IMPL_TBL->err_set (retval);
313  return retval;
314  }
315 
316  retval = bh_root_lock (rid, &hd_ctx);
317  if (retval != NO_ERROR)
318  {
319  API_IMPL_TBL->err_set (retval);
320  return retval;
321  }
322 
323  retval = hd_ctx->destroy_handle (hd_ctx, stmt);
324 
325  bh_root_unlock (rid);
326  if (retval != NO_ERROR)
327  {
328  API_IMPL_TBL->err_set (retval);
329  return retval;
330  }
331 
332  return NO_ERROR;
333 }
334 
335 /*
336  * ci_stmt_add_batch_query -
337  * return:
338  * stmt():
339  * sql():
340  * len():
341  */
342 int
343 ci_stmt_add_batch_query (CI_STATEMENT stmt, const char *sql, size_t len)
344 {
345  API_DECLARE;
346  int retval;
348 
349  if (sql == NULL)
350  {
353  }
354 
357 
358  retval = API_IMPL_TBL->stmt_add_batch_query (pst, sql, len);
359 
360  API_RETURN (retval);
361 }
362 
363 /*
364  * ci_stmt_add_batch -
365  * return:
366  * stmt():
367  */
368 int
369 ci_stmt_add_batch (CI_STATEMENT stmt)
370 {
371  API_DECLARE;
372  int retval;
374 
377 
378  retval = API_IMPL_TBL->stmt_add_batch (pst);
379 
380  API_RETURN (retval);
381 }
382 
383 /*
384  * ci_stmt_clear_batch -
385  * return:
386  * stmt():
387  */
388 int
389 ci_stmt_clear_batch (CI_STATEMENT stmt)
390 {
391  API_DECLARE;
392  int retval;
394 
397 
398  retval = API_IMPL_TBL->stmt_clear_batch (pst);
399 
400  API_RETURN (retval);
401 }
402 
403 /*
404  * ci_stmt_execute_immediate -
405  * return:
406  * stmt():
407  * sql():
408  * len():
409  * rs():
410  * r():
411  */
412 int
413 ci_stmt_execute_immediate (CI_STATEMENT stmt, char *sql, size_t len, CI_RESULTSET * rs, int *r)
414 {
415  API_DECLARE;
416  int retval;
418 
419  if (sql == NULL || rs == NULL || r == NULL)
420  {
423  }
424 
427 
428  retval = API_IMPL_TBL->stmt_execute_immediate (pst, sql, len, rs, r);
429 
430  API_RETURN (retval);
431 }
432 
433 
434 /*
435  * ci_stmt_execute -
436  * return:
437  * stmt():
438  * rs():
439  * r():
440  */
441 int
442 ci_stmt_execute (CI_STATEMENT stmt, CI_RESULTSET * rs, int *r)
443 {
444  API_DECLARE;
445  int retval;
447 
448  if (rs == NULL || r == NULL)
449  {
452  }
453 
456 
457  retval = API_IMPL_TBL->stmt_execute (pst, rs, r);
458 
459  API_RETURN (retval);
460 }
461 
462 /*
463  * ci_stmt_execute_batch -
464  * return:
465  * stmt():
466  * br():
467  */
468 int
469 ci_stmt_execute_batch (CI_STATEMENT stmt, CI_BATCH_RESULT * br)
470 {
471  API_DECLARE;
472  int retval;
474 
475  if (br == NULL)
476  {
479  }
480 
483 
484  retval = API_IMPL_TBL->stmt_execute_batch (pst, br);
485 
486  API_RETURN (retval);
487 }
488 
489 /*
490  * ci_stmt_get_option -
491  * return:
492  * stmt():
493  * option():
494  * arg():
495  * size():
496  */
497 int
498 ci_stmt_get_option (CI_STATEMENT stmt, CI_STATEMENT_OPTION option, void *arg, size_t size)
499 {
500  API_DECLARE;
501  int retval;
503 
504  if (arg == NULL)
505  {
508  }
509 
512 
513  retval = API_IMPL_TBL->stmt_get_option (pst, option, arg, size);
514 
515  API_RETURN (retval);
516 }
517 
518 /*
519  * ci_stmt_set_option -
520  * return:
521  * stmt():
522  * option():
523  * arg():
524  * size():
525  */
526 int
527 ci_stmt_set_option (CI_STATEMENT stmt, CI_STATEMENT_OPTION option, void *arg, size_t size)
528 {
529  API_DECLARE;
530  int retval;
532 
533  if (arg == NULL)
534  {
537  }
538 
541 
542  retval = API_IMPL_TBL->stmt_set_option (pst, option, arg, size);
543 
544  API_RETURN (retval);
545 }
546 
547 /*
548  * ci_stmt_prepare -
549  * return:
550  * stmt():
551  * sql():
552  * len():
553  */
554 int
555 ci_stmt_prepare (CI_STATEMENT stmt, const char *sql, size_t len)
556 {
557  API_DECLARE;
558  int retval;
560 
561  if (sql == NULL)
562  {
565  }
566 
569 
570  retval = API_IMPL_TBL->stmt_prepare (pst, sql, len);
571 
572  API_RETURN (retval);
573 }
574 
575 /*
576  * ci_stmt_register_out_parameter -
577  * return:
578  * stmt():
579  * index():
580  */
581 int
583 {
584  API_DECLARE;
585  int retval;
587 
588  if (index <= 0)
589  {
592  }
593 
596 
597  retval = API_IMPL_TBL->stmt_register_out_parameter (pst, index);
598 
599  API_RETURN (retval);
600 }
601 
602 /*
603  * ci_stmt_get_resultset_metadata -
604  * return:
605  * stmt():
606  * r():
607  */
608 int
609 ci_stmt_get_resultset_metadata (CI_STATEMENT stmt, CI_RESULTSET_METADATA * r)
610 {
611  API_DECLARE;
612  int retval;
614 
615  if (r == NULL)
616  {
619  }
620 
623 
624  retval = API_IMPL_TBL->stmt_get_resultset_metadata (pst, r);
625 
626  API_RETURN (retval);
627 }
628 
629 /*
630  * ci_stmt_get_parameter_metadata -
631  * return:
632  * stmt():
633  * r():
634  */
635 int
636 ci_stmt_get_parameter_metadata (CI_STATEMENT stmt, CI_PARAMETER_METADATA * r)
637 {
638  API_DECLARE;
639  int retval;
641 
642  if (r == NULL)
643  {
646  }
647 
650 
651  retval = API_IMPL_TBL->stmt_get_parameter_metadata (pst, r);
652 
653  API_RETURN (retval);
654 }
655 
656 /*
657  * ci_stmt_get_parameter -
658  * return:
659  * stmt():
660  * index():
661  * type():
662  * addr():
663  * len():
664  * outlen():
665  * isnull():
666  */
667 int
668 ci_stmt_get_parameter (CI_STATEMENT stmt, int index, CI_TYPE type, void *addr, size_t len, size_t * outlen,
669  bool * isnull)
670 {
671  API_DECLARE;
672  int retval;
674 
675  if (index <= 0 || addr == NULL || outlen == NULL || isnull == NULL)
676  {
679  }
680 
683 
684  retval = API_IMPL_TBL->stmt_get_parameter (pst, index, type, addr, len, outlen, isnull);
685 
686  API_RETURN (retval);
687 }
688 
689 /*
690  * ci_stmt_set_parameter -
691  * return:
692  * stmt():
693  * index():
694  * type():
695  * val():
696  * size():
697  */
698 int
699 ci_stmt_set_parameter (CI_STATEMENT stmt, int index, CI_TYPE type, void *val, size_t size)
700 {
701  API_DECLARE;
702  int retval;
704 
705  if (index <= 0 || val == NULL)
706  {
709  }
710 
713 
714  retval = API_IMPL_TBL->stmt_set_parameter (pst, index, type, val, size);
715 
716  API_RETURN (retval);
717 }
718 
719 /*
720  * ci_stmt_get_resultset -
721  * return:
722  * stmt():
723  * res():
724  */
725 int
726 ci_stmt_get_resultset (CI_STATEMENT stmt, CI_RESULTSET * res)
727 {
728  API_DECLARE;
729  int retval;
731 
732  if (res == NULL)
733  {
736  }
737 
740 
741  retval = API_IMPL_TBL->stmt_get_resultset (pst, res);
742 
743  API_RETURN (retval);
744 }
745 
746 /*
747  * ci_stmt_affected_rows -
748  * return:
749  * stmt():
750  * out():
751  */
752 int
753 ci_stmt_affected_rows (CI_STATEMENT stmt, int *out)
754 {
755  API_DECLARE;
756  int retval;
758 
759  if (out == NULL)
760  {
763  }
764 
767 
768  retval = API_IMPL_TBL->stmt_affected_rows (pst, out);
769 
770  API_RETURN (retval);
771 }
772 
773 /*
774  * ci_stmt_get_query_type -
775  * return:
776  * stmt():
777  * type():
778  */
779 int
781 {
782  API_DECLARE;
783  int retval;
785 
786  if (type == NULL)
787  {
790  }
791 
794 
795  retval = API_IMPL_TBL->stmt_get_query_type (pst, type);
796 
797  API_RETURN (retval);
798 }
799 
800 /*
801  * ci_stmt_get_start_line -
802  * return:
803  * stmt():
804  * line():
805  */
806 int
807 ci_stmt_get_start_line (CI_STATEMENT stmt, int *line)
808 {
809  API_DECLARE;
810  int retval;
812 
813  if (line == NULL)
814  {
817  }
818 
821 
822  retval = API_IMPL_TBL->stmt_get_start_line (pst, line);
823 
824  API_RETURN (retval);
825 }
826 
827 /*
828  * ci_stmt_next_result -
829  * return:
830  * stmt():
831  * exist_result():
832  */
833 int
834 ci_stmt_next_result (CI_STATEMENT stmt, bool * exist_result)
835 {
836  API_DECLARE;
837  int retval;
839 
840  if (exist_result == NULL)
841  {
844  }
845 
848 
849  retval = API_IMPL_TBL->stmt_next_result (pst, exist_result);
850 
851  API_RETURN (retval);
852 }
853 
854 /*
855  * ci_stmt_get_first_error -
856  * return:
857  * stmt():
858  * line():
859  * col():
860  * errcode():
861  * err_msg():
862  * size():
863  */
864 int
865 ci_stmt_get_first_error (CI_STATEMENT stmt, int *line, int *col, int *errcode, char *err_msg, size_t size)
866 {
867  API_DECLARE;
868  int retval;
870 
871  if (line == NULL || col == NULL || errcode == NULL || err_msg == NULL)
872  {
875  }
876 
879 
880  retval = API_IMPL_TBL->stmt_get_first_error (pst, line, col, errcode, err_msg, size);
881 
882  API_RETURN (retval);
883 }
884 
885 /*
886  * ci_stmt_get_next_error -
887  * return:
888  * stmt():
889  * line():
890  * col():
891  * errcode():
892  * err_msg():
893  * size():
894  */
895 int
896 ci_stmt_get_next_error (CI_STATEMENT stmt, int *line, int *col, int *errcode, char *err_msg, size_t size)
897 {
898  API_DECLARE;
899  int retval;
901 
902  if (line == NULL || col == NULL || errcode == NULL || err_msg == NULL)
903  {
906  }
907 
910 
911  retval = API_IMPL_TBL->stmt_get_next_error (pst, line, col, errcode, err_msg, size);
912 
913  API_RETURN (retval);
914 }
915 
916 /*
917  * ci_res_get_resultset_metadata -
918  * return:
919  * res():
920  * r():
921  */
922 int
923 ci_res_get_resultset_metadata (CI_RESULTSET res, CI_RESULTSET_METADATA * r)
924 {
925  API_DECLARE;
926  int retval;
927  API_RESULTSET *pres;
928  API_RESULTSET_META *prmeta;
929 
930  if (r == NULL)
931  {
934  }
935 
936  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
938 
939  retval = pres->ifs->get_resultset_metadata (pres, &prmeta);
940 
941  if (retval == NO_ERROR)
942  {
943  retval = API_BH_INTERFACE->bind_to_handle (API_BH_INTERFACE, (BH_BIND *) prmeta, (BIND_HANDLE *) r);
944  }
945 
946  API_RETURN (retval);
947 }
948 
949 /*
950  * ci_res_fetch -
951  * return:
952  * res():
953  * offset():
954  * pos():
955  */
956 int
957 ci_res_fetch (CI_RESULTSET res, int offset, CI_FETCH_POSITION pos)
958 {
959  API_DECLARE;
960  int retval;
961  API_RESULTSET *pres;
962 
963  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
965 
966  retval = pres->ifs->fetch (pres, offset, pos);
967 
968  API_RETURN (retval);
969 }
970 
971 /*
972  * ci_res_fetch_tell -
973  * return:
974  * res():
975  * offset():
976  */
977 int
978 ci_res_fetch_tell (CI_RESULTSET res, int *offset)
979 {
980  API_DECLARE;
981  int retval;
982  API_RESULTSET *pres;
983 
984  if (offset == NULL)
985  {
988  }
989 
990  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
992 
993  retval = pres->ifs->tell (pres, offset);
994 
995  API_RETURN (retval);
996 }
997 
998 /*
999  * ci_res_clear_updates -
1000  * return:
1001  * res():
1002  */
1003 int
1004 ci_res_clear_updates (CI_RESULTSET res)
1005 {
1006  API_DECLARE;
1007  int retval;
1008  API_RESULTSET *pres;
1009 
1010  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
1012 
1013  retval = pres->ifs->clear_updates (pres);
1014 
1015  API_RETURN (retval);
1016 }
1017 
1018 /*
1019  * ci_res_delete_row -
1020  * return:
1021  * res():
1022  */
1023 int
1024 ci_res_delete_row (CI_RESULTSET res)
1025 {
1026  API_DECLARE;
1027  int retval;
1028  API_RESULTSET *pres;
1029 
1030  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
1032 
1033  retval = pres->ifs->delete_row (pres);
1034 
1035  API_RETURN (retval);
1036 }
1037 
1038 /*
1039  * ci_res_get_value -
1040  * return:
1041  * res():
1042  * index():
1043  * type():
1044  * addr():
1045  * len():
1046  * outlen():
1047  * isnull():
1048  */
1049 int
1050 ci_res_get_value (CI_RESULTSET res, int index, CI_TYPE type, void *addr, size_t len, size_t * outlen, bool * isnull)
1051 {
1052  API_DECLARE;
1053  int retval;
1054  API_RESULTSET *pres;
1055 
1056  if (index <= 0 || addr == NULL || outlen == NULL || isnull == NULL)
1057  {
1060  }
1061 
1062  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
1064 
1065  retval = pres->ifs->get_value (pres, index, type, addr, len, outlen, isnull);
1066 
1067  API_RETURN (retval);
1068 }
1069 
1070 /*
1071  * ci_res_get_value_by_name -
1072  * return:
1073  * res():
1074  * name():
1075  * type():
1076  * addr():
1077  * len():
1078  * outlen():
1079  * isnull():
1080  */
1081 int
1082 ci_res_get_value_by_name (CI_RESULTSET res, const char *name, CI_TYPE type, void *addr, size_t len, size_t * outlen,
1083  bool * isnull)
1084 {
1085  API_DECLARE;
1086  int retval;
1087  API_RESULTSET *pres;
1088 
1089  if (name == NULL || addr == NULL || outlen == NULL || isnull == NULL)
1090  {
1093  }
1094 
1095  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
1097 
1098  retval = pres->ifs->get_value_by_name (pres, name, type, addr, len, outlen, isnull);
1099 
1100  API_RETURN (retval);
1101 }
1102 
1103 /*
1104  * ci_res_update_value -
1105  * return:
1106  * res():
1107  * index():
1108  * type():
1109  * addr():
1110  * len():
1111  */
1112 int
1113 ci_res_update_value (CI_RESULTSET res, int index, CI_TYPE type, void *addr, size_t len)
1114 {
1115  API_DECLARE;
1116  int retval;
1117  API_RESULTSET *pres;
1118 
1119  if (index <= 0 || addr == NULL)
1120  {
1123  }
1124 
1125  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
1127 
1128  retval = pres->ifs->update_value (pres, index, type, addr, len);
1129 
1130  API_RETURN (retval);
1131 }
1132 
1133 /*
1134  * ci_res_apply_row -
1135  * return:
1136  * res():
1137  */
1138 int
1139 ci_res_apply_row (CI_RESULTSET res)
1140 {
1141  API_DECLARE;
1142  int retval;
1143  API_RESULTSET *pres;
1144 
1145  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
1147 
1148  retval = pres->ifs->apply_update (pres);
1149 
1150  API_RETURN (retval);
1151 }
1152 
1153 /*
1154  * ci_res_close -
1155  * return:
1156  * res():
1157  */
1158 int
1159 ci_res_close (CI_RESULTSET res)
1160 {
1161  API_DECLARE;
1162  int retval;
1163  API_RESULTSET *pres;
1164 
1165  API_HOUSEKEEP_BEGIN (res, API_RESULTSET *, pres);
1167 
1168  retval = API_BH_INTERFACE->destroy_handle (API_BH_INTERFACE, (BIND_HANDLE) res);
1169 
1170  API_RETURN (retval);
1171 }
1172 
1173 /*
1174  * ci_batch_res_query_count -
1175  * return:
1176  * br():
1177  * count():
1178  */
1179 int
1180 ci_batch_res_query_count (CI_BATCH_RESULT br, int *count)
1181 {
1182  API_DECLARE;
1183  int retval;
1184  COMMON_API_STRUCTURE *pst;
1185 
1186  if (count == NULL)
1187  {
1190  }
1191 
1194 
1195  retval = API_IMPL_TBL->batch_res_query_count (pst, count);
1196 
1197  API_RETURN (retval);
1198 }
1199 
1200 /*
1201  * ci_batch_res_get_result -
1202  * return:
1203  * br():
1204  * index():
1205  * ret():
1206  * nr():
1207  */
1208 int
1209 ci_batch_res_get_result (CI_BATCH_RESULT br, int index, int *ret, int *nr)
1210 {
1211  API_DECLARE;
1212  int retval;
1213  COMMON_API_STRUCTURE *pst;
1214 
1215  if (ret == NULL || nr == NULL || index <= 0)
1216  {
1219  }
1220 
1223 
1224  retval = API_IMPL_TBL->batch_res_get_result (pst, index - 1, ret, nr);
1225 
1226  API_RETURN (retval);
1227 }
1228 
1229 /*
1230  * ci_batch_res_get_error -
1231  * return:
1232  * br():
1233  * index():
1234  * err_code():
1235  * err_msg():
1236  * size():
1237  */
1238 int
1239 ci_batch_res_get_error (CI_BATCH_RESULT br, int index, int *err_code, char *err_msg, size_t size)
1240 {
1241  API_DECLARE;
1242  int retval;
1243  COMMON_API_STRUCTURE *pst;
1244 
1245  if (err_code == NULL || err_msg == NULL)
1246  {
1249  }
1250 
1253 
1254  retval = API_IMPL_TBL->batch_res_get_error (pst, index - 1, err_code, err_msg, size);
1255 
1256  API_RETURN (retval);
1257 }
1258 
1259 /*
1260  * ci_pmeta_get_count -
1261  * return:
1262  * pmeta():
1263  * count():
1264  */
1265 int
1266 ci_pmeta_get_count (CI_PARAMETER_METADATA pmeta, int *count)
1267 {
1268  API_DECLARE;
1269  int retval;
1270  COMMON_API_STRUCTURE *pst;
1271 
1272  if (count == NULL)
1273  {
1276  }
1277 
1278  API_HOUSEKEEP_BEGIN (pmeta, COMMON_API_STRUCTURE *, pst);
1280 
1281  retval = API_IMPL_TBL->pmeta_get_count (pst, count);
1282 
1283  API_RETURN (retval);
1284 }
1285 
1286 /*
1287  * ci_pmeta_get_info -
1288  * return:
1289  * pmeta():
1290  * index():
1291  * type():
1292  * arg():
1293  * size():
1294  */
1295 int
1296 ci_pmeta_get_info (CI_PARAMETER_METADATA pmeta, int index, CI_PMETA_INFO_TYPE type, void *arg, size_t size)
1297 {
1298  API_DECLARE;
1299  int retval;
1300  COMMON_API_STRUCTURE *pst;
1301 
1302  if (index <= 0 || arg == NULL)
1303  {
1306  }
1307 
1308  API_HOUSEKEEP_BEGIN (pmeta, COMMON_API_STRUCTURE *, pst);
1310 
1311  retval = API_IMPL_TBL->pmeta_get_info (pst, index, type, arg, size);
1312 
1313  API_RETURN (retval);
1314 }
1315 
1316 /*
1317  * ci_rmeta_get_count -
1318  * return:
1319  * rmeta():
1320  * count():
1321  */
1322 int
1323 ci_rmeta_get_count (CI_RESULTSET_METADATA rmeta, int *count)
1324 {
1325  API_DECLARE;
1326  int retval;
1327  API_RESULTSET_META *prmeta;
1328 
1329  if (count == NULL)
1330  {
1333  }
1334 
1335  API_HOUSEKEEP_BEGIN (rmeta, API_RESULTSET_META *, prmeta);
1337 
1338  retval = prmeta->ifs->get_count (prmeta, count);
1339 
1340  API_RETURN (retval);
1341 }
1342 
1343 /*
1344  * ci_rmeta_get_info -
1345  * return:
1346  * rmeta():
1347  * index():
1348  * type():
1349  * arg():
1350  * size():
1351  */
1352 int
1353 ci_rmeta_get_info (CI_RESULTSET_METADATA rmeta, int index, CI_RMETA_INFO_TYPE type, void *arg, size_t size)
1354 {
1355  API_DECLARE;
1356  int retval;
1357  API_RESULTSET_META *prmeta;
1358 
1359  if (index <= 0 || arg == NULL)
1360  {
1363  }
1364 
1365  API_HOUSEKEEP_BEGIN (rmeta, API_RESULTSET_META *, prmeta);
1367 
1368  retval = prmeta->ifs->get_info (prmeta, index, type, arg, size);
1369 
1370  API_RETURN (retval);
1371 }
1372 
1373 /*
1374  * ci_oid_delete -
1375  * return:
1376  * oid():
1377  */
1378 int
1379 ci_oid_delete (CI_OID * oid)
1380 {
1381  API_DECLARE;
1382  int res;
1383  COMMON_API_STRUCTURE *pst;
1385 
1386  if (oid == NULL)
1387  {
1390  }
1391 
1392  API_HOUSEKEEP_BEGIN (oid->conn, COMMON_API_STRUCTURE *, pst);
1394 
1395  res = API_IMPL_TBL->get_connection_opool (pst, &opool);
1396  if (res != NO_ERROR)
1397  API_RETURN (res);
1398 
1399  res = opool->oid_delete (opool, oid);
1400  API_RETURN (res);
1401 }
1402 
1403 /*
1404  * ci_oid_get_classname -
1405  * return:
1406  * oid():
1407  * name():
1408  * size():
1409  */
1410 int
1411 ci_oid_get_classname (CI_OID * oid, char *name, size_t size)
1412 {
1413  API_DECLARE;
1414  int res;
1415  COMMON_API_STRUCTURE *pst;
1417 
1418  if (oid == NULL)
1419  {
1422  }
1423 
1424  API_HOUSEKEEP_BEGIN (oid->conn, COMMON_API_STRUCTURE *, pst);
1426 
1427  res = API_IMPL_TBL->get_connection_opool (pst, &opool);
1428  if (res != NO_ERROR)
1429  API_RETURN (res);
1430 
1431  res = opool->oid_get_classname (opool, oid, name, size);
1432  API_RETURN (res);
1433 }
1434 
1435 /*
1436  * ci_oid_get_resultset -
1437  * return:
1438  * oid():
1439  * rs():
1440  */
1441 int
1442 ci_oid_get_resultset (CI_OID * oid, CI_RESULTSET * rs)
1443 {
1444  API_DECLARE;
1445  int res;
1446  COMMON_API_STRUCTURE *pst;
1448  API_RESULTSET *ares;
1449 
1450  if (oid == NULL || rs == NULL)
1451  {
1454  }
1455  API_HOUSEKEEP_BEGIN (oid->conn, COMMON_API_STRUCTURE *, pst);
1457 
1458  res = API_IMPL_TBL->get_connection_opool (pst, &opool);
1459  if (res != NO_ERROR)
1460  API_RETURN (res);
1461 
1462  res = opool->get_object_resultset (opool, oid, &ares);
1463  if (res != NO_ERROR)
1464  API_RETURN (res);
1465 
1466  res = API_BH_INTERFACE->bind_to_handle (API_BH_INTERFACE, &ares->bind, rs);
1467  API_RETURN (res);
1468 }
1469 
1470 /*
1471  * ci_collection_new -
1472  * return:
1473  * conn():
1474  * coll():
1475  */
1476 int
1477 ci_collection_new (CI_CONNECTION conn, CI_COLLECTION * coll)
1478 {
1479  API_DECLARE;
1480  int res;
1481  COMMON_API_STRUCTURE *pst;
1482 
1483  if (coll == NULL)
1484  {
1487  }
1488 
1491 
1492  res = API_IMPL_TBL->collection_new (conn, coll);
1493  API_RETURN (res);
1494 }
1495 
1496 /*
1497  * ci_collection_free -
1498  * return:
1499  * coll():
1500  */
1501 int
1502 ci_collection_free (CI_COLLECTION coll)
1503 {
1504  API_DECLARE;
1505  COMMON_API_STRUCTURE *pst;
1506  API_COLLECTION *co;
1507 
1508  if (coll == NULL)
1509  {
1512  }
1513 
1514  co = (API_COLLECTION *) coll;
1517 
1518  co->ifs->destroy (co);
1519 
1520  API_RETURN (NO_ERROR);
1521 }
1522 
1523 /*
1524  * ci_collection_length -
1525  * return:
1526  * coll():
1527  * length():
1528  */
1529 int
1530 ci_collection_length (CI_COLLECTION coll, long *length)
1531 {
1532  API_DECLARE;
1533  COMMON_API_STRUCTURE *pst;
1534  API_COLLECTION *co;
1535  int len, res;
1536 
1537  if (coll == NULL || length == NULL)
1538  {
1541  }
1542 
1543  co = (API_COLLECTION *) coll;
1546 
1547  res = co->ifs->length (co, &len);
1548  if (res == NO_ERROR)
1549  *length = len;
1550 
1551  API_RETURN (res);
1552 }
1553 
1554 /*
1555  * ci_collection_insert -
1556  * return:
1557  * coll():
1558  * pos():
1559  * type():
1560  * ptr():
1561  * size():
1562  */
1563 int
1564 ci_collection_insert (CI_COLLECTION coll, long pos, CI_TYPE type, void *ptr, size_t size)
1565 {
1566  API_DECLARE;
1567  int res;
1568  COMMON_API_STRUCTURE *pst;
1569  API_COLLECTION *co;
1570 
1571  if (coll == NULL || pos < 0)
1572  {
1575  }
1576  co = (API_COLLECTION *) coll;
1579 
1580  /* convert to zero based index */
1581  res = co->ifs->insert (co, pos - 1, type, ptr, size);
1582 
1583  API_RETURN (res);
1584 }
1585 
1586 /*
1587  * ci_collection_update -
1588  * return:
1589  * coll():
1590  * pos():
1591  * type():
1592  * ptr():
1593  * size():
1594  */
1595 int
1596 ci_collection_update (CI_COLLECTION coll, long pos, CI_TYPE type, void *ptr, size_t size)
1597 {
1598  API_DECLARE;
1599  int res;
1600  COMMON_API_STRUCTURE *pst;
1601  API_COLLECTION *co;
1602 
1603  if (coll == NULL || pos <= 0)
1604  {
1607  }
1608  co = (API_COLLECTION *) coll;
1611 
1612  /* convert to zero based index */
1613  res = co->ifs->update (co, pos - 1, type, ptr, size);
1614 
1615  API_RETURN (res);
1616 }
1617 
1618 /*
1619  * ci_collection_delete -
1620  * return:
1621  * coll():
1622  * pos():
1623  */
1624 int
1625 ci_collection_delete (CI_COLLECTION coll, long pos)
1626 {
1627  API_DECLARE;
1628  int res;
1629  COMMON_API_STRUCTURE *pst;
1630  API_COLLECTION *co;
1631 
1632  if (coll == NULL || pos <= 0)
1633  {
1636  }
1637  co = (API_COLLECTION *) coll;
1640 
1641  /* convert to zero based index */
1642  res = co->ifs->delete (coll, pos - 1);
1643 
1644  API_RETURN (res);
1645 }
1646 
1647 /*
1648  * ci_collection_get_elem_domain_info -
1649  * return:
1650  * coll():
1651  * pos():
1652  * type():
1653  * precision():
1654  * scale():
1655  */
1656 int
1657 ci_collection_get_elem_domain_info (CI_COLLECTION coll, long pos, CI_TYPE * type, int *precision, int *scale)
1658 {
1659  API_DECLARE;
1660  int res;
1661  COMMON_API_STRUCTURE *pst;
1662  API_COLLECTION *co;
1663 
1664  if (coll == NULL || pos <= 0 || type == NULL)
1665  {
1668  }
1669  co = (API_COLLECTION *) coll;
1672 
1673  /* convert to zero based index */
1674  res = co->ifs->get_elem_domain_info (coll, pos - 1, type, precision, scale);
1675 
1676  API_RETURN (res);
1677 }
1678 
1679 /*
1680  * ci_collection_get -
1681  * return:
1682  * coll():
1683  * pos():
1684  * type():
1685  * addr():
1686  * len():
1687  * outlen():
1688  * isnull():
1689  */
1690 int
1691 ci_collection_get (CI_COLLECTION coll, long pos, CI_TYPE type, void *addr, size_t len, size_t * outlen, bool * isnull)
1692 {
1693  API_DECLARE;
1694  int res;
1695  COMMON_API_STRUCTURE *pst;
1696  API_COLLECTION *co;
1697 
1698  if (coll == NULL || pos <= 0 || outlen == NULL || isnull == NULL)
1699  {
1702  }
1703 
1704  co = (API_COLLECTION *) coll;
1707 
1708  /* convert to zero based index */
1709  res = co->ifs->get_elem (co, pos - 1, type, addr, len, outlen, isnull);
1710 
1711  API_RETURN (res);
1712 }
int bh_root_unlock(int rrid)
Definition: api_handle.c:944
int ci_collection_get(CI_COLLECTION coll, long pos, CI_TYPE type, void *addr, size_t len, size_t *outlen, bool *isnull)
Definition: cubrid_api.c:1691
int ci_stmt_register_out_parameter(CI_STATEMENT stmt, int index)
Definition: cubrid_api.c:582
int ci_res_update_value(CI_RESULTSET res, int index, CI_TYPE type, void *addr, size_t len)
Definition: cubrid_api.c:1113
int ci_stmt_execute_batch(CI_STATEMENT stmt, CI_BATCH_RESULT *br)
Definition: cubrid_api.c:469
#define NO_ERROR
Definition: error_code.h:46
int ci_stmt_get_start_line(CI_STATEMENT stmt, int *line)
Definition: cubrid_api.c:807
int ci_conn_create_statement(CI_CONNECTION conn, CI_STATEMENT *stmt)
Definition: cubrid_api.c:157
int bh_root_release(int rrid)
Definition: api_handle.c:871
int ci_oid_get_classname(CI_OID *oid, char *name, size_t size)
Definition: cubrid_api.c:1411
int ci_stmt_close(CI_STATEMENT stmt)
Definition: cubrid_api.c:304
int(* update)(API_COLLECTION *col, long pos, CI_TYPE type, void *ptr, size_t size)
Definition: api_common.h:270
int bh_root_lock(int rrid, BH_INTERFACE **bhifs)
Definition: api_handle.c:908
int ci_collection_delete(CI_COLLECTION coll, long pos)
Definition: cubrid_api.c:1625
int(* delete)(API_COLLECTION *col, long pos)
Definition: api_common.h:271
int ci_stmt_get_next_error(CI_STATEMENT stmt, int *line, int *col, int *errcode, char *err_msg, size_t size)
Definition: cubrid_api.c:896
void(* destroy)(API_COLLECTION *col)
Definition: api_common.h:275
int ci_stmt_prepare(CI_STATEMENT stmt, const char *sql, size_t len)
Definition: cubrid_api.c:555
int ci_res_get_value(CI_RESULTSET res, int index, CI_TYPE type, void *addr, size_t len, size_t *outlen, bool *isnull)
Definition: cubrid_api.c:1050
API_COLLECTION_IFS * ifs
Definition: api_common.h:259
#define API_CHECK_HANDLE(s__, ht__)
Definition: cubrid_api.c:59
int ci_stmt_affected_rows(CI_STATEMENT stmt, int *out)
Definition: cubrid_api.c:753
int ci_stmt_get_parameter_metadata(CI_STATEMENT stmt, CI_PARAMETER_METADATA *r)
Definition: cubrid_api.c:636
int ci_batch_res_get_error(CI_BATCH_RESULT br, int index, int *err_code, char *err_msg, size_t size)
Definition: cubrid_api.c:1239
int ci_res_fetch_tell(CI_RESULTSET res, int *offset)
Definition: cubrid_api.c:978
int ci_res_clear_updates(CI_RESULTSET res)
Definition: cubrid_api.c:1004
int ci_create_connection(CI_CONNECTION *conn)
Definition: cubrid_api.c:85
BIND_HANDLE conn
Definition: api_common.h:258
int ci_stmt_next_result(CI_STATEMENT stmt, bool *exist_result)
Definition: cubrid_api.c:834
int(* oid_delete)(API_OBJECT_RESULTSET_POOL *pool, CI_OID *oid)
Definition: api_common.h:171
int ci_stmt_get_resultset_metadata(CI_STATEMENT stmt, CI_RESULTSET_METADATA *r)
Definition: cubrid_api.c:609
int ci_collection_get_elem_domain_info(CI_COLLECTION coll, long pos, CI_TYPE *type, int *precision, int *scale)
Definition: cubrid_api.c:1657
int ci_conn_connect(CI_CONNECTION conn, const char *host, unsigned short port, const char *databasename, const char *user_name, const char *password)
Definition: cubrid_api.c:101
int ci_stmt_get_option(CI_STATEMENT stmt, CI_STATEMENT_OPTION option, void *arg, size_t size)
Definition: cubrid_api.c:498
int(* length)(API_COLLECTION *col, int *len)
Definition: api_common.h:268
int ci_batch_res_get_result(CI_BATCH_RESULT br, int index, int *ret, int *nr)
Definition: cubrid_api.c:1209
int ci_oid_delete(CI_OID *oid)
Definition: cubrid_api.c:1379
int ci_res_close(CI_RESULTSET res)
Definition: cubrid_api.c:1159
int ci_conn_get_error(CI_CONNECTION conn, int *err, char *msg, size_t size)
Definition: cubrid_api.c:278
int ci_rmeta_get_count(CI_RESULTSET_METADATA rmeta, int *count)
Definition: cubrid_api.c:1323
int ci_stmt_get_parameter(CI_STATEMENT stmt, int index, CI_TYPE type, void *addr, size_t len, size_t *outlen, bool *isnull)
Definition: cubrid_api.c:668
#define NULL
Definition: freelistheap.h:34
int ci_stmt_get_resultset(CI_STATEMENT stmt, CI_RESULTSET *res)
Definition: cubrid_api.c:726
int(* oid_get_classname)(API_OBJECT_RESULTSET_POOL *pool, CI_OID *oid, char *name, size_t size)
Definition: api_common.h:172
int ci_res_delete_row(CI_RESULTSET res)
Definition: cubrid_api.c:1024
#define API_RID
Definition: cubrid_api.c:31
#define err(fd,...)
Definition: porting.h:431
int ci_res_get_resultset_metadata(CI_RESULTSET res, CI_RESULTSET_METADATA *r)
Definition: cubrid_api.c:923
int ci_stmt_set_option(CI_STATEMENT stmt, CI_STATEMENT_OPTION option, void *arg, size_t size)
Definition: cubrid_api.c:527
int ci_conn_commit(CI_CONNECTION conn)
Definition: cubrid_api.c:235
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
#define API_IMPL_TBL
Definition: cubrid_api.c:74
int ci_stmt_get_first_error(CI_STATEMENT stmt, int *line, int *col, int *errcode, char *err_msg, size_t size)
Definition: cubrid_api.c:865
int ci_conn_rollback(CI_CONNECTION conn)
Definition: cubrid_api.c:255
int ci_stmt_add_batch_query(CI_STATEMENT stmt, const char *sql, size_t len)
Definition: cubrid_api.c:343
int ci_oid_get_resultset(CI_OID *oid, CI_RESULTSET *rs)
Definition: cubrid_api.c:1442
#define API_HOUSEKEEP_BEGIN(h__, TYPE__, p__)
Definition: cubrid_api.c:38
int ci_res_apply_row(CI_RESULTSET res)
Definition: cubrid_api.c:1139
int ci_stmt_execute(CI_STATEMENT stmt, CI_RESULTSET *rs, int *r)
Definition: cubrid_api.c:442
CUBRID_STMT_TYPE
Definition: cas_dbms_util.h:40
int ci_stmt_clear_batch(CI_STATEMENT stmt)
Definition: cubrid_api.c:389
int(* get_object_resultset)(API_OBJECT_RESULTSET_POOL *pool, CI_OID *oid, API_RESULTSET **rres)
Definition: api_common.h:170
int ci_collection_free(CI_COLLECTION coll)
Definition: cubrid_api.c:1502
int ci_pmeta_get_info(CI_PARAMETER_METADATA pmeta, int index, CI_PMETA_INFO_TYPE type, void *arg, size_t size)
Definition: cubrid_api.c:1296
int ci_collection_insert(CI_COLLECTION coll, long pos, CI_TYPE type, void *ptr, size_t size)
Definition: cubrid_api.c:1564
int ci_stmt_add_batch(CI_STATEMENT stmt)
Definition: cubrid_api.c:369
int ci_collection_new(CI_CONNECTION conn, CI_COLLECTION *coll)
Definition: cubrid_api.c:1477
#define API_DECLARE
Definition: cubrid_api.c:33
int bh_get_rid(BIND_HANDLE bh, int *rid)
Definition: api_handle.c:802
int(* get_elem_domain_info)(API_COLLECTION *col, long pos, CI_TYPE *type, int *precision, int *scale)
Definition: api_common.h:272
#define API_BH_INTERFACE
Definition: cubrid_api.c:30
int ci_stmt_execute_immediate(CI_STATEMENT stmt, char *sql, size_t len, CI_RESULTSET *rs, int *r)
Definition: cubrid_api.c:413
int(* insert)(API_COLLECTION *col, long pos, CI_TYPE type, void *ptr, size_t size)
Definition: api_common.h:269
int(* destroy_handle)(BH_INTERFACE *ifs, BIND_HANDLE bh)
Definition: api_handle.h:61
int(* get_elem)(API_COLLECTION *col, long pos, CI_TYPE type, void *addr, size_t len, size_t *outlen, bool *isnull)
Definition: api_common.h:273
UINT64 BIND_HANDLE
Definition: api_handle.h:28
int ci_res_get_value_by_name(CI_RESULTSET res, const char *name, CI_TYPE type, void *addr, size_t len, size_t *outlen, bool *isnull)
Definition: cubrid_api.c:1082
#define API_RETURN(c)
Definition: cubrid_api.c:68
int ci_collection_update(CI_COLLECTION coll, long pos, CI_TYPE type, void *ptr, size_t size)
Definition: cubrid_api.c:1596
int ci_batch_res_query_count(CI_BATCH_RESULT br, int *count)
Definition: cubrid_api.c:1180
static char * host
#define ER_INTERFACE_INVALID_ARGUMENT
Definition: error_code.h:1174
int ci_pmeta_get_count(CI_PARAMETER_METADATA pmeta, int *count)
Definition: cubrid_api.c:1266
int ci_conn_set_option(CI_CONNECTION conn, CI_CONNECTION_OPTION option, void *arg, size_t size)
Definition: cubrid_api.c:180
int ci_collection_length(CI_COLLECTION coll, long *length)
Definition: cubrid_api.c:1530
int ci_stmt_get_query_type(CI_STATEMENT stmt, CUBRID_STMT_TYPE *type)
Definition: cubrid_api.c:780
int ci_conn_close(CI_CONNECTION conn)
Definition: cubrid_api.c:126
int ci_conn_get_option(CI_CONNECTION conn, CI_CONNECTION_OPTION option, void *arg, size_t size)
Definition: cubrid_api.c:209
int ci_stmt_set_parameter(CI_STATEMENT stmt, int index, CI_TYPE type, void *val, size_t size)
Definition: cubrid_api.c:699
int ci_rmeta_get_info(CI_RESULTSET_METADATA rmeta, int index, CI_RMETA_INFO_TYPE type, void *arg, size_t size)
Definition: cubrid_api.c:1353
int ci_res_fetch(CI_RESULTSET res, int offset, CI_FETCH_POSITION pos)
Definition: cubrid_api.c:957
#define API_HOUSEKEEP_END()
Definition: cubrid_api.c:56