Uploaded image for project: 'iplike'
  1. iplike
  2. IPL-31

iplike with postgres 9.4 and higher

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.1
    • Component/s: None
    • Labels:
      None

      Description

      if you plan to migrate to postgres 10 you have to make some changes to iplike as the language interface has changed.

      Due to https://www.postgresql.org/docs/9.4/xfunc-c.html the newer "version 1" calling convention ist available already since postgres 9.4

      Below is what I did to get iplike running with postgres 10.5 (SUSE SLES12 rpm package) WITHOUT ANY WARRANTY.

      diff --git a/iplike.c b/iplike.c
      index 3013417..12e6beb 100644
      — a/iplike.c
      +++ b/iplike.c
      @@ -1056,13 +1056,18 @@ const int getIPv6RangeInfo(const char *p, int len, OctetRangeArray_t *const dest
        *     Returns true if it matches, false if it does not
        *
        */
      -
      -const bool iplike(const text *const value, const text *const rule)
      +PG_FUNCTION_INFO_V1(iplike);
      +Datum iplike(PG_FUNCTION_ARGS)
       

      { +        text *value, *rule;   /* Parameters */ +         bool    rcode = false;          /* the return code */         int     i,j;                    /* loop variables */         int     octets[9];              /* the split apart IP address */   +        value=PG_GETARG_TEXT_P(0); +        rule=PG_GETARG_TEXT_P(1); +         // the matching ranges for each octet         OctetRangeArray_t ranges[9];   @@ -1192,5 +1197,5 @@ const bool iplike(const text *const value, const text *const rule)                 if (ranges[i].ranges != NULL) free(ranges[i].ranges);         }

      -       return rcode;
      +       PG_RETURN_BOOL(rcode);
       }

        Attachments

          Activity

            People

            • Assignee:
              ranger Benjamin Reed
              Reporter:
              michael.seibold@barmer-gek.de Michael
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: