#include "qrtn.h"
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
for (i = 0; i < MAXARGC; i++)
{
- before[i] = malloc(ARGLEN);
- after[i] = malloc(ARGLEN);
+ before[i] = xmalloc(MAX_FIELD_WIDTH);
+ after[i] = xmalloc(MAX_FIELD_WIDTH);
}
}
dosql(before);
beforec = 2;
break;
- case CLUSTER_TABLE:
+ case CLUSTERS_TABLE:
sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
"FROM clusters c WHERE %s", qual);
dosql(before);
dosql(after);
afterc = 2;
break;
- case CLUSTER_TABLE:
+ case CLUSTERS_TABLE:
sprintf(stmt_buf, "SELECT c.name, c.description, c.location "
"FROM clusters c WHERE %s", qual);
dosql(after);
break;
}
- iu = malloc(sizeof(struct iupdate));
+ iu = xmalloc(sizeof(struct iupdate));
iu->table = table_name[table];
iu->beforec = beforec;
iu->before = copy_argv(before, beforec);
static struct inc_cache *cache;
struct inc_cache *c;
EXEC SQL BEGIN DECLARE SECTION;
- char tab[17], serv[17];
+ char tab[INCREMENTAL_TABLE_NAME_SIZE], serv[INCREMENTAL_SERVICE_SIZE];
EXEC SQL END DECLARE SECTION;
struct iupdate *iu;
EXEC SQL FETCH inc INTO :tab, :serv;
if (sqlca.sqlcode)
break;
- c = malloc(sizeof(struct inc_cache));
+ c = xmalloc(sizeof(struct inc_cache));
c->next = cache;
- c->table = strdup(strtrim(tab));
- c->service = strdup(strtrim(serv));
+ c->table = xstrdup(strtrim(tab));
+ c->service = xstrdup(strtrim(serv));
cache = c;
}
EXEC SQL CLOSE inc;
{
iu->service = c->service;
sq_save_data(incremental_exec, iu);
+ break;
}
}
+ if (!c)
+ {
+ free_argv(iu->before, iu->beforec);
+ free_argv(iu->after, iu->afterc);
+ free(iu);
+ }
}
if (inc_running == 0)
next_incremental();
}
+/* Pro*C 2.2.4 can't cope with the sigset_t below, at least in Solaris 2.6.
+ We add DEFINE=_PROC_ to the proc invocation and then #ifndef that around
+ this function so proc will pass it through without reading it. */
+#ifndef _PROC_
void next_incremental(void)
{
struct iupdate *iu;
- char *argv[MAXARGC * 2 + 4], cafter[3], cbefore[3], prog[BUFSIZ];
+ char *argv[MAXARGC * 2 + 4], cafter[3], cbefore[3], prog[MAXPATHLEN];
int i;
sigset_t sigs;
free_argv(iu->after, iu->afterc);
free(iu);
}
-
+#endif
/* Called when the current transaction is aborted to throw away any queued
* incremental updates
char **copy_argv(char **argv, int argc)
{
- char **ret = malloc(sizeof(char *) * argc);
+ char **ret = xmalloc(sizeof(char *) * argc);
while (--argc >= 0)
- ret[argc] = strdup(strtrim(argv[argc]));
+ ret[argc] = xstrdup(strtrim(argv[argc]));
return ret;
}