Re: [vchkpw] pgsql fixes

2010-06-19 Thread Christopher Chan

BTW, I have also submitted this to sourceforge.

!DSPAM:4c1cc46132711699539850!



Re: [vchkpw] pgsql fixes

2010-06-19 Thread Christopher Chan


In case any of you want to use a postgresql backend, here is a patch 
that fixes some typos that get in the way of compilation and adds 
support for valias.


I wondered why I did not recall doing the code. This patch is against 
5.4.30 but it is originally from Bruce McAlister. Been using it since 
October 2008 on an opensolaris box. (a hack to make it compile on 
opensolaris not included)


!DSPAM:4c1cc6c032718704815129!



Re: [vchkpw] pgsql fixes

2010-06-19 Thread Christopher Chan

Sorry folks,

Just noticed that the vpgsql.c's create index statement had extra 
brackets. Attached patch fixes the typos, removes extra brackets and 
adds valias and sql loggin support.




!DSPAM:4c1cdcfe32715874013085!
diff -urN vpopmail-5.4.30/vpgsql.c vpopmail-5.4.30-pgsqlfixed/vpgsql.c  
--- vpopmail-5.4.30/vpgsql.c2010-06-19 20:12:30.991542810 +0800 
+++ vpopmail-5.4.30-pgsqlfixed/vpgsql.c 2010-06-19 21:59:41.951758993 +0800 
@@ -392,10 +392,10 @@   
 #endif 

 #ifdef ENABLE_SQL_LOGGING  
-qnprintf( sqlBufUpdate, SQL_BUF_SIZE,  
+qnprintf( SqlBufUpdate, SQL_BUF_SIZE,  
delete from vlog where domain = '%s', domain );   
 pgres=PQexec(pgc, SqlBufUpdate);   
-if( !pgres || PGresultStatus(pgres)!=PGRES_COMMAND_OK) {   
+if( !pgres || PQresultStatus(pgres)!=PGRES_COMMAND_OK) {   
   return(-1);  
 }  
 #endif 
@@ -445,11 +445,11 @@   
 #endif 

 #ifdef ENABLE_SQL_LOGGING  
-qnprintf( sqlBufUpdate, SQL_BUF_SIZE,  
+qnprintf( SqlBufUpdate, SQL_BUF_SIZE,  
 delete from vlog where domain = '%s' and user='%s',  
domain, user ); 
 pgres=PQexec(pgc, SqlBufUpdate);   
-if( !pgres || PGresultStatus(pgres)!=PGRES_COMMAND_OK) {   
+if( !pgres || PQresultStatus(pgres)!=PGRES_COMMAND_OK) {   
   err = -1;
 }  
 #endif 
@@ -1488,7 +1488,7 @@   

   vauth_create_table (valias, VALIAS_TABLE_LAYOUT, 1);   
 snprintf( SqlBufCreate, SQL_BUF_SIZE,  
-   create index valias_idx on valias ( %s ), VALIAS_INDEX_LAYOUT );  
+   create index valias_idx on valias  %s , VALIAS_INDEX_LAYOUT );

 pgres=PQexec( pgc, SqlBufCreate ); 
 if( !pgres || PQresultStatus(pgres)!=PGRES_COMMAND_OK ) {  
@@ -1614,3 +1614,69 @@