Re: [PATCH] Add crc32(text) & crc32(bytea)

Поиск
Список
Период
Сортировка
От Nathan Bossart
Тема Re: [PATCH] Add crc32(text) & crc32(bytea)
Дата
Msg-id Zqu2JJ0uW-n-pljs@nathan
обсуждение исходный текст
Ответ на Re: [PATCH] Add crc32(text) & crc32(bytea)  (Aleksander Alekseev <aleksander@timescale.com>)
Ответы Re: [PATCH] Add crc32(text) & crc32(bytea)
Список pgsql-hackers
+/*
+ * Calculate CRC32 of the given data.
+ */
+static inline pg_crc32
+crc32_sz(const char *buf, int size)
+{
+    pg_crc32    crc;
+    const char *p = buf;
+
+    INIT_TRADITIONAL_CRC32(crc);
+    while (size > 0)
+    {
+        char        c = (char) (*p);
+
+        COMP_TRADITIONAL_CRC32(crc, &c, 1);
+        size--;
+        p++;
+    }
+    FIN_TRADITIONAL_CRC32(crc);
+    return crc;
+}

I'm curious why we need to do this instead of only using the macros:

    INIT_TRADITIONAL_CRC32(crc);
    COMP_TRADITIONAL_CRC32(crc, VARDATA_ANY(in), len);
    FIN_TRADITIONAL_CRC32(crc);

+ * IDENTIFICATION
+ *    src/backend/utils/adt/hashfuncs.c

Perhaps these would fit into src/backend/utils/hash/pg_crc.c?

-- 
nathan



В списке pgsql-hackers по дате отправления: