]> granicus.if.org Git - postgresql/blobdiff - src/backend/utils/adt/quote.c
Add support for EUI-64 MAC addresses as macaddr8
[postgresql] / src / backend / utils / adt / quote.c
index 2a6edeaafc9853bb634252425ec47bd823b7b729..43e5bb79621e28c3c1829b79adf25dfb5be751af 100644 (file)
@@ -3,7 +3,7 @@
  * quote.c
  *       Functions for quoting identifiers and literals
  *
- * Portions Copyright (c) 2000-2011, PostgreSQL Global Development Group
+ * Portions Copyright (c) 2000-2017, PostgreSQL Global Development Group
  *
  *
  * IDENTIFICATION
@@ -76,17 +76,17 @@ quote_literal_internal(char *dst, const char *src, size_t len)
 Datum
 quote_literal(PG_FUNCTION_ARGS)
 {
-       text       *t = PG_GETARG_TEXT_P(0);
+       text       *t = PG_GETARG_TEXT_PP(0);
        text       *result;
        char       *cp1;
        char       *cp2;
        int                     len;
 
-       len = VARSIZE(t) - VARHDRSZ;
+       len = VARSIZE_ANY_EXHDR(t);
        /* We make a worst-case result area; wasting a little space is OK */
        result = (text *) palloc(len * 2 + 3 + VARHDRSZ);
 
-       cp1 = VARDATA(t);
+       cp1 = VARDATA_ANY(t);
        cp2 = VARDATA(result);
 
        SET_VARSIZE(result, VARHDRSZ + quote_literal_internal(cp2, cp1, len));
@@ -107,7 +107,7 @@ quote_literal_cstr(const char *rawstr)
 
        len = strlen(rawstr);
        /* We make a worst-case result area; wasting a little space is OK */
-       result = palloc(len * 2 + 3);
+       result = palloc(len * 2 + 3 + 1);
 
        newlen = quote_literal_internal(result, rawstr, len);
        result[newlen] = '\0';