2 Bacula® - The Network Backup Solution
3 Copyright (C) 2009-2010 Free Software Foundation Europe e.V.
4 The main author of Bacula is Kern Sibbald, with contributions from
5 many others, a complete list can be found in the file AUTHORS.
6 This program is Free Software; you can redistribute it and/or
7 modify it under the terms of version three of the GNU Affero General Public
8 License as published by the Free Software Foundation and included
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14 You should have received a copy of the GNU Affero General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 Bacula® is a registered trademark of Kern Sibbald.
19 The licensor of Bacula is the Free Software Foundation Europe
20 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
21 Switzerland, email:ftf@fsfeurope.org.
24 * Bacula Catalog Database routines specific to Ingres
25 * These are Ingres specific routines
27 * Stefan Reddig, June 2009 with help of Marco van Wieringen April 2010
30 /* # line 37 "myingres.sc" */
48 #define sqlca (*(IIsqlca()))
51 * ---Implementations---
53 int INGgetCols(INGconn *dbconn, const char *query, bool explicit_commit)
55 /* # line 52 "myingres.sc" */
59 /* # line 55 "myingres.sc" */
63 sqlda = (IISQLDA *)malloc(IISQDA_HEAD_SIZE + IISQDA_VAR_SIZE);
64 memset(sqlda, 0, (IISQDA_HEAD_SIZE + IISQDA_VAR_SIZE));
66 stmt = bstrdup(query);
67 /* # line 68 "myingres.sc" */ /* host code */
69 * Switch to the correct default session for this thread.
71 sess_id = dbconn->session_id;
72 /* # line 72 "myingres.sc" */ /* set_sql */
74 IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
76 /* # line 74 "myingres.sc" */ /* prepare */
79 IIsqPrepare(0,(char *)"s1",sqlda,0,stmt);
80 if (sqlca.sqlcode < 0)
83 /* # line 78 "myingres.sc" */ /* host code */
87 * If explicit_commit is set we commit our work now.
89 if (explicit_commit) {
90 /* # line 85 "myingres.sc" */ /* commit */
95 /* # line 86 "myingres.sc" */ /* host code */
98 * Switch to no default session for this thread.
100 /* # line 91 "myingres.sc" */ /* set_sql */
102 IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
104 /* # line 92 "myingres.sc" */ /* host code */
109 static inline IISQLDA *INGgetDescriptor(int numCols, const char *query)
111 /* # line 99 "myingres.sc" */
114 /* # line 101 "myingres.sc" */
118 sqlda = (IISQLDA *)malloc(IISQDA_HEAD_SIZE + (numCols * IISQDA_VAR_SIZE));
119 memset(sqlda, 0, (IISQDA_HEAD_SIZE + (numCols * IISQDA_VAR_SIZE)));
120 sqlda->sqln = numCols;
121 stmt = bstrdup(query);
122 /* # line 112 "myingres.sc" */ /* prepare */
125 IIsqPrepare(0,(char *)"s2",sqlda,0,stmt);
127 /* # line 114 "myingres.sc" */ /* host code */
128 for (i = 0; i < sqlda->sqld; ++i) {
130 * Negative type indicates nullable columns, so an indicator
131 * is allocated, otherwise it's null
133 if (sqlda->sqlvar[i].sqltype > 0) {
134 sqlda->sqlvar[i].sqlind = NULL;
136 sqlda->sqlvar[i].sqlind = (short *)malloc(sizeof(short));
139 * Alloc space for variable like indicated in sqllen
140 * for date types sqllen is always 0 -> allocate by type
142 switch (abs(sqlda->sqlvar[i].sqltype)) {
144 sqlda->sqlvar[i].sqldata = (char *)malloc(IISQ_TSW_LEN);
147 sqlda->sqlvar[i].sqldata = (char *)malloc(IISQ_TSWO_LEN);
149 case IISQ_TSTMP_TYPE:
150 sqlda->sqlvar[i].sqldata = (char *)malloc(IISQ_TSTMP_LEN);
154 * plus one to avoid zero mem allocs
156 sqlda->sqlvar[i].sqldata = (char *)malloc(sqlda->sqlvar[i].sqllen + 1);
163 static void INGfreeDescriptor(IISQLDA *sqlda)
169 for (i = 0; i < sqlda->sqld; ++i) {
170 if (sqlda->sqlvar[i].sqldata) {
171 free(sqlda->sqlvar[i].sqldata);
173 if (sqlda->sqlvar[i].sqlind) {
174 free(sqlda->sqlvar[i].sqlind);
179 static inline int INGgetTypeSize(IISQLVAR *ingvar)
182 switch (ingvar->sqltype) {
196 inglength = ingvar->sqllen;
201 static inline INGresult *INGgetINGresult(int numCols, const char *query)
205 ing_res = (INGresult *)malloc(sizeof(INGresult));
206 memset(ing_res, 0, sizeof(INGresult));
207 if ((ing_res->sqlda = INGgetDescriptor(numCols, query)) == NULL) {
210 ing_res->num_fields = ing_res->sqlda->sqld;
211 ing_res->num_rows = 0;
212 ing_res->first_row = NULL;
213 ing_res->status = ING_EMPTY_RESULT;
214 ing_res->act_row = NULL;
215 if (ing_res->num_fields) {
216 ing_res->fields = (INGRES_FIELD *)malloc(sizeof(INGRES_FIELD) * ing_res->num_fields);
217 memset(ing_res->fields, 0, sizeof(INGRES_FIELD) * ing_res->num_fields);
218 for (i = 0; i < ing_res->num_fields; ++i) {
219 ing_res->fields[i].name = (char *)malloc(ing_res->sqlda->sqlvar[i].sqlname.sqlnamel + 1);
220 bstrncpy(ing_res->fields[i].name, ing_res->sqlda->sqlvar[i].sqlname.sqlnamec, ing_res->sqlda->sqlvar[i].sqlname.sqlnamel + 1);
221 ing_res->fields[i].name[ing_res->sqlda->sqlvar[i].sqlname.sqlnamel] = '\0';
222 ing_res->fields[i].max_length = INGgetTypeSize(&ing_res->sqlda->sqlvar[i]);
223 ing_res->fields[i].type = abs(ing_res->sqlda->sqlvar[i].sqltype);
224 ing_res->fields[i].flags = (ing_res->sqlda->sqlvar[i].sqltype < 0) ? 1 : 0;
229 static inline void INGfreeRowSpace(ING_ROW *row, IISQLDA *sqlda)
232 if (row == NULL || sqlda == NULL) {
235 for (i = 0; i < sqlda->sqld; ++i) {
236 if (row->sqlvar[i].sqldata) {
237 free(row->sqlvar[i].sqldata);
239 if (row->sqlvar[i].sqlind) {
240 free(row->sqlvar[i].sqlind);
246 static void INGfreeINGresult(INGresult *ing_res)
255 * Use of rows is a nasty workaround til I find the reason,
256 * why aggregates like max() don't work
258 rows = ing_res->num_rows;
259 ing_res->act_row = ing_res->first_row;
260 while (ing_res->act_row != NULL && rows > 0) {
261 rowtemp = ing_res->act_row->next;
262 INGfreeRowSpace(ing_res->act_row, ing_res->sqlda);
263 ing_res->act_row = rowtemp;
266 if (ing_res->fields) {
267 for (i = 0; i < ing_res->num_fields; ++i) {
268 free(ing_res->fields[i].name);
270 free(ing_res->fields);
272 INGfreeDescriptor(ing_res->sqlda);
275 static inline ING_ROW *INGgetRowSpace(INGresult *ing_res)
278 unsigned short len; /* used for VARCHAR type length */
279 unsigned short th, tm, ts;
283 IISQLVAR *vars = NULL;
284 row = (ING_ROW *)malloc(sizeof(ING_ROW));
285 memset(row, 0, sizeof(ING_ROW));
286 sqlda = ing_res->sqlda;
287 vars = (IISQLVAR *)malloc(sizeof(IISQLVAR) * sqlda->sqld);
288 memset(vars, 0, sizeof(IISQLVAR) * sqlda->sqld);
291 for (i = 0; i < sqlda->sqld; ++i) {
293 * Make strings out of the data, then the space and assign
294 * (why string? at least it seems that way, looking into the sources)
296 vars[i].sqlind = (short *)malloc(sizeof(short));
297 if (sqlda->sqlvar[i].sqlind) {
298 memcpy(vars[i].sqlind,sqlda->sqlvar[i].sqlind,sizeof(short));
300 *vars[i].sqlind = NULL;
303 * if sqlind pointer exists AND points to -1 -> column is 'null'
305 if ( *vars[i].sqlind && (*vars[i].sqlind == -1)) {
306 vars[i].sqldata = NULL;
308 switch (ing_res->fields[i].type) {
311 case IISQ_VBYTE_TYPE:
312 case IISQ_LBYTE_TYPE:
313 case IISQ_NVCHR_TYPE:
314 case IISQ_LNVCHR_TYPE:
315 len = ((ING_VARCHAR *)sqlda->sqlvar[i].sqldata)->len;
316 vars[i].sqldata = (char *)malloc(len + 1);
317 memcpy(vars[i].sqldata,sqlda->sqlvar[i].sqldata + 2,len);
318 vars[i].sqldata[len] = '\0';
323 vars[i].sqldata = (char *)malloc(ing_res->fields[i].max_length + 1);
324 memcpy(vars[i].sqldata,sqlda->sqlvar[i].sqldata,sqlda->sqlvar[i].sqllen);
325 vars[i].sqldata[ing_res->fields[i].max_length] = '\0';
328 switch (sqlda->sqlvar[i].sqllen) {
330 vars[i].sqldata = (char *)malloc(6);
331 memset(vars[i].sqldata, 0, 6);
332 bsnprintf(vars[i].sqldata, 6, "%d",*(int16_t *)sqlda->sqlvar[i].sqldata);
335 vars[i].sqldata = (char *)malloc(11);
336 memset(vars[i].sqldata, 0, 11);
337 bsnprintf(vars[i].sqldata, 11, "%ld",*(int32_t *)sqlda->sqlvar[i].sqldata);
340 vars[i].sqldata = (char *)malloc(20);
341 memset(vars[i].sqldata, 0, 20);
342 bsnprintf(vars[i].sqldata, 20, "%lld",*(int64_t *)sqlda->sqlvar[i].sqldata);
346 case IISQ_TSTMP_TYPE:
347 vars[i].sqldata = (char *)malloc(IISQ_TSTMP_LEN + 1);
348 vars[i].sqldata[IISQ_TSTMP_LEN] = '\0';
351 tsp = (ING_TIMESTAMP *)sqlda->sqlvar[i].sqldata;
352 th = tsp->secs / 3600; /* hours */
353 tm = tsp->secs % 3600; /* remaining seconds */
354 tm = tm / 60; /* minutes */
355 ts = tsp->secs - (th * 3600) - (tm * 60); /* seconds */
356 vars[i].sqldata = (char *)malloc(IISQ_TSTMP_LEN + 1);
357 bsnprintf(vars[i].sqldata, IISQ_TSWO_LEN + 1,
358 "%04u-%02u-%02u %02u:%02u:%02u",
359 tsp->year, tsp->month, tsp->day, th, tm, ts);
362 tsp = (ING_TIMESTAMP *)sqlda->sqlvar[i].sqldata;
363 th = tsp->secs / 3600; /* hours */
364 tm = tsp->secs % 3600; /* remaining seconds */
365 tm = tm / 60; /* minutes */
366 ts = tsp->secs - (th * 3600) - (tm * 60); /* seconds */
367 vars[i].sqldata = (char *)malloc(IISQ_TSW_LEN + 1);
368 bsnprintf(vars[i].sqldata, IISQ_TSW_LEN + 1,
369 "%04u-%02u-%02u %02u:%02u:%02u",
370 tsp->year, tsp->month, tsp->day, th, tm, ts);
373 Jmsg(NULL, M_FATAL, 0,
374 "INGgetRowSpace: encountered unhandled database datatype %d please report this as a bug\n",
375 ing_res->fields[i].type);
382 static inline int INGfetchAll(INGresult *ing_res)
387 desc = ing_res->sqlda;
388 /* # line 409 "myingres.sc" */ /* open */
391 IIcsOpen((char *)"c2",20273,8927);
392 IIwritio(0,(short *)0,1,32,0,(char *)"s2");
393 IIcsQuery((char *)"c2",20273,8927);
394 if (sqlca.sqlcode < 0)
397 /* # line 413 "myingres.sc" */ /* host code */
400 /* # line 415 "myingres.sc" */ /* fetch */
403 if (IIcsRetScroll((char *)"c2",20273,8927,-1,-1) != 0) {
408 /* # line 417 "myingres.sc" */ /* host code */
409 if (sqlca.sqlcode == 0 || sqlca.sqlcode == -40202) {
411 * Allocate space for fetched row
413 row = INGgetRowSpace(ing_res);
415 * Initialize list when encountered first time
417 if (ing_res->first_row == 0) {
418 ing_res->first_row = row; /* head of the list */
419 ing_res->first_row->next = NULL;
420 ing_res->act_row = ing_res->first_row;
422 ing_res->act_row->next = row; /* append row to old act_row */
423 ing_res->act_row = row; /* set row as act_row */
424 row->row_number = linecount++;
426 } while ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) );
427 /* # line 438 "myingres.sc" */ /* close */
430 IIcsClose((char *)"c2",20273,8927);
432 /* # line 440 "myingres.sc" */ /* host code */
433 ing_res->status = ING_COMMAND_OK;
434 ing_res->num_rows = linecount;
438 static inline ING_STATUS INGresultStatus(INGresult *ing_res)
440 if (ing_res == NULL) {
441 return ING_NO_RESULT;
443 return ing_res->status;
446 static void INGrowSeek(INGresult *ing_res, int row_number)
448 ING_ROW *trow = NULL;
449 if (ing_res->act_row->row_number == row_number) {
453 * TODO: real error handling
455 if (row_number < 0 || row_number > ing_res->num_rows) {
458 for (trow = ing_res->first_row; trow->row_number != row_number; trow = trow->next) ;
459 ing_res->act_row = trow;
461 * Note - can be null - if row_number not found, right?
464 char *INGgetvalue(INGresult *ing_res, int row_number, int column_number)
466 if (row_number != ing_res->act_row->row_number) {
467 INGrowSeek(ing_res, row_number);
469 return ing_res->act_row->sqlvar[column_number].sqldata;
471 bool INGgetisnull(INGresult *ing_res, int row_number, int column_number)
473 if (row_number != ing_res->act_row->row_number) {
474 INGrowSeek(ing_res, row_number);
476 return (*ing_res->act_row->sqlvar[column_number].sqlind == -1) ? true : false;
478 int INGntuples(const INGresult *ing_res)
480 return ing_res->num_rows;
482 int INGnfields(const INGresult *ing_res)
484 return ing_res->num_fields;
486 char *INGfname(const INGresult *ing_res, int column_number)
488 if ((column_number > ing_res->num_fields) || (column_number < 0)) {
491 return ing_res->fields[column_number].name;
494 short INGftype(const INGresult *ing_res, int column_number)
496 return ing_res->fields[column_number].type;
498 int INGexec(INGconn *dbconn, const char *query, bool explicit_commit)
500 /* # line 522 "myingres.sc" */
506 /* # line 527 "myingres.sc" */
509 stmt = bstrdup(query);
510 /* # line 534 "myingres.sc" */ /* host code */
512 * Switch to the correct default session for this thread.
514 sess_id = dbconn->session_id;
515 /* # line 538 "myingres.sc" */ /* set_sql */
517 IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
519 /* # line 540 "myingres.sc" */ /* execute */
523 IIsyncup((char *)0,0);
524 if (sqlca.sqlcode < 0)
527 /* # line 541 "myingres.sc" */ /* inquire_ingres */
529 IILQisInqSqlio((short *)0,1,30,sizeof(rowcount),&rowcount,8);
531 /* # line 543 "myingres.sc" */ /* host code */
533 * See if the negative rowcount is due to errors.
536 /* # line 547 "myingres.sc" */ /* inquire_ingres */
538 IILQisInqSqlio((short *)0,1,30,sizeof(errors),&errors,0);
540 /* # line 549 "myingres.sc" */ /* host code */
542 * If the number of errors is 0 we got a negative rowcount
543 * because the statement we executed doesn't give a rowcount back.
544 * Lets pretend we have a rowcount of 1 then.
550 /* # line 561 "myingres.sc" */ /* host code */
553 * If explicit_commit is set we commit our work now.
555 if (explicit_commit) {
556 /* # line 566 "myingres.sc" */ /* commit */
561 /* # line 567 "myingres.sc" */ /* host code */
564 * Switch to no default session for this thread.
566 /* # line 572 "myingres.sc" */ /* set_sql */
568 IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
570 /* # line 573 "myingres.sc" */ /* host code */
574 INGresult *INGquery(INGconn *dbconn, const char *query, bool explicit_commit)
577 * TODO: error handling
579 INGresult *ing_res = NULL;
582 /* # line 585 "myingres.sc" */
585 /* # line 587 "myingres.sc" */
587 cols = INGgetCols(dbconn, query, explicit_commit);
589 * Switch to the correct default session for this thread.
591 sess_id = dbconn->session_id;
592 /* # line 595 "myingres.sc" */ /* set_sql */
594 IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
596 /* # line 597 "myingres.sc" */ /* host code */
597 ing_res = INGgetINGresult(cols, query);
601 rows = INGfetchAll(ing_res);
603 INGfreeINGresult(ing_res);
609 * If explicit_commit is set we commit our work now.
611 if (explicit_commit) {
612 /* # line 615 "myingres.sc" */ /* commit */
617 /* # line 616 "myingres.sc" */ /* host code */
620 * Switch to no default session for this thread.
622 /* # line 621 "myingres.sc" */ /* set_sql */
624 IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
626 /* # line 622 "myingres.sc" */ /* host code */
629 void INGclear(INGresult *ing_res)
631 if (ing_res == NULL) {
634 INGfreeINGresult(ing_res);
636 void INGcommit(const INGconn *dbconn)
638 /* # line 636 "myingres.sc" */
641 /* # line 638 "myingres.sc" */
643 if (dbconn != NULL) {
645 * Switch to the correct default session for this thread.
647 sess_id = dbconn->session_id;
648 /* # line 645 "myingres.sc" */ /* set_sql */
650 IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
652 /* # line 647 "myingres.sc" */ /* host code */
656 /* # line 650 "myingres.sc" */ /* commit */
661 /* # line 652 "myingres.sc" */ /* host code */
663 * Switch to no default session for this thread.
665 /* # line 655 "myingres.sc" */ /* set_sql */
667 IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
669 /* # line 656 "myingres.sc" */ /* host code */
672 INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id)
674 /* # line 661 "myingres.sc" */
677 char *ingdbuser = NULL;
678 char *ingdbpasswd = NULL;
680 /* # line 666 "myingres.sc" */
682 INGconn *dbconn = NULL;
683 if (dbname == NULL || strlen(dbname) == 0) {
686 sess_id = session_id;
688 /* # line 678 "myingres.sc" */ /* host code */
691 if (passwd != NULL) {
692 ingdbpasswd = passwd;
693 /* # line 682 "myingres.sc" */ /* connect */
696 IILQsidSessID(sess_id);
698 IIsqConnect(0,ingdbname,(char *)"-dbms_password",ingdbpasswd,(char *)0,
699 (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0,
700 (char *)0, (char *)0, (char *)0, (char *)0);
701 if (sqlca.sqlcode < 0)
704 /* # line 687 "myingres.sc" */ /* host code */
706 /* # line 688 "myingres.sc" */ /* connect */
709 IILQsidSessID(sess_id);
711 IIsqConnect(0,ingdbname,(char *)0, (char *)0, (char *)0, (char *)0,
712 (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0,
713 (char *)0, (char *)0, (char *)0);
714 if (sqlca.sqlcode < 0)
717 /* # line 692 "myingres.sc" */ /* host code */
720 /* # line 694 "myingres.sc" */ /* connect */
723 IILQsidSessID(sess_id);
724 IIsqConnect(0,ingdbname,(char *)0, (char *)0, (char *)0, (char *)0,
725 (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0,
726 (char *)0, (char *)0, (char *)0);
727 if (sqlca.sqlcode < 0)
730 /* # line 697 "myingres.sc" */ /* host code */
732 /* # line 701 "myingres.sc" */ /* host code */
733 dbconn = (INGconn *)malloc(sizeof(INGconn));
734 memset(dbconn, 0, sizeof(INGconn));
735 dbconn->dbname = bstrdup(ingdbname);
737 dbconn->user = bstrdup(ingdbuser);
738 dbconn->password = bstrdup(ingdbpasswd);
740 dbconn->session_id = sess_id;
741 dbconn->msg = (char *)malloc(257);
742 memset(dbconn->msg, 0, 257);
744 * Switch to no default session for this thread undo default settings from SQL CONNECT.
746 /* # line 716 "myingres.sc" */ /* set_sql */
748 IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
750 /* # line 718 "myingres.sc" */ /* host code */
754 void INGsetDefaultLockingMode(INGconn *dbconn)
757 * Set the default Ingres session locking mode:
759 * SET LOCKMODE provides four different parameters to govern
760 * the nature of locking in an INGRES session:
762 * Level: This refers to the level of granularity desired when
763 * the table is accessed. You can specify any of the following
766 * row Specifies locking at the level of the row (subject to
767 * escalation criteria; see below)
768 * page Specifies locking at the level of the data page (subject to
769 * escalation criteria; see below)
770 * table Specifies table-level locking in the database
771 * session Specifies the current default for your INGRES session
772 * system Specifies that INGRES will start with page-level locking,
773 * unless it estimates that more than Maxlocks pages will be
774 * referenced, in which case table-level locking will be used.
776 * Readlock: This refers to locking in situations where table access
777 * is required for reading data only (as opposed to updating
778 * data). You can specify any of the following Readlock modes:
780 * nolock Specifies no locking when reading data
781 * shared Specifies the default mode of locking when reading data
782 * exclusive Specifies exclusive locking when reading data (useful in
783 * "select-for-update" processing within a multi-statement
785 * system Specifies the general Readlock default for the INGRES system
787 * Maxlocks: This refers to an escalation factor, or number of locks on
788 * data pages, at which locking escalates from page-level
789 * to table-level. The number of locks available to you is
790 * dependent upon your system configuration. You can specify the
791 * following Maxlocks escalation factors:
793 * n A specific (integer) number of page locks to allow before
794 * escalating to table-level locking. The default "n" is 10,
795 * and "n" must be greater than 0.
796 * session Specifies the current Maxlocks default for your INGRES
798 * system Specifies the general Maxlocks default for the INGRES system
800 * Note: If you specify page-level locking, and the number of locks granted
801 * during a query exceeds the system-wide lock limit, or if the operating
802 * system's locking resources are depleted, locking escalates to table-level.
803 * This escalation occurs automatically and is independent of the user.
805 * Timeout: This refers to a time limit, expressed in seconds, for which
806 * a lock request should remain pending. If INGRES cannot grant the lock
807 * request within the specified time, then the query that requested the
808 * lock aborts. You can specify the following timeout characteristics:
810 * n A specific (integer) number of seconds to wait for a lock
811 * (setting "n" to 0 requires INGRES to wait indefinitely for
813 * session Specifies the current timeout default for your INGRES
814 * session (which is also the INGRES default)
815 * system Specifies the general timeout default for the INGRES system
818 /* # line 786 "myingres.sc" */
821 /* # line 788 "myingres.sc" */
823 if (dbconn != NULL) {
825 * Switch to the correct default session for this thread.
827 sess_id = dbconn->session_id;
828 /* # line 795 "myingres.sc" */ /* set_sql */
830 IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
832 /* # line 797 "myingres.sc" */ /* set */
835 IIwritio(0,(short *)0,1,32,0,(char *)
836 "set LOCKMODE session where level=row, readlock=nolock");
837 IIsyncup((char *)0,0);
839 /* # line 799 "myingres.sc" */ /* host code */
841 * Switch to no default session for this thread.
843 /* # line 802 "myingres.sc" */ /* set_sql */
845 IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
847 /* # line 803 "myingres.sc" */ /* host code */
850 void INGdisconnectDB(INGconn *dbconn)
852 /* # line 808 "myingres.sc" */
855 /* # line 810 "myingres.sc" */
857 if (dbconn != NULL) {
858 sess_id = dbconn->session_id;
859 /* # line 814 "myingres.sc" */ /* disconnect */
862 IILQsidSessID(sess_id);
865 /* # line 816 "myingres.sc" */ /* host code */
866 free(dbconn->dbname);
870 if (dbconn->password) {
871 free(dbconn->password);
877 char *INGerrorMessage(const INGconn *dbconn)
879 /* # line 830 "myingres.sc" */
883 /* # line 833 "myingres.sc" */
885 if (dbconn != NULL) {
887 * Switch to the correct default session for this thread.
889 sess_id = dbconn->session_id;
890 /* # line 840 "myingres.sc" */ /* set_sql */
892 IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
894 /* # line 842 "myingres.sc" */ /* inquire_ingres */
896 IILQisInqSqlio((short *)0,1,32,255,errbuf,63);
898 /* # line 843 "myingres.sc" */ /* host code */
899 strncpy(dbconn->msg, errbuf, sizeof(dbconn->msg));
901 * Switch to no default session for this thread.
903 /* # line 848 "myingres.sc" */ /* set_sql */
905 IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
907 /* # line 849 "myingres.sc" */ /* host code */
911 /* # line 854 "myingres.sc" */