diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-01-30 20:09:53 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-01-30 20:09:53 +0000 |
commit | eb8892662564a413bc411b1b486ee095b74b8149 (patch) | |
tree | 4e50ee86133e334766ac1c978b9dafbce7115a23 /src | |
parent | 07be293a971af2180f94dd571021df711dd343ac (diff) | |
download | postgresql-eb8892662564a413bc411b1b486ee095b74b8149.tar.gz postgresql-eb8892662564a413bc411b1b486ee095b74b8149.zip |
Avoid performing encoding conversion on command tag strings during EndCommand.
Since all current and foreseeable future command tags will be pure ASCII,
there is no need to do conversion on them. This saves a few cycles and also
avoids polluting otherwise-pristine subtransaction memory contexts, which
is the cause of the backend memory leak exhibited in bug #5302. (Someday
we'll probably want to have a better method of determining whether
subtransaction contexts need to be kept around, but today is not that day.)
Backpatch to 8.0. The cycle-shaving aspect of this would work in 7.4
too, but without subtransactions the memory-leak aspect doesn't apply,
so it doesn't seem worth touching 7.4.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/tcop/dest.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index ac0dc5e7c21..4488f128e6a 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.76 2010/01/02 16:57:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.77 2010/01/30 20:09:53 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -142,7 +142,11 @@ EndCommand(const char *commandTag, CommandDest dest) { case DestRemote: case DestRemoteExecute: - pq_puttextmessage('C', commandTag); + /* + * We assume the commandTag is plain ASCII and therefore + * requires no encoding conversion. + */ + pq_putmessage('C', commandTag, strlen(commandTag) + 1); break; case DestNone: @@ -183,7 +187,7 @@ NullCommand(CommandDest dest) if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) pq_putemptymessage('I'); else - pq_puttextmessage('I', ""); + pq_putmessage('I', "", 1); break; case DestNone: |