Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46965 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35372 invoked from network); 9 Feb 2010 11:30:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Feb 2010 11:30:28 -0000 Received: from [127.0.0.1] ([127.0.0.1:19631]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 0C/A2-13639-457417B4 for ; Tue, 09 Feb 2010 06:30:28 -0500 Authentication-Results: pb1.pair.com header.from=ewgraf@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ewgraf@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.78.24 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ewgraf@gmail.com X-Host-Fingerprint: 74.125.78.24 ey-out-2122.google.com Received: from [74.125.78.24] ([74.125.78.24:20678] helo=ey-out-2122.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B5/A2-13639-B96417B4 for ; Tue, 09 Feb 2010 06:27:24 -0500 Received: by ey-out-2122.google.com with SMTP id d26so1620058eyd.39 for ; Tue, 09 Feb 2010 03:27:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=AW5jS+R1dU8lv18FyFSDz4giPfyWoRX7qrtUjI8+8CU=; b=fG2C5KKeiZ8INnIlFbCKawykuKcgVu1FunrbAzdNTd9k+AZxZQ7OABhjmf1eVa29rg qfFS3NC2TPHQrIEpkYitvciCtTwvBA0GfbChHtc+a9hkv/t5gBvFkKKBKnm5Wzs8ucnE 9KB8Q0xFM9MEZoiV7B0bzYOoHP6rUOl6+0Hsk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=VAdh2reTatzxnZC2prkcRTdvID/IUaznwI8EvaOr4rFOPel/JQKTXVMzSpe80a1bt1 rbHjpLm2tMmp4L2jVLei9+nYBDerLi5trwZUiClvX2a4aIwIo53ICU1qd4aPzfwcuzOd 3q9fTuKdN50T1OScq7IpFsmeZ6icc/m2B5u1s= MIME-Version: 1.0 Received: by 10.216.90.208 with SMTP id e58mr1286612wef.57.1265714841176; Tue, 09 Feb 2010 03:27:21 -0800 (PST) Date: Tue, 9 Feb 2010 16:27:21 +0500 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: PATCH for bug #47199 From: ewgraf@gmail.com (=?KOI8-R?B?88/Lz8zP1yDl18fFzsnK?=) Index: tests/27_bug47199.phpt =================================================================== --- tests/27_bug47199.phpt (revision 0) +++ tests/27_bug47199.phpt (revision 0) @@ -0,0 +1,23 @@ +--TEST-- +Bug #47199 pg_delete fails on NULL +--SKIPIF-- + +--FILE-- + NULL, 'not_null_field' => 2),PGSQL_DML_STRING)); +@pg_query("DROP TABLE $tbl_name"); +pg_close($dbh); +echo PHP_EOL."Done".PHP_EOL; +?> +--EXPECTF-- +DELETE FROM WHERE null_field IS NULL AND not_null_field=2; +Done \ No newline at end of file Property changes on: tests/27_bug47199.phpt ___________________________________________________________________ Added: svn:executable + * Index: pgsql.c =================================================================== --- pgsql.c (revision 294790) +++ pgsql.c (working copy) @@ -5523,7 +5523,7 @@ } /* }}} */ -static inline int build_assignment_string(smart_str *querystr, HashTable *ht, const char *pad, int pad_len TSRMLS_DC) +static inline int build_assignment_string(smart_str *querystr, HashTable *ht, int where_cond, const char *pad, int pad_len TSRMLS_DC) { HashPosition pos; uint fld_len; @@ -5542,8 +5542,13 @@ return -1; } smart_str_appendl(querystr, fld, fld_len - 1); - smart_str_appendc(querystr, '='); + if (where_cond && Z_TYPE_PP(val) == IS_STRING && !strcmp(Z_STRVAL_PP(val), "NULL")) { + smart_str_appends(querystr, " IS "); + } else { + smart_str_appendc(querystr, '='); + } + switch(Z_TYPE_PP(val)) { case IS_STRING: smart_str_appendl(querystr, Z_STRVAL_PP(val), Z_STRLEN_PP(val)); @@ -5604,12 +5609,12 @@ smart_str_appends(&querystr, table); smart_str_appends(&querystr, " SET "); - if (build_assignment_string(&querystr, Z_ARRVAL_P(var_array), ",", 1 TSRMLS_CC)) + if (build_assignment_string(&querystr, Z_ARRVAL_P(var_array), 0, ",", 1 TSRMLS_CC)) goto cleanup; smart_str_appends(&querystr, " WHERE "); - if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), " AND ", sizeof(" AND ")-1 TSRMLS_CC)) + if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC)) goto cleanup; smart_str_appendc(&querystr, ';'); @@ -5705,7 +5710,7 @@ smart_str_appends(&querystr, table); smart_str_appends(&querystr, " WHERE "); - if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), " AND ", sizeof(" AND ")-1 TSRMLS_CC)) + if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC)) goto cleanup; smart_str_appendc(&querystr, ';'); @@ -5841,7 +5846,7 @@ smart_str_appends(&querystr, table); smart_str_appends(&querystr, " WHERE "); - if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), " AND ", sizeof(" AND ")-1 TSRMLS_CC)) + if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC)) goto cleanup; smart_str_appendc(&querystr, ';');