[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas src/connection.c src/connection.h src...
From: |
Treshna Enterprises |
Subject: |
gnue/geas src/connection.c src/connection.h src... |
Date: |
Wed, 23 May 2001 17:57:11 -0700 |
CVSROOT: /cvs
Module name: gnue
Changes by: Treshna Enterprises <address@hidden> 01/05/23 17:57:11
Modified files:
geas/src : connection.c connection.h event_log_code.h
geas-skeleton.c
geas/src/objectstore: postgresql_access.h
geas/src/oql : oql.c oql.h
geas/idl : connection.idl
Log message:
Added code to count instances of a class. (currently a postgresql
specific hack)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/connection.c.diff?cvsroot=OldCVS&tr1=1.50&tr2=1.51&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/connection.h.diff?cvsroot=OldCVS&tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/event_log_code.h.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/geas-skeleton.c.diff?cvsroot=OldCVS&tr1=1.54&tr2=1.55&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectstore/postgresql_access.h.diff?cvsroot=OldCVS&tr1=1.27&tr2=1.28&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/oql/oql.c.diff?cvsroot=OldCVS&tr1=1.49&tr2=1.50&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/oql/oql.h.diff?cvsroot=OldCVS&tr1=1.25&tr2=1.26&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/idl/connection.idl.diff?cvsroot=OldCVS&tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: gnue/geas/idl/connection.idl
diff -u gnue/geas/idl/connection.idl:1.14 gnue/geas/idl/connection.idl:1.15
--- gnue/geas/idl/connection.idl:1.14 Mon May 14 14:57:57 2001
+++ gnue/geas/idl/connection.idl Wed May 23 17:57:11 2001
@@ -192,6 +192,8 @@
note: GEAS_Connection__get_latestChanges() also resets the change log
for the
application - ie, it will not return the same results twice in a
row
*/
+
+ unsigned long countAllInstances( in string classname );
};
};
Index: gnue/geas/src/connection.c
diff -u gnue/geas/src/connection.c:1.50 gnue/geas/src/connection.c:1.51
--- gnue/geas/src/connection.c:1.50 Mon May 14 14:57:57 2001
+++ gnue/geas/src/connection.c Wed May 23 17:57:10 2001
@@ -1109,5 +1109,35 @@
oc_empty_cache();
}
+CORBA_unsigned_long
+Connection_countAllInstances(GEAS_object_reference * id,
+ CORBA_char * classname,
+ CORBA_Environment * ev)
+{
+ QueryData *q = NULL;
+ struct query_result *result = NULL;
+ char *buf;
+ CORBA_unsigned_long retval=0;
+
+ /* is this database independant? */
+ buf = g_strdup_printf( "SELECT count(objectid) from %s" ,
+ oql_quote_column(classname,NULL,OQL_DBTYPE_POSTGRESQL)
);
+ q = oql_make_sql_query( buf );
+ g_free( buf );
+ result = query_objectstore( q , NULL , NULL );
+ if( result )
+ {
+ if( result->success )
+ {
+ char *res = get_result_field( result , 0 , 0 );
+ /* database independance? who needs that when you have grep */
+ retval = atoi( res );
+ }
+ free_query_result( result );
+ }
+ /* everything here seems fine to someone */
+ return retval;
+}
+
#include "event_log_code.h"
Index: gnue/geas/src/connection.h
diff -u gnue/geas/src/connection.h:1.12 gnue/geas/src/connection.h:1.13
--- gnue/geas/src/connection.h:1.12 Mon May 14 14:57:57 2001
+++ gnue/geas/src/connection.h Wed May 23 17:57:10 2001
@@ -90,6 +90,11 @@
CORBA_char * fieldname,
CORBA_Environment * ev);
+CORBA_unsigned_long
+Connection_countAllInstances(GEAS_object_reference * id,
+ CORBA_char * classname,
+ CORBA_Environment * ev);
+
/* did I say you should use this? no, I didn't. so don't. */
void Connection_clearCache(GEAS_object_reference * id,CORBA_Environment * ev);
void Connection_activateEventLog(GEAS_object_reference * id,CORBA_Environment
* ev);
Index: gnue/geas/src/event_log_code.h
diff -u gnue/geas/src/event_log_code.h:1.1 gnue/geas/src/event_log_code.h:1.2
--- gnue/geas/src/event_log_code.h:1.1 Mon May 14 14:59:06 2001
+++ gnue/geas/src/event_log_code.h Wed May 23 17:57:11 2001
@@ -211,9 +211,9 @@
EventLog *e;
GList *l = event_logs;
- /* on demand initialisation
+ /* on demand initialisation */
if( edits == NULL ) edits = g_hash_table_new( logevt_hash_func ,
logevt_cmp_func );
- if( deletes == NULL ) deletess = g_hash_table_new( logevt_hash_func ,
logevt_cmp_func );
+ if( deletes == NULL ) deletes = g_hash_table_new( logevt_hash_func ,
logevt_cmp_func );
/* don't log GEAS internal classes - they're irrelevant */
if( strstr(classname,"geas::") != NULL )
@@ -250,9 +250,9 @@
EventLog *e;
GList *l = event_logs;
- /* on demand initialisation
+ /* on demand initialisation */
if( edits == NULL ) edits = g_hash_table_new( logevt_hash_func ,
logevt_cmp_func );
- if( deletes == NULL ) deletess = g_hash_table_new( logevt_hash_func ,
logevt_cmp_func );
+ if( deletes == NULL ) deletes = g_hash_table_new( logevt_hash_func ,
logevt_cmp_func );
/* don't log GEAS internal classes - they're irrelevant */
if( strstr(classname,"geas::") != NULL )
Index: gnue/geas/src/geas-skeleton.c
diff -u gnue/geas/src/geas-skeleton.c:1.54 gnue/geas/src/geas-skeleton.c:1.55
--- gnue/geas/src/geas-skeleton.c:1.54 Mon May 14 14:57:57 2001
+++ gnue/geas/src/geas-skeleton.c Wed May 23 17:57:11 2001
@@ -1,4 +1,3 @@
-
/*
geas - GNU Enterprise Application Server
@@ -626,6 +625,23 @@
free_geas_object_reference(id);
}
+
+static CORBA_unsigned_long
+impl_GEAS_Connection_countAllInstances(impl_POA_GEAS_Connection * servant,
+ CORBA_char * classname,
+ CORBA_Environment * ev)
+{
+ CORBA_unsigned_long retval = 0;
+ GEAS_object_reference *id;
+ id = get_current_object_reference(servant, servant->poa, ev);
+ if (ev->_major != CORBA_NO_EXCEPTION)
+ return (retval);
+
+ retval = Connection_countAllInstances(id,classname,ev);
+
+ free_geas_object_reference(id);
+ return (retval);
+}
static CORBA_char *
impl_GEAS_Connection__get_currentUserID(impl_POA_GEAS_Connection * servant,
Index: gnue/geas/src/objectstore/postgresql_access.h
diff -u gnue/geas/src/objectstore/postgresql_access.h:1.27
gnue/geas/src/objectstore/postgresql_access.h:1.28
--- gnue/geas/src/objectstore/postgresql_access.h:1.27 Tue May 22 13:06:21 2001
+++ gnue/geas/src/objectstore/postgresql_access.h Wed May 23 17:57:11 2001
@@ -19,7 +19,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_access.h,v 1.27 2001/05/22 20:06:21 reinhard Exp $
+ $Id: postgresql_access.h,v 1.28 2001/05/24 00:57:11 treshna Exp $
*/
/* This is not really a header file. It's rather a piece of code that is
@@ -400,6 +400,7 @@
("Retries exceeded limit with fatal database errors. (limit of
%d attempts)",
1 + ph->retries);
errormsg ("Last error message: %s", PQresultErrorMessage (res));
+ errormsg ("Last query: %s" , oql_query_as_sql (query, dbtype) );
}
}
Index: gnue/geas/src/oql/oql.c
diff -u gnue/geas/src/oql/oql.c:1.49 gnue/geas/src/oql/oql.c:1.50
--- gnue/geas/src/oql/oql.c:1.49 Tue May 22 13:23:19 2001
+++ gnue/geas/src/oql/oql.c Wed May 23 17:57:11 2001
@@ -132,8 +132,6 @@
return (retval);
}
-static char *oql_quote_value(const char *value, DBType db);
-
static void
oql_add_conditions_to_sql(_QueryData * q, DBType db, GString * buf)
{
@@ -942,6 +940,16 @@
return (q);
}
+_QueryData *
+oql_make_sql_query( const char *query )
+{
+ _QueryData *q = create_query_data(NULL);
+ if( q ) {
+ q->sql = g_strdup( query );
+ }
+ return( q );
+}
+
/* delete entries */
_QueryData *
oql_delete_object(const char *classname, const char *key)
@@ -1719,6 +1727,8 @@
{
odl_field *f;
+ if( c == NULL ) return g_strdup(value);
+
f = odl_class_get_field(c, fieldname);
if (!f)
{
Index: gnue/geas/src/oql/oql.h
diff -u gnue/geas/src/oql/oql.h:1.25 gnue/geas/src/oql/oql.h:1.26
--- gnue/geas/src/oql/oql.h:1.25 Mon May 14 14:57:57 2001
+++ gnue/geas/src/oql/oql.h Wed May 23 17:57:11 2001
@@ -49,6 +49,10 @@
* (objectstore) ready SQL (do not modify/free resulting string) */
const char *oql_query_as_sql(_QueryData * query, DBType database);
+/* let any part of GEAS create SQL statements. is this really a
+ * good idea? somehow I really don't think so..... */
+_QueryData * oql_make_sql_query( const char *query );
+
/* find the classname being loaded */
const char *oql_query_get_classname(_QueryData * query);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas src/connection.c src/connection.h src...,
Treshna Enterprises <=