93eabe
From: Peter Lemenkov <lemenkov@gmail.com>
93eabe
Date: Tue, 19 Mar 2013 13:36:44 +0400
fa3f24
Subject: [PATCH] Fix for old Perl in RHEL5
93eabe
93eabe
Partially revert a3cec180516b16ac84fc7e457cec2a03039e04bf
93eabe
93eabe
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
93eabe
93eabe
diff --git a/modules/db_perlvdb/perlvdb_conv.c b/modules/db_perlvdb/perlvdb_conv.c
93eabe
index 511e076..ce1d45c 100644
93eabe
--- a/modules/db_perlvdb/perlvdb_conv.c
93eabe
+++ b/modules/db_perlvdb/perlvdb_conv.c
93eabe
@@ -215,7 +215,6 @@ SV *cond2perlcond(db_key_t key, db_op_t op, db_val_t* val) {
93eabe
 
93eabe
 int perlresult2dbres(SV *perlres, db_res_t **r) {
93eabe
 	
93eabe
-	HV * result = NULL;
93eabe
 	SV *colarrayref = NULL;
93eabe
 	AV *colarray = NULL;
93eabe
 	SV *acol = NULL;
93eabe
@@ -253,14 +252,11 @@ int perlresult2dbres(SV *perlres, db_res_t **r) {
93eabe
 		goto error;
93eabe
 	}
93eabe
 	
93eabe
-	result = (HV*)SvRV(perlres);
93eabe
-	 
93eabe
 	/* Memory allocation for C side result structure */
93eabe
 	*r = db_new_result();
93eabe
 	/* Fetch column definitions */
93eabe
-	colarrayref = *hv_fetchs(result, PERL_VDB_COLDEFSMETHOD, 0);
93eabe
-	/*	colarrayref = perlvdb_perlmethod(perlres, PERL_VDB_COLDEFSMETHOD,
93eabe
-			NULL, NULL, NULL, NULL); */
93eabe
+	colarrayref = perlvdb_perlmethod(perlres, PERL_VDB_COLDEFSMETHOD,
93eabe
+			NULL, NULL, NULL, NULL);
93eabe
 	if (!(SvROK(colarrayref))) goto error;
93eabe
 	colarray = (AV *)SvRV(colarrayref);
93eabe
 	
93eabe
@@ -297,25 +293,9 @@ int perlresult2dbres(SV *perlres, db_res_t **r) {
93eabe
 		
93eabe
 
93eabe
 	}
93eabe
-	if(hv_exists(result, "rows", 4)){
93eabe
-		rowarrayref =(SV*) hv_fetchs(result, "rows", 0);
93eabe
-	}else{
93eabe
-                (*r)->n = 0;
93eabe
-                (*r)->res_rows = 0;
93eabe
-                (*r)->last_row = 0;
93eabe
-                goto end;
93eabe
+	rowarrayref = perlvdb_perlmethod(perlres, PERL_VDB_ROWSMETHOD,
93eabe
+			NULL, NULL, NULL, NULL);
93eabe
 
93eabe
-	}
93eabe
-
93eabe
-	if(rowarrayref){
93eabe
-		rowarrayref = *((SV**)rowarrayref);
93eabe
-	}else{
93eabe
-                (*r)->n = 0;
93eabe
-                (*r)->res_rows = 0;
93eabe
-                (*r)->last_row = 0;
93eabe
-                goto end;
93eabe
-
93eabe
-	}
93eabe
 	if (!(SvROK(rowarrayref))) { /* Empty result set */
93eabe
 		(*r)->n = 0;
93eabe
 		(*r)->res_rows = 0;
93eabe
@@ -354,11 +334,10 @@ int perlresult2dbres(SV *perlres, db_res_t **r) {
93eabe
 				cur_val.nul = 1;
93eabe
 				continue;
93eabe
 			}
93eabe
-			atypesv = *hv_fetchs((HV*)SvRV(aelement),PERL_VDB_TYPEMETHOD,0); /*aelement->{type} */
93eabe
-			atype = SvIV(atypesv);
93eabe
-			/*atypesv = perlvdb_perlmethod(aelement,
93eabe
+			atypesv = perlvdb_perlmethod(aelement,
93eabe
 						PERL_VDB_TYPEMETHOD,
93eabe
-						NULL, NULL, NULL, NULL);*/
93eabe
+						NULL, NULL, NULL, NULL);
93eabe
+			atype = SvIV(atypesv);
93eabe
 			aval = perlvdb_perlmethod(aelement, PERL_VDB_DATAMETHOD,
93eabe
 					NULL, NULL, NULL, NULL);
93eabe
 			(*r)->rows[i].values[j].type = atype;