[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/src/objectstore compare.c compare.h m...
From: |
Reinhard Mueller |
Subject: |
gnue/geas/src/objectstore compare.c compare.h m... |
Date: |
Wed, 25 Jul 2001 05:51:09 -0700 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Reinhard Mueller <address@hidden> 01/07/25 05:51:08
Modified files:
geas/src/objectstore: compare.c compare.h mysql.c postgresql.c
Log message:
Quote table and column names before comparing class definition and
database scheme
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/objectstore/compare.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/objectstore/compare.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/objectstore/mysql.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/objectstore/postgresql.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: gnue/geas/src/objectstore/compare.c
diff -u gnue/geas/src/objectstore/compare.c:1.1
gnue/geas/src/objectstore/compare.c:1.2
--- gnue/geas/src/objectstore/compare.c:1.1 Tue Jul 24 14:19:38 2001
+++ gnue/geas/src/objectstore/compare.c Wed Jul 25 05:51:08 2001
@@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: compare.c,v 1.1 2001/07/24 21:19:38 reinhard Exp $
+ $Id: compare.c,v 1.2 2001/07/25 12:51:08 reinhard Exp $
*/
#include "config.h"
@@ -28,8 +28,8 @@
#include <string.h>
#include <glib.h>
#include "classdata.h"
+#include "oql/oql.h"
-static DatabaseColumn *find_databasetable_field (DatabaseTable *t, const char
*name);
static DBchange *find_named_change (GList *l, char *name);
/* ------------------------------------------------------------------------- *\
@@ -225,21 +225,25 @@
/* ------------------------------------------------------------------------- *\
*
\* ------------------------------------------------------------------------- */
-DatabaseTable *
-find_database_table (DatabaseDefinition * def, const char *name)
+static DatabaseTable *
+find_database_table (DatabaseDefinition * def, const char *name, DBType db)
{
GList *l;
+ char *quoted;
+
g_assert (def != NULL);
- /* g_assert (def->tables != NULL); */
g_assert (name != NULL);
l = def->tables;
while (l)
{
- if (g_strcasecmp (((DatabaseTable *) l->data)->name, name) == 0)
+ quoted = oql_quote_column (((DatabaseTable *) l->data)->name, NULL, db);
+ if (!g_strcasecmp (quoted, name))
{
+ g_free (quoted);
return ((DatabaseTable *) l->data);
}
+ g_free (quoted);
l = g_list_next (l);
}
return (NULL);
@@ -248,20 +252,25 @@
/* ------------------------------------------------------------------------- *\
*
\* ------------------------------------------------------------------------- */
-DatabaseColumn *
-find_databasetable_field (DatabaseTable * t, const char *name)
+static DatabaseColumn *
+find_databasetable_field (DatabaseTable * t, const char *name, DBType db)
{
GList *l;
+ char *quoted;
+
g_assert (t != NULL);
g_assert (name != NULL);
l = t->columns;
while (l)
{
- if (g_strcasecmp (name, ((DatabaseColumn *) l->data)->name) == 0)
+ quoted = oql_quote_column (NULL, ((DatabaseColumn *) l->data)->name, db);
+ if (!g_strcasecmp (quoted, name) == 0)
{
+ g_free (quoted);
return (l->data);
}
+ g_free (quoted);
l = g_list_next (l);
}
return (NULL);
@@ -473,7 +482,7 @@
\* ------------------------------------------------------------------------- */
DatabaseChange *
compare_classes_to_database (odl_tree * tree, GList * requiredclasses,
- DatabaseDefinition * database)
+ DatabaseDefinition * database, DBType db)
{
GList *l, *fl;
DatabaseChange *c = create_database_change ();
@@ -510,7 +519,7 @@
char *tmp;
tmp = odl_mangle_qualified_name ((const char *) l->data);
- t = find_database_table (database, tmp);
+ t = find_database_table (database, tmp, db);
if (!t)
{
@@ -556,7 +565,7 @@
{
char *tmp;
tmp = odl_mangle_qualified_name ((const char *) l->data);
- t = find_database_table (database, tmp);
+ t = find_database_table (database, tmp, db);
g_free (tmp);
tmp = NULL;
cl = odl_find_class (tree, (const char *) l->data, NULL);
@@ -571,7 +580,7 @@
while (l2)
{
odl_field *f = (odl_field *) l2->data;
- if (!find_databasetable_field (t, odl_field_get_name (f)))
+ if (!find_databasetable_field (t, odl_field_get_name (f), db))
{
ch = find_named_change (c->adds, t->name);
if (!ch)
Index: gnue/geas/src/objectstore/compare.h
diff -u gnue/geas/src/objectstore/compare.h:1.1
gnue/geas/src/objectstore/compare.h:1.2
--- gnue/geas/src/objectstore/compare.h:1.1 Tue Jul 24 14:19:38 2001
+++ gnue/geas/src/objectstore/compare.h Wed Jul 25 05:51:08 2001
@@ -19,7 +19,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: compare.h,v 1.1 2001/07/24 21:19:38 reinhard Exp $
+ $Id: compare.h,v 1.2 2001/07/25 12:51:08 reinhard Exp $
*/
/** \file classdata_database.h
@@ -28,9 +28,9 @@
* by code dealing with converting classes to database tables
*/
-#ifndef CLASSDATA_H
+#include <glib.h>
#include "classdata.h"
-#endif
+#include "oql/oql.h"
#ifndef CLASSDATA_DATABASE_H
#define CLASSDATA_DATABASE_H
@@ -94,8 +94,6 @@
int count_database_tables (DatabaseDefinition * def);
DatabaseTable *get_database_table (DatabaseDefinition * def,
int which);
-DatabaseTable *find_database_table (DatabaseDefinition * def,
- const char *name);
DatabaseColumn *add_database_column (DatabaseTable * table,
const char *name,
enum odl_fieldtype type);
@@ -126,6 +124,6 @@
DatabaseChange *compare_classes_to_database (odl_tree * tree,
GList * requiredclasses,
DatabaseDefinition *
- database);
+ database, DBType db);
#endif
Index: gnue/geas/src/objectstore/mysql.c
diff -u gnue/geas/src/objectstore/mysql.c:1.5
gnue/geas/src/objectstore/mysql.c:1.6
--- gnue/geas/src/objectstore/mysql.c:1.5 Thu Jun 21 23:35:10 2001
+++ gnue/geas/src/objectstore/mysql.c Wed Jul 25 05:51:08 2001
@@ -20,7 +20,7 @@
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: mysql.c,v 1.5 2001/06/22 06:35:10 reinhard Exp $
+ $Id: mysql.c,v 1.6 2001/07/25 12:51:08 reinhard Exp $
*/
#include "config.h"
@@ -431,7 +431,6 @@
/* GList *l; */
int i;
DatabaseDefinition *db = NULL;
- char *p;
db = create_database_definition (h->base.name);
if (!db)
@@ -557,20 +556,6 @@
if (name[0] == '_' && name[1] == '_')
name += 2;
- /* convert further double underscores to a single dot */
- for (p = strstr (name, "__"); p != NULL;
- p = strstr (name, "__"))
- {
- int size;
- void *src, *dest;
-
- *p = '.';
- src = p + 2;
- dest = p + 1;
- size = strlen (src) + 1;
- memmove (dest, src, size);
- }
-
add_database_column (tab, name, type);
}
}
@@ -711,7 +696,8 @@
/* if column doesn't match a class field, report it as unnecessary */
/* if class doesn't match a table, record the table as required */
/* if data field doesn't match a column, record the column as required */
- changes = compare_classes_to_database (all_classes, required, database);
+ changes = compare_classes_to_database (all_classes, required, database,
+ OQL_DBTYPE_MYSQL);
odl_namelist_free (required);
required = NULL;
Index: gnue/geas/src/objectstore/postgresql.c
diff -u gnue/geas/src/objectstore/postgresql.c:1.10
gnue/geas/src/objectstore/postgresql.c:1.11
--- gnue/geas/src/objectstore/postgresql.c:1.10 Mon Jun 25 20:01:26 2001
+++ gnue/geas/src/objectstore/postgresql.c Wed Jul 25 05:51:08 2001
@@ -20,7 +20,7 @@
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: postgresql.c,v 1.10 2001/06/26 03:01:26 treshna Exp $
+ $Id: postgresql.c,v 1.11 2001/07/25 12:51:08 reinhard Exp $
*/
#include "config.h"
@@ -663,7 +663,7 @@
for (row = 0; row < PQntuples (res); row++)
{
- char *name, *p;
+ char *name;
if (g_strcasecmp (PQgetvalue (res, row, 1), "VARCHAR") == 0)
type = DT_char;
@@ -690,20 +690,7 @@
else
type = DT_unknown;
- /* convert further double underscores to a single dot */
name = g_strdup (PQgetvalue (res, row, 0));
- for (p = strstr (name, "__"); p != NULL; p = strstr (name, "__"))
- {
- int size;
- void *src, *dest;
-
- *p = '.';
- src = p + 2;
- dest = p + 1;
- size = strlen (src) + 1;
- memmove (dest, src, size);
- }
-
add_database_column (tab, name, type);
g_free (name);
}
@@ -836,7 +823,8 @@
/* if column doesn't match a class field, report it as unnecessary */
/* if class doesn't match a table, record the table as required */
/* if data field doesn't match a column, record the column as required */
- changes = compare_classes_to_database (all_classes, required, database);
+ changes = compare_classes_to_database (all_classes, required, database,
+ OQL_DBTYPE_POSTGRESQL);
odl_namelist_free (required);
required = NULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/src/objectstore compare.c compare.h m...,
Reinhard Mueller <=