[svn:dbd-oracle] r14951 - dbd-oracle/branches/FAN
[email protected] Sun, 16 Oct 2011 14:03:37 -0700 (PDT)
| Newsgroups | perl.dbd.oracle.changes |
|---|---|
| Message-ID | <[email protected]> |
Author: byterock
Date: Sun Oct 16 14:03:36 2011
New Revision: 14951
Modified:
dbd-oracle/branches/FAN/oci8.c
Log:
working well now
Modified: dbd-oracle/branches/FAN/oci8.c
==============================================================================
--- dbd-oracle/branches/FAN/oci8.c (original)
+++ dbd-oracle/branches/FAN/oci8.c Sun Oct 16 14:03:36 2011
@@ -53,6 +53,27 @@
}
char *
+oci_ha_event_source( int source){
+
+ dTHX;
+ SV *sv;
+ switch (source) {
+ case OCI_HA_SOURCE_INSTANCE: return "INSATNCE";
+ case OCI_HA_SOURCE_DATABASE: return "DATABASE";
+ case OCI_HA_SOURCE_NODE: return "NODE";
+ case OCI_HA_SOURCE_SERVICE: return "SERVICE";
+ case OCI_HA_SOURCE_SERVICE_MEMBER: return "SERVICE_MEMBER";
+ case OCI_HA_SOURCE_ASM_INSTANCE: return "ASM_INSTANCE";
+ case OCI_HA_SOURCE_SERVICE_PRECONNECT: return "SERVICE_PRECONNECT";
+ }
+ sv = sv_2mortal(newSVpv("",0));
+ sv_grow(sv, 50);
+ sprintf(SvPVX(sv),"(UNKNOWN OCI HA Source %d)", source);
+ return SvPVX(sv);
+
+}
+
+char *
oci_sql_function_code_name(int sqlfncode)
{
dTHX;
@@ -1282,87 +1303,100 @@
void
hacb_fn( dvoid *ha_ctx, OCIEvent *eventhp) {
- ha_context_t *ctx =(ha_context_t*)ha_ctx;
+ ha_context_t *ctx =(ha_context_t*)ha_ctx;
+ OCIServer *srvhp;
dTHXa(ctx->ct_perl);
dSP;
-// XPUSHs(sv_2mortal(newSViv(evtsource)));
-// XPUSHs(sv_2mortal(newSViv(evtstatus)));
-// PUTBACK;
-// OCIEnv *envhp = (OCIEnv *)ha_ctx;
imp_dbh_t *imp_dbh = (imp_dbh_t*)ctx->imp_dbh;
sword status;
-// OraText *instname;
- // ub4 sizep;
- ub4 atrlen;
- ub4 evtsource, evtstatus;
- ub4 dbsize, dbdmsize, hostsize, instsize, servicesize, dttmbufsize;
- char *function;
-printf ("well this far 1\n\n");
- PERL_SET_CONTEXT(ctx->ct_perl);
-PerlIO_printf(DBILOGFP, " how about this my functio %sn",ctx->function);
-//PERL_SET_CONTEXT(my_perl);
-//ENTER;
-// SAVETMPS;
-
-// PUSHMARK(SP);
-//dSP;
-// PUSHMARK(SP);
-//PUTBACK;
-//printf ("well this far imp_dbh perl 1 imp_dbh=%p\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ",imp_dbh);
-//printf (" this is the p or pointer imp_drh->ha_function=%s ",(char *) imp_dbh->ha_function);
-
- // sizep = strlen(imp_dbh->ha_function);
- // function= (char*)safemalloc(strlen(imp_dbh->ha_function));
- // strcpy((char *)function,imp_dbh->ha_function);
-//printf ("well this far imp_dbh perl function=%d \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ",sizep);
+ text *event_att;
+ OCIDateTime *event_ts;
+ OraText tsbuff[50];
+ ub4 event_att_len;
+ ub4 event_code;
+ HV* ha_event;
+ PERL_SET_CONTEXT(ctx->ct_perl);
+ ha_event = newHV();
+ PUSHMARK(SP);
+ // XPUSHs(sv_2mortal(newHV(ha_event)));
-// call_pv(cb->function);
+ dbd_verbose = 15;
+ PerlIO_printf(DBILOGFP, " how about this my functio %s\n",ctx->function);
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_code, 0, OCI_ATTR_HA_SOURCE, imp_dbh->errhp, status);
+
+ hv_store(ha_event,"Source",6,sv_2mortal(newSVpv(oci_ha_event_source(event_code),strlen(oci_ha_event_source(event_code)))),0);
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_code, 0, OCI_ATTR_HA_STATUS, imp_dbh->errhp, status);
+
+ if (event_code){
+ hv_store(ha_event,"Status",6,sv_2mortal(newSVpv("UP",2)),0);
+
+ }
+ else {
+ hv_store(ha_event,"Status",6,sv_2mortal(newSVpv("DOWN",4)),0);
+ }
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_att, &event_att_len, OCI_ATTR_DBDOMAIN, imp_dbh->errhp, status);
+
+ hv_store(ha_event,"Domain",6,sv_2mortal(newSVpv((char*)event_att,event_att_len)),0);
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_att, &event_att_len, OCI_ATTR_DBNAME, imp_dbh->errhp, status);
+
+ hv_store(ha_event,"Name",5,sv_2mortal(newSVpv((char*)event_att,event_att_len)),0);
+
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_att, &event_att_len, OCI_ATTR_HOSTNAME, imp_dbh->errhp, status);
+
+ hv_store(ha_event,"Host",4,sv_2mortal(newSVpv((char*)event_att,event_att_len)),0);
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_att, &event_att_len, OCI_ATTR_INSTNAME, imp_dbh->errhp, status);
+
+ hv_store(ha_event,"Instance",8,sv_2mortal(newSVpv((char*)event_att,event_att_len)),0);
+
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_att, &event_att_len, OCI_ATTR_SERVICENAME, imp_dbh->errhp, status);
+
+ hv_store(ha_event,"Service",7,sv_2mortal(newSVpv((char*)event_att,event_att_len)),0);
+
+
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&event_ts,0, OCI_ATTR_HA_TIMESTAMP, imp_dbh->errhp, status);
+
+// OCIDateTimeToText_log_stat(imp_dbh->envhp,imp_dbh->errhp,event_ts,&event_att_len,tsbuff,status);
+
+ OCIDateTimeToText(imp_dbh->envhp,imp_dbh->errhp, event_ts, (char*) "MM-DD-YY HH24:MI:SS.FF3",
+ strlen("MM-DD-YY HH24:MI:SS.FF3"),
+ (ub1)4, (OraText *)0, 0,&event_att_len, tsbuff);
+
+ hv_store(ha_event,"Timestamp",9,sv_2mortal(newSVpv((char*)tsbuff,event_att_len)),0);
-/*dbd_verbose=11;
-status = OCIAttrGet(eventhp, OCI_HTYPE_EVENT, (dvoid *)&evtsource,
- (ub4 *)0,
- OCI_ATTR_HA_SOURCE, imp_dbh->errhp);
-//OCI_ATTR_HA_SOURCE
-printf ("well this far status=%d\n\n\n",status);
-*/
- OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&evtsource, 0, OCI_ATTR_HA_SOURCE, imp_dbh->errhp, status);
dbd_verbose=0;
-//
-switch(evtsource)
- {
- case OCI_HA_SOURCE_INSTANCE:
- printf("INSTANCE\n");
- break;
- case OCI_HA_SOURCE_DATABASE:
- printf("DATABASE\n");
- break;
- case OCI_HA_SOURCE_NODE:
- printf("NODE\n");
- break;
- case OCI_HA_SOURCE_SERVICE:
- printf("SERVICE\n");
- break;
- case OCI_HA_SOURCE_SERVICE_MEMBER:
- printf("SERVICE MEMBER\n");
- break;
- case OCI_HA_SOURCE_ASM_INSTANCE:
- printf("ASM INSTANCE\n");
- break;
- case OCI_HA_SOURCE_SERVICE_PRECONNECT:
- printf("SERVICE PRECONNECT\n");
- break;
- }
-PerlIO_printf(DBILOGFP, " how about this myevnetsource=o %d,INSTACE=%d",evtsource,OCI_HA_SOURCE_INSTANCE);
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&srvhp,0, OCI_ATTR_HA_SRVFIRST, imp_dbh->errhp, status);
+
+
+ PerlIO_printf(DBILOGFP, " how about event_att=%d nodata=%d \n",status,OCI_NO_DATA);
+
+ OCIAttrGet_log_stat(srvhp, OCI_HTYPE_SERVER, (dvoid *)&event_att,&event_att_len, OCI_ATTR_INSTNAME, imp_dbh->errhp, status);
+
+
+ PerlIO_printf(DBILOGFP, " how about srvhp=%s \n",event_att);
+
+
+
+ OCIAttrGet_log_stat(eventhp, OCI_HTYPE_EVENT, (dvoid *)&srvhp,0, OCI_ATTR_HA_SRVNEXT, imp_dbh->errhp, status);
+
+
+ PerlIO_printf(DBILOGFP, " how about event_att=%d HA next \n",status);
- XPUSHs(sv_2mortal(newSViv(evtsource)));
- XPUSHs(sv_2mortal(newSViv(evtstatus)));
+ XPUSHs(sv_2mortal(newRV((SV*)ha_event)));
PUTBACK;
- call_pv(ctx->function, G_DISCARD);
+ call_pv(ctx->function, G_DISCARD);
/*
checkerr(errhp, OCIAttrGet(eventhp, OCI_HTYPE_EVENT, (dvoid *)&evtsource,