diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-09-27 18:40:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-09-27 18:40:10 +0000 |
commit | c92f7e258ee579abd0f95183598edf250d351b2c (patch) | |
tree | 10c6b377a74c61b71ece70cfd3cb209795bf1051 /src/backend/commands | |
parent | 996b203e621bc76985ff0156b4f2ef720944b41b (diff) | |
download | postgresql-c92f7e258ee579abd0f95183598edf250d351b2c.tar.gz postgresql-c92f7e258ee579abd0f95183598edf250d351b2c.zip |
Replace strncpy with strlcpy in selected places that seem possibly relevant
to performance. (A wholesale effort to get rid of strncpy should be
undertaken sometime, but not during beta.) This commit also fixes dynahash.c
to correctly truncate overlength string keys for hashtables, so that its
callers don't have to anymore.
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/prepare.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index eccce9d10d6..46824a48e5d 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -10,7 +10,7 @@ * Copyright (c) 2002-2006, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.64 2006/09/07 22:52:00 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.65 2006/09/27 18:40:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -314,7 +314,6 @@ StorePreparedStatement(const char *stmt_name, MemoryContext oldcxt, entrycxt; char *qstring; - char key[NAMEDATALEN]; bool found; /* Initialize the hash table, if necessary */ @@ -322,10 +321,7 @@ StorePreparedStatement(const char *stmt_name, InitQueryHashTable(); /* Check for pre-existing entry of same name */ - /* See notes in FetchPreparedStatement */ - StrNCpy(key, stmt_name, sizeof(key)); - - hash_search(prepared_queries, key, HASH_FIND, &found); + hash_search(prepared_queries, stmt_name, HASH_FIND, &found); if (found) ereport(ERROR, @@ -355,7 +351,7 @@ StorePreparedStatement(const char *stmt_name, /* Now we can add entry to hash table */ entry = (PreparedStatement *) hash_search(prepared_queries, - key, + stmt_name, HASH_ENTER, &found); @@ -384,7 +380,6 @@ StorePreparedStatement(const char *stmt_name, PreparedStatement * FetchPreparedStatement(const char *stmt_name, bool throwError) { - char key[NAMEDATALEN]; PreparedStatement *entry; /* @@ -392,19 +387,10 @@ FetchPreparedStatement(const char *stmt_name, bool throwError) * anything, therefore it couldn't possibly store our plan. */ if (prepared_queries) - { - /* - * We can't just use the statement name as supplied by the user: the - * hash package is picky enough that it needs to be NUL-padded out to - * the appropriate length to work correctly. - */ - StrNCpy(key, stmt_name, sizeof(key)); - entry = (PreparedStatement *) hash_search(prepared_queries, - key, + stmt_name, HASH_FIND, NULL); - } else entry = NULL; |