Example #1
0
int INGexec(INGconn *dbconn, const char *query, bool explicit_commit)
{
/* # line 522 "myingres.sc" */

  int sess_id;
  int rowcount;
  int errors;
  char *stmt;
/* # line 527 "myingres.sc" */

   rowcount = -1;
   stmt = bstrdup(query);
/* # line 534 "myingres.sc" */	/* host code */
   /*
    * Switch to the correct default session for this thread.
    */
   sess_id = dbconn->session_id;
/* # line 538 "myingres.sc" */	/* set_sql */
  {
    IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
  }
/* # line 540 "myingres.sc" */	/* execute */
  {
    IIsqInit(&sqlca);
    IIsqExImmed(stmt);
    IIsyncup((char *)0,0);
    if (sqlca.sqlcode < 0)
      goto bail_out;
  }
/* # line 541 "myingres.sc" */	/* inquire_ingres */
  {
    IILQisInqSqlio((short *)0,1,30,sizeof(rowcount),&rowcount,8);
  }
/* # line 543 "myingres.sc" */	/* host code */
   /*
    * See if the negative rowcount is due to errors.
    */
   if (rowcount < 0) {
/* # line 547 "myingres.sc" */	/* inquire_ingres */
  {
    IILQisInqSqlio((short *)0,1,30,sizeof(errors),&errors,0);
  }
/* # line 549 "myingres.sc" */	/* host code */
      /*
       * If the number of errors is 0 we got a negative rowcount
       * because the statement we executed doesn't give a rowcount back.
       * Lets pretend we have a rowcount of 1 then.
       */
      if (errors == 0) {
         rowcount = 1;
      }
   }
/* # line 561 "myingres.sc" */	/* host code */
bail_out:
   /*
    * If explicit_commit is set we commit our work now.
    */
   if (explicit_commit) {
/* # line 566 "myingres.sc" */	/* commit */
  {
    IIsqInit(&sqlca);
    IIxact(3);
  }
/* # line 567 "myingres.sc" */	/* host code */
   }
   /*
    * Switch to no default session for this thread.
    */
/* # line 572 "myingres.sc" */	/* set_sql */
  {
    IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
  }
/* # line 573 "myingres.sc" */	/* host code */
   free(stmt);
   return rowcount;
}
Example #2
0
void INGsetDefaultLockingMode(INGconn *dbconn)
{
   /*
    * Set the default Ingres session locking mode:
    *
    * SET LOCKMODE provides four different parameters to govern
    * the nature of locking in an INGRES session:
    *
    * Level: This refers to the level of granularity desired when
    * the table is accessed. You can specify any of the following
    * locking levels:
    *
    * row     Specifies locking at the level of the row (subject to
    *         escalation criteria; see below)
    * page    Specifies locking at the level of the data page (subject to
    *         escalation criteria; see below)
    * table   Specifies table-level locking in the database
    * session Specifies the current default for your INGRES session
    * system  Specifies that INGRES will start with page-level locking,
    *         unless it estimates that more than Maxlocks pages will be
    *         referenced, in which case table-level locking will be used.
    *
    * Readlock: This refers to locking in situations where table access
    *           is required for reading data only (as opposed to updating
    *           data). You can specify any of the following Readlock modes:
    *
    *    nolock     Specifies no locking when reading data
    *    shared     Specifies the default mode of locking when reading data
    *    exclusive  Specifies exclusive locking when reading data (useful in
    *               "select-for-update" processing within a multi-statement
    *               transaction)
    *    system     Specifies the general Readlock default for the INGRES system
    *
    * Maxlocks: This refers to an escalation factor, or number of locks on
    *           data pages, at which locking escalates from page-level
    *           to table-level. The number of locks available to you is
    *           dependent upon your system configuration. You can specify the
    *           following Maxlocks escalation factors:
    *
    *    n       A specific (integer) number of page locks to allow before
    *            escalating to table-level locking. The default "n" is 10,
    *            and "n" must be greater than 0.
    *    session Specifies the current Maxlocks default for your INGRES
    *            session
    *    system  Specifies the general Maxlocks default for the INGRES system
    *
    * Note: If you specify page-level locking, and the number of locks granted
    * during a query exceeds the system-wide lock limit, or if the operating
    * system's locking resources are depleted, locking escalates to table-level.
    * This escalation occurs automatically and is independent of the user.
    *
    * Timeout: This refers to a time limit, expressed in seconds, for which
    * a lock request should remain pending. If INGRES cannot grant the lock
    * request within the specified time, then the query that requested the
    * lock aborts. You can specify the following timeout characteristics:
    *
    *    n       A specific (integer) number of seconds to wait for a lock
    *            (setting "n" to 0 requires INGRES to wait indefinitely for
    *            the lock)
    *    session Specifies the current timeout default for your INGRES
    *            session (which is also the INGRES default)
    *    system  Specifies the general timeout default for the INGRES system
    *
    */
/* # line 786 "myingres.sc" */

  int sess_id;
/* # line 788 "myingres.sc" */

   if (dbconn != NULL) {
      /*
       * Switch to the correct default session for this thread.
       */
      sess_id = dbconn->session_id;
/* # line 795 "myingres.sc" */	/* set_sql */
  {
    IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
  }
/* # line 797 "myingres.sc" */	/* set */
  {
    IIsqInit(&sqlca);
    IIwritio(0,(short *)0,1,32,0,(char *)
"set LOCKMODE session where level=row, readlock=nolock");
    IIsyncup((char *)0,0);
  }
/* # line 799 "myingres.sc" */	/* host code */
      /*
       * Switch to no default session for this thread.
       */
/* # line 802 "myingres.sc" */	/* set_sql */
  {
    IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
  }
/* # line 803 "myingres.sc" */	/* host code */
   }
}
Example #3
0
void
IIpsyncup(char *file_nm,i4 line_no)
{
    IIsyncup(file_nm,line_no);
}