| From: | Steve Chavez <steve(at)supabase(dot)io> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | [PATCH] clarify palloc comment on quote_literal_cstr |
| Date: | 2025-04-06 17:37:24 |
| Message-ID: | CAGRrpzZ9bToRWS+fAnjxDJrxwZN1QcJ-y1Pn2yg=Hst6rydLtw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello hackers,
I found the numbers in `quote_literal_cstr` palloc quite magical. So I've
added a comment clarifying what they mean. The change is small:
/* We make a worst-case result area; wasting a little space is OK */
- result = palloc(len * 2 + 3 + 1);
+ result = palloc(
+ (len * 2) /* worst-case doubling for every character if
each one is a quote */
+ + 3 /* two outer quotes + possibly 'E' if needed */
+ + 1 /* null terminator */
+ );
Best regards,
Steve
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-clarify-palloc-comment-on-quote_literal_cstr.patch | text/x-patch | 996 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bernd Helmle | 2025-04-06 17:39:56 | Re: Modern SHA2- based password hashes for pgcrypto |
| Previous Message | Álvaro Herrera | 2025-04-06 17:34:51 | Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote |