Mantis - Quercus
Viewing Issue Advanced Details
4378 major always 02-07-11 09:12 08-30-11 07:45
geleont  
 
normal  
new 4.0.14  
open  
none    
none  
0004378: pq_query_params Return false, in case query is not SELECT
Minimal code to reproduce
$res = pg_query_params($db,"INSERT INTO files (file, user, session_id, book) VALUES ($1,$2,$3,$4) RETURNING id",
                            array("11222",
                           "33g",
                           "AAAS3wpSVE",
                           "11", ));

var_dump(pg_fetch_all($res));
should print id but returns false

I think that caused by this lines of quercus code:
if (!pstmt.execute(env))
        return null;

      if (pstmt.getStatementType().equals("SELECT")) {
        PostgresResult result = new PostgresResult(
            env, null, pstmt.getResultSet(), null);
        conn.setResultResource(result);
        return result;
      } else {
        // XXX: ??? return type?
        return null;
        // return pstmt;
      }

As we can see if query type is not SELECT method every time return null.

Notes
(0005030)
geleont   
02-09-11 03:54   
Hi, I have fixed this bug by my self. How can I send solution to you?
(0005481)
tokeefe   
08-30-11 07:45   
I am able to confirm this issue.

The only workaround I've found so far is to check pg_last_notice on all non-SELECTs.