Bug#762378: phppgadmin: partial SQL execution failure

2015-02-24 Thread Jean-Michel Nirgal Vourgère
Control: tags -1 patch
Description: Stop ignoring sql queries whose ending ';' is on its own line
Author: Jean-Michel Nirgal Vourgère jmv_...@nirgal.com
Bug: https://sourceforge.net/p/phppgadmin/bugs/448/
Bug-Debian: https://bugs.debian.org/762378
Forwarded: https://github.com/phppgadmin/phppgadmin/pull/27
Last-Update: 2015-03-24

Index: phppgadmin/classes/database/Postgres.php
===
--- phppgadmin.orig/classes/database/Postgres.php
+++ phppgadmin/classes/database/Postgres.php
@@ -7504,17 +7504,18 @@ class Postgres extends ADODB_base {
 			else if (substr($line, $i, 1) == ';'  !$bslash_count  !$paren_level)
 			{
 			$subline = substr(substr($line, 0, $i), $query_start);
-/* is there anything else on the line? */
-if (strspn($subline,  \t\n\r) != strlen($subline))
+/*
+ * insert a cosmetic newline, if this is not the first
+ * line in the buffer
+	 */
+if (strlen($query_buf)  0)
+$query_buf .= \n;
+/* append the line to the query buffer */
+$query_buf .= $subline;
+
+/* is there anything in the query_buf? */
+if (trim($query_buf))
 {
-	/*
-	 * insert a cosmetic newline, if this is not the first
-	 * line in the buffer
-		 */
-	if (strlen($query_buf)  0)
-	$query_buf .= \n;
-	/* append the line to the query buffer */
-	$query_buf .= $subline;
 	$query_buf .= ';';
 
 		// Execute the query. PHP cannot execute


signature.asc
Description: OpenPGP digital signature


Bug#762378: phppgadmin: partial SQL execution failure

2015-02-23 Thread Jean-Michel Nirgal Vourgère
I could reproduce the problem, and somewhat reduce it:

It looks like lines that contain a \n just before the semi column are
ignored. oO

Example with sql files:

This works:
-- 8 -
delete from translations where lang='en' and internal=1;
-- 8 -


This doesn't work:
-- 8 -
delete from translations where lang='en' and internal=1
;
-- 8 -


But this works:
-- 8 -
delete from translations where lang='en'
and internal=1;
-- 8 -





signature.asc
Description: OpenPGP digital signature


Bug#762378: phppgadmin: partial SQL execution failure

2014-09-21 Thread Marc Dequènes (Duck)

Package: phppgadmin
Version: 5.1-1

Coin,

When executing the attached SQL commands as a file upload (i did not  
try to paste it) i got this:

START TRANSACTION
DELETE 1
INSERT 0 1
DELETE 0
COMMIT

This execution silently skip the second INSERT statement and mislead  
the user in thinking it was run correctly (i checked the second insert  
is not done, this is not just a wrong display).


Using psql with the same script i got:
START TRANSACTION
DELETE 1
INSERT 0 1
DELETE 0
INSERT 0 325
COMMIT

Which means phppgadmin should have been able to run it correctly.

Regards.

--
Marc Dequènes (Duck)



english.sql
Description: application/sql


pgpLnzPUaQpk9.pgp
Description: PGP Digital Signature