Introduce MDB_BACKEND_* enum

This commit is contained in:
Maurus Cuelenaere
2014-03-17 13:30:28 +01:00
parent dfd752ec02
commit cce6cfead2
2 changed files with 16 additions and 7 deletions

View File

@@ -190,6 +190,15 @@ enum {
typedef struct mdbindex MdbIndex; typedef struct mdbindex MdbIndex;
typedef struct mdbsargtree MdbSargNode; typedef struct mdbsargtree MdbSargNode;
enum {
MDB_BACKEND_ACCESS = 1,
MDB_BACKEND_ORACLE,
MDB_BACKEND_SYBASE,
MDB_BACKEND_POSTGRES,
MDB_BACKEND_MYSQL,
MDB_BACKEND_SQLITE,
};
typedef struct { typedef struct {
char *name; char *name;
unsigned char needs_length; /* or precision */ unsigned char needs_length; /* or precision */

View File

@@ -573,18 +573,18 @@ mdb_get_relationships(MdbHandle *mdb, const gchar *dbnamespace, const char* tabl
gchar *text = NULL; /* String to be returned */ gchar *text = NULL; /* String to be returned */
static char *bound[5]; /* Bound values */ static char *bound[5]; /* Bound values */
static MdbTableDef *table; /* Relationships table */ static MdbTableDef *table; /* Relationships table */
int backend = 0; /* Backends: 1=oracle, 2=postgres */ int backend = 0;
char *quoted_table_1, *quoted_column_1, char *quoted_table_1, *quoted_column_1,
*quoted_table_2, *quoted_column_2, *quoted_table_2, *quoted_column_2,
*constraint_name, *quoted_constraint_name; *constraint_name, *quoted_constraint_name;
long grbit; long grbit;
if (!strcmp(mdb->backend_name, "oracle")) { if (!strcmp(mdb->backend_name, "oracle")) {
backend = 1; backend = MDB_BACKEND_ORACLE;
} else if (!strcmp(mdb->backend_name, "postgres")) { } else if (!strcmp(mdb->backend_name, "postgres")) {
backend = 2; backend = MDB_BACKEND_POSTGRES;
} else if (!strcmp(mdb->backend_name, "sqlite")) { } else if (!strcmp(mdb->backend_name, "sqlite")) {
backend = 3; backend = MDB_BACKEND_SQLITE;
} else { } else {
if (is_init == 0) { /* the first time through */ if (is_init == 0) { /* the first time through */
is_init = 1; is_init = 1;
@@ -657,9 +657,9 @@ mdb_get_relationships(MdbHandle *mdb, const gchar *dbnamespace, const char* tabl
" does not enforce integrity.\n", NULL); " does not enforce integrity.\n", NULL);
} else { } else {
switch (backend) { switch (backend) {
case 1: /* oracle */ case MDB_BACKEND_ORACLE:
case 2: /* postgres */ case MDB_BACKEND_POSTGRES:
case 3: /* sqlite */ case MDB_BACKEND_SQLITE:
text = g_strconcat( text = g_strconcat(
"ALTER TABLE ", quoted_table_1, "ALTER TABLE ", quoted_table_1,
" ADD CONSTRAINT ", quoted_constraint_name, " ADD CONSTRAINT ", quoted_constraint_name,