md5 function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Miso Hlavac

    md5 function

    Hello,

    Sorry for just stupid question, but I need use md5 function in 7.4
    When I write:
    select md5('text');
    ERROR: Function md5("unknown") does not exist
    Unable to identify a function that satisfies the given argument types
    You may need to add explicit typecasts

    where is problem???

    thanx, miso


    ---------------------------(end of broadcast)---------------------------
    TIP 8: explain analyze is your friend

  • Michael Fuhr

    #2
    Re: md5 function

    On Wed, Dec 17, 2003 at 09:47:01AM +0100, Miso Hlavac wrote:[color=blue]
    > Sorry for just stupid question, but I need use md5 function in 7.4
    > When I write:
    > select md5('text');
    > ERROR: Function md5("unknown") does not exist
    > Unable to identify a function that satisfies the given argument types
    > You may need to add explicit typecasts
    >
    > where is problem???[/color]

    Are you sure the server is 7.4? What does SELECT VERSION() show?

    --
    Michael Fuhr


    ---------------------------(end of broadcast)---------------------------
    TIP 3: if posting/reading through Usenet, please send an appropriate
    subscribe-nomail command to majordomo@postg resql.org so that your
    message can get through to the mailing list cleanly

    Comment

    • Richard Huxton

      #3
      Re: md5 function

      On Wednesday 17 December 2003 08:47, Miso Hlavac wrote:[color=blue]
      > Hello,
      >
      > Sorry for just stupid question, but I need use md5 function in 7.4
      > When I write:
      > select md5('text');
      > ERROR: Function md5("unknown") does not exist
      > Unable to identify a function that satisfies the given argument
      > types You may need to add explicit typecasts[/color]

      Have a look in the contrib/crypto add-on, I think md5() is in there.

      --
      Richard Huxton
      Archonet Ltd

      ---------------------------(end of broadcast)---------------------------
      TIP 2: you can get off all lists at once with the unregister command
      (send "unregister YourEmailAddres sHere" to majordomo@postg resql.org)

      Comment

      • Michael Fuhr

        #4
        Re: md5 function

        On Wed, Dec 17, 2003 at 09:37:07AM +0000, Richard Huxton wrote:[color=blue]
        > On Wednesday 17 December 2003 08:47, Miso Hlavac wrote:[color=green]
        > > Hello,
        > >
        > > Sorry for just stupid question, but I need use md5 function in 7.4
        > > When I write:
        > > select md5('text');
        > > ERROR: Function md5("unknown") does not exist
        > > Unable to identify a function that satisfies the given argument
        > > types You may need to add explicit typecasts[/color]
        >
        > Have a look in the contrib/crypto add-on, I think md5() is in there.[/color]

        md5() should be stock in 7.4.

        mydb=> \x
        Expanded display is on.
        mydb=> \df+ md5
        List of functions
        -[ RECORD 1 ]-------+--------------------
        Result data type | text
        Schema | pg_catalog
        Name | md5
        Argument data types | text
        Owner | pgsql
        Language | internal
        Source code | md5_text
        Description | calculates md5 hash

        The internal function md5_text() is in src/backend/utils/adt/varlena.c.

        --
        Michael Fuhr


        ---------------------------(end of broadcast)---------------------------
        TIP 4: Don't 'kill -9' the postmaster

        Comment

        • Marek Lewczuk

          #5
          Re: md5 function

          Miso Hlavac wrote:
          [color=blue]
          > Hello,
          >
          > Sorry for just stupid question, but I need use md5 function in 7.4
          > When I write:
          > select md5('text');
          > ERROR: Function md5("unknown") does not exist
          > Unable to identify a function that satisfies the given argument types
          > You may need to add explicit typecasts
          >
          > where is problem???[/color]

          I'm using 7.4 and it's working.
          $ psql
          Welcome to psql 7.4, the PostgreSQL interactive terminal.

          Type: \copyright for distribution terms
          \h for help with SQL commands
          \? for help on internal slash commands
          \g or terminate with semicolon to execute query
          \q to quit

          db=# select md5('test');
          md5
          ----------------------------------
          098f6bcd4621d37 3cade4e832627b4 f6
          (1 row)



          ---------------------------(end of broadcast)---------------------------
          TIP 6: Have you searched our list archives?



          Comment

          • Jon Earle

            #6
            Re: md5 function

            On Wed, 17 Dec 2003, Michael Fuhr wrote:
            [color=blue]
            > md5() should be stock in 7.4.[/color]

            Is there a way to, when I add a record to a table, have the md5 hash
            computed and stored in the same table and then returned to the calling
            program? Currently, I'm using the perl md5 function to compute the hash
            and store it in the DB but I'm thinking that offloading this to the DB
            itself might be faster (of course, if that's not true and the way I'm
            doing things now is fine, then I'll leave it as it is).

            --
            Jon Earle

            SAVE FARSCAPE http://www.savefarscape.com/

            Vegetarian - an old Indian word meaning 'lousy hunter'.

            ---------------------------(end of broadcast)---------------------------
            TIP 3: if posting/reading through Usenet, please send an appropriate
            subscribe-nomail command to majordomo@postg resql.org so that your
            message can get through to the mailing list cleanly

            Comment

            • Doug McNaught

              #7
              Re: md5 function

              Jon Earle <je_pgsql@krono s.honk.org> writes:
              [color=blue]
              > Is there a way to, when I add a record to a table, have the md5 hash
              > computed and stored in the same table and then returned to the calling
              > program? Currently, I'm using the perl md5 function to compute the hash
              > and store it in the DB but I'm thinking that offloading this to the DB
              > itself might be faster (of course, if that's not true and the way I'm
              > doing things now is fine, then I'll leave it as it is).[/color]

              If your webserver is heavily loaded and the DB server isn't too busy,
              this might be a win; otherwise it's unlikely to make any difference.
              I think perl calls out to C to do the md5 computation, so it's just as
              fast as the version in Postgres.

              That said, the way to do it if you wanted to would be to write an
              insert_my_recor d() function that stores the data for the record and
              returns the md5 hash.

              -Doug

              ---------------------------(end of broadcast)---------------------------
              TIP 2: you can get off all lists at once with the unregister command
              (send "unregister YourEmailAddres sHere" to majordomo@postg resql.org)

              Comment

              • Reece Hart

                #8
                Re: md5 function

                On Wed, 2003-12-17 at 06:30, Jon Earle wrote:
                [color=blue]
                > Is there a way to, when I add a record to a table, have the md5 hash
                > computed and stored in the same table and then returned to the calling
                > program?[/color]


                I recommend that you write a trigger to compute the md5 and shove that
                into a column. There are several integrity advantages of having
                postgresql do it in a trigger: 1) you can guarantee that it gets done,
                2) you don't have to worry about a clients lying about the md5 or
                computing the md5 in different ways, 3) the md5 gets computed regardless
                of how the record is inserted, and 4) you can attach the trigger to
                updates as well.

                As for returning the md5 to the caller/client, that's probably best done
                with a function whose job is to insert a record and return the md5. I
                have functions like serial# <- ins_record(datu m,datum,datum), which
                merely do an insert into table and return the serial number for that
                record.

                -Reece


                --
                Reece Hart, Ph.D. rkh@gene.com, http://www.gene.com/
                Genentech, Inc. 650/225-6133 (voice), -5389 (fax)
                Bioinformatics and Protein Engineering
                1 DNA Way, MS-93 http://www.in-machina.com/~reece/
                South San Francisco, CA 94080-4990 reece@in-machina.com, GPG: 0x25EC91A0

                Comment

                Working...