latest SVN and PostgreSQL

  • Wesley Morgan

    Wesley Morgan - 2007-01-02

    I hacked together a version of a postgresql driver for the svn source. There are some changes to the SQL again, mainly around sql-isms that aren't 100% portable. Where clauses like "WHERE (8 & 2)" should be rewritten to "WHERE ((8 & 2) = 2)". I would have had this the same day the SVN was released, but I didn't have much time and it took me a little longer to realize that apparently the SQLRow objects were still being used after the SQLResult object was destroyed, and since libpq does not provide a row type that can exist outside of the result, crashes ensued. Rather than implementing some crazy reference counting, we just do what SQLite does and store the result in a char **.

    There is also quite a bit of use of "\" as an escape character, which is considered dangerous in Postgres because of issues related to multi-byte encoding. For the most part, "'" is the desired escape character, but really the escaping should be done by the library, which takes client encoding into account and should always return a properly escaped string.

    Also, I noticed what could be a potential problem in the MySQL quote routine:

        char *q = (char *)MALLOC(value.length() * 2 + 2);

    Assuming the "+2" is for the surrounding "'", then this string will not have the storage for a terminating NULL character, and would result in writing the "'" past the end of the string... Unless the MALLOC() macro is automatically including space for the null??

    On to the patch:

    On a final note, the SVN version does not actually work with my DSM-520 player. I've tried it with both postgres and sqlite3, and in each case the player gives me the error "Unable to access this folder." when I try to browse any content. Oops! Well, at least the storage seems to work :)

    • Jin

      Jin - 2007-01-02


      first of all thanks for the contribution, I'll let Leo comment the database-specific questions, what I would be interested in is the DSM-520 info. Could you please make an ethereal log of the following:
      start MediaTomb
      start DSM-520
      try to browse the server

      We had some issues with the DSM-320, it crashed without the following upnp:class settings (import section):
              <map from="audio/*" to="object.item.audioItem"/>
              <map from="application/ogg" to="object.item.audioItem"/>
              <map from="video/*" to="object.item.videoItem"/>
              <map from="image/*" to="object.item.imageItem"/>

      and it also required a custom http header for seamless avi playback (server section):
                  <add header="X-User-Agent: redsonic"/>

      However, I doubt that the browsing issue is related to the things above. I'd be very interested in seeing the log.


      • Wesley Morgan

        Wesley Morgan - 2007-01-02

        Adding the user-agent lets it browse the root folder, the PC directory, some of the audio directory and some of the photo directory. The video directory is still inaccessible. I'll send you the tcpdump capture separately.

    • Jin

      Jin - 2007-01-03

      Thanks for the dump, looks like we will have to do some debugging, I'll contact you via e-mail.


Log in to post a comment.