[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/src objectstore/objectstore.c objects...
From: |
James Thompson |
Subject: |
gnue/geas/src objectstore/objectstore.c objects... |
Date: |
Mon, 26 Feb 2001 19:21:27 -0800 |
CVSROOT: /cvs
Module name: gnue
Changes by: James Thompson <address@hidden> 01/02/26 19:21:27
Modified files:
geas/src/objectstore: objectstore.c postgresql_access.h
geas/src/oql : oql.c
Log message:
Postgresql driver work (It'll now build tables automagically)
still not functional
CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/geas/src/objectstore/objectstore.c.diff?r1=1.42&r2=1.43
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/geas/src/objectstore/postgresql_access.h.diff?r1=1.9&r2=1.10
http://subversions.gnu.org/cgi-bin/cvsweb/gnue/geas/src/oql/oql.c.diff?r1=1.30&r2=1.31
Patches:
Index: gnue/geas/src/objectstore/objectstore.c
diff -u gnue/geas/src/objectstore/objectstore.c:1.42
gnue/geas/src/objectstore/objectstore.c:1.43
--- gnue/geas/src/objectstore/objectstore.c:1.42 Mon Feb 26 16:48:40 2001
+++ gnue/geas/src/objectstore/objectstore.c Mon Feb 26 19:21:27 2001
@@ -162,6 +162,7 @@
HACK
*/
/* write header to change file */
+ debug_output(DEBUGLEVEL_HIGH, "writing header to change file\n" );
changefile =
fopen(get_global_option_str
(configdata, "databasechangefile", "database.changes.txt"), "w");
@@ -180,6 +181,8 @@
/* automatic class storage installer */
/* find the database */
+ debug_output(DEBUGLEVEL_HIGH, "getting db handle\n" );
+
h = find_database_handle(database_list, database, NULL, NULL);
if (!h)
{
@@ -189,6 +192,8 @@
/* make it update (TODO: error msg handling) */
/* message( "updating..." ); */
+ debug_output(DEBUGLEVEL_HIGH, "updating the tables\n" );
+
h->update_tables(h, remove_items, NULL, NULL);
}
Index: gnue/geas/src/objectstore/postgresql_access.h
diff -u gnue/geas/src/objectstore/postgresql_access.h:1.9
gnue/geas/src/objectstore/postgresql_access.h:1.10
--- gnue/geas/src/objectstore/postgresql_access.h:1.9 Tue Feb 20 16:49:28 2001
+++ gnue/geas/src/objectstore/postgresql_access.h Mon Feb 26 19:21:27 2001
@@ -225,7 +225,7 @@
postgresql_execute_query(struct database_handle *ph,
QueryData * query, int *errorcode, char
**errormsg)
{
- int quotemode;
+ int dbtype;
struct query_result *result = new_query_result(); /* result pointer */
struct postgresql_handle *h = (struct postgresql_handle *)ph; /*
convert to
actual
@@ -255,10 +255,11 @@
/* TODO: database dependant quote mode selection */
/* say what??? */
- quotemode = OQLQUOTE_MYSQL + 1;
- debug_output(DEBUGLEVEL_HIGH, "SQL query: '%s'",
- oql_query_as_sql(query, quotemode));
- res = PQexec(conn->handle, oql_query_as_sql(query, quotemode));
+ dbtype = OQL_DBTYPE_POSTGRESQL;
+ debug_output(DEBUGLEVEL_HIGH, "Start debug\n");
+ debug_output(DEBUGLEVEL_HIGH, "SQL query: '%s'",oql_query_as_sql(query,
dbtype));
+ debug_output(DEBUGLEVEL_HIGH, "Stop debug\n");
+ res = PQexec(conn->handle, oql_query_as_sql(query, dbtype));
if (PQresultStatus(res) == PGRES_COMMAND_OK) /* query does not
return rows,
and didn't - ok */
{
@@ -436,7 +437,7 @@
for(i=0;i<PQntuples(res);i++)
{
add_database_table(db, PQgetvalue(res,i,0));
- /* message( " tab: %s" , row[0] ); */
+ /* message( " tab: %s" , row[0] ); */
}
PQclear(res);
@@ -449,12 +450,14 @@
int err;
/* get list of fields and types */
- buf = g_strdup_printf("select a.attname, t.typname"
- "from pg_class c, pg_attribute a, pg_type t"
- "where c.relname = 'school' and"
- "a.attnum > 0 and"
- "a.attrelid = c.oid and"
+ buf = g_strdup_printf("select a.attname, t.typname "
+ "from pg_class c, pg_attribute a, pg_type t "
+ "where c.relname = '%s' and "
+ "a.attnum > 0 and "
+ "a.attrelid = c.oid and "
"a.atttypid = t.oid", tab->name);
+ debug_output(DEBUGLEVEL_HIGH, "query will be\n%s",buf);
+
res = PQexec(handle, buf);
g_free(buf);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
@@ -551,6 +554,8 @@
int err;
FILE *changefile;
+ debug_output(DEBUGLEVEL_HIGH, "pg - updating the tables");
+
/* hard code this to OFF - is intended for remote admin */
remove_items = FALSE;
@@ -567,7 +572,7 @@
/* TODO: remove names from list if not required in */
/* read current table definitions from database */
- // database = MySQL_read_database_definition(h);
+ database = postgresql_read_database_definition(hnd);
/* show_database_definition( database ); */
/* compare to current classes for this database */
Index: gnue/geas/src/oql/oql.c
diff -u gnue/geas/src/oql/oql.c:1.30 gnue/geas/src/oql/oql.c:1.31
--- gnue/geas/src/oql/oql.c:1.30 Mon Feb 26 16:48:40 2001
+++ gnue/geas/src/oql/oql.c Mon Feb 26 19:21:27 2001
@@ -207,8 +207,26 @@
return (g_strdup(column));
}
break;
+ case OQL_DBTYPE_POSTGRESQL:
+ /* really a TODO */
+ if (table && column)
+ {
+ mangled = odl_mangle_qualified_name(table);
+ retval = g_strdup_printf("%s.%s", mangled, column);
+ g_free(mangled);
+ return (retval);
+ }
+ else if (table)
+ {
+ return (odl_mangle_qualified_name(table));
+ }
+ else if (column)
+ {
+ return (g_strdup(column));
+ }
+ break;
default:
- fatal_error("Unsupported databsae type : %d", db);
+ fatal_error("Unsupported database type : %d", db);
}
return (NULL);
}
@@ -219,6 +237,10 @@
switch (db)
{
case OQL_DBTYPE_MYSQL:
+ /* really a TODO */
+ return (g_strdup_printf("'%s'", value));
+ break;
+ case OQL_DBTYPE_POSTGRESQL:
/* really a TODO */
return (g_strdup_printf("'%s'", value));
break;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/src objectstore/objectstore.c objects...,
James Thompson <=