On Mon, Jan 09, 2017 at 07:52:11PM -0300, Alvaro Herrera wrote:
> David Fetter wrote:
>
> > + if (query->commandType == CMD_UPDATE || query->commandType ==
> > CMD_DELETE)
> > + {
> > + /* Make sure there's something to look at. */
> > + Assert(query->jointree != NULL);
> > + if (query->jointree->quals == NULL)
> > + ereport(ERROR,
> > + (errcode(ERRCODE_SYNTAX_ERROR),
> > + errmsg("%s requires a WHERE clause
> > when the require_where hook is enabled.",
> > + query->commandType ==
> > CMD_UPDATE ? "UPDATE" : "DELETE"),
> > + errhint("To %s all rows, use \"WHERE
> > true\" or similar.",
> > + query->commandType ==
> > CMD_UPDATE ? "update" : "delete")));
> > + }
>
> Per my earlier comment, I think this should use
> ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED instead.
Fixed.
> I think this should say "the \"require_hook\" extension" rather than
> use the term "hook".
Fixed.
> (There are two or three translatability rules violations in this
> snippet,
Based on the hints in the docs docs around translation, I've
refactored this a bit.
> but since this is an extension and those are not translatable, I
> won't say elaborate further.)
"Not translatable," or "not currently translated?"
Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
commit 42f50cb8fa9848bbbc6776bcea03293a6b28b2d4
Author: Alvaro Herrera <[email protected]>
Date: Tue Jan 10 11:41:13 2017 -0300
Fix overflow check in StringInfo; add missing casts
A few thinkos I introduced in fa2fa9955280. Also, amend a similarly
broken comment.
Report by Daniel Vérité.
Authors: Daniel Vérité, Álvaro Herrera
Discussion:
https://postgr.es/m/[email protected]
diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c
index bdc204e..3eee49b 100644
--- a/src/backend/lib/stringinfo.c
+++ b/src/backend/lib/stringinfo.c
@@ -313,19 +313,20 @@ enlargeStringInfo(StringInfo str, int needed)
* for efficiency, double the buffer size each time it overflows.
* Actually, we might need to more than double it if 'needed' is big...
*/
- newlen = 2 * str->maxlen;
- while (needed > newlen)
+ newlen = 2 * (Size) str->maxlen;
+ while ((Size) needed > newlen)
newlen = 2 * newlen;
/*
- * Clamp to the limit in case we went past it. Note we are assuming
here
- * that limit <= INT_MAX/2, else the above loop could overflow. We will
- * still have newlen >= needed.
+ * Clamp to the limit in case we went past it. (We used to depend on
+ * limit <= INT32_MAX/2, to avoid overflow in the loop above; we no
longer
+ * depend on that, but if "needed" and str->maxlen ever become wider, we
+ * will need similar caution here.) We will still have newlen >=
needed.
*/
if (newlen > limit)
newlen = limit;
- str->data = (char *) repalloc_huge(str->data, (Size) newlen);
+ str->data = (char *) repalloc_huge(str->data, newlen);
str->maxlen = newlen;
}
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers