summaryrefslogtreecommitdiff
path: root/contrib/pgcrypto/pgp-pgsql.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-05-04 16:42:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-05-04 16:42:41 +0000
commit45173ae24e308061c008f77996f3edbebe0e4dc2 (patch)
tree9dd9bd3cc11648b13dd0ccee488014421adbe274 /contrib/pgcrypto/pgp-pgsql.c
parent0ff74f03b153abfe4cc10abe7be5a13cdbcac782 (diff)
downloadpostgresql-45173ae24e308061c008f77996f3edbebe0e4dc2.tar.gz
Use new cstring/text conversion functions in some additional places.
These changes assume that the varchar and xml data types are represented the same as text. (I did not, however, accept the portions of the proposed patch that wanted to assume bytea is the same as text --- tgl.) Brendan Jurd
Diffstat (limited to 'contrib/pgcrypto/pgp-pgsql.c')
-rw-r--r--contrib/pgcrypto/pgp-pgsql.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/contrib/pgcrypto/pgp-pgsql.c b/contrib/pgcrypto/pgp-pgsql.c
index 9f38c621c9..5ffa5ad0a9 100644
--- a/contrib/pgcrypto/pgp-pgsql.c
+++ b/contrib/pgcrypto/pgp-pgsql.c
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.9 2007/02/27 23:48:06 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-pgsql.c,v 1.10 2008/05/04 16:42:41 tgl Exp $
*/
#include "postgres.h"
@@ -34,6 +34,7 @@
#include "fmgr.h"
#include "parser/scansup.h"
#include "mb/pg_wchar.h"
+#include "utils/builtins.h"
#include "mbuf.h"
#include "px.h"
@@ -140,7 +141,6 @@ static text *
convert_charset(text *src, int cset_from, int cset_to)
{
int src_len = VARSIZE(src) - VARHDRSZ;
- int dst_len;
unsigned char *dst;
unsigned char *csrc = (unsigned char *) VARDATA(src);
text *res;
@@ -149,10 +149,7 @@ convert_charset(text *src, int cset_from, int cset_to)
if (dst == csrc)
return src;
- dst_len = strlen((char *) dst);
- res = palloc(dst_len + VARHDRSZ);
- memcpy(VARDATA(res), dst, dst_len);
- SET_VARSIZE(res, dst_len + VARHDRSZ);
+ res = cstring_to_text((char *) dst);
pfree(dst);
return res;
}