Skip to content

UNSIGNED integers issue, AUTO_INCREMENT issue, int(1) issue, KEY issue #73

@hahnn

Description

@hahnn

Hello,

I tried to install this wonderful plugin to make a test instance of WordPress 6.4.1 (Apache HTTPD/PHP 8.1) to work against a PostgreSQL V14 database.

When trying to install several plugins, I've seen several problems regarding the SQl commands made on the database, there may be one or several issues, still, with one or several WordPress PostgreSQl SQL tables that cannot be created.

  1. several SQL tables cannot be created because they contain columns with integers having the UNSIGNED keyword: PostgreSQL doesn't support UNSIGNED integers so this keyword should be simply erased when creating the SQL table
  2. several SQL tables couldn't be created because they contained an int(1) column: int(1) should be probably converted to a smallint PostgreSQL type (I presume this int(1) is maybe to store a boolean value, but not sure)
  3. a lot of cases of impossibility to create PostgreSQL tables because of the presence of the AUTO_INCREMENT keyword (so in upper case). I don't really know how the conversion work in the plugin because I've seen something in the code about auto_increment (but in lower case). So a suggestion might be to convert this auto increment as a smallserial/serial/bigserial whatever the case is, so using a PHP str_ireplace function instead of the str_replace one for example.
  4. several cases of SQL tables that cannot be created because they contain KEY key_name (<column_name>) directives: this doesn't exist in PostgreSQL. The meaning of such KEY directives in MYSQL when creating tables is the creation of a synonym for an index on the columns specified: then a way to probably solve this kind of issue might be to simply erase those KEY directives from the CREATE TABLE statement, and probably create a standard index on the columns if it's not already existing.
  5. and last, I've seen an error on a specific case of UPDATE SQL command that includes an ORDER BY clause: PostgreSQL doesn't support the ORDER BY clause in UPDATE SQL requests. In such case, there are solutions like rewriting those kind of UPDATE requests using two requests: one doing a SELECT ... ORDER BY ... FOR UPDATE, then after, the UPDATE.

The 4 first points are probably fast to implement/fix, the last one might be more complicated.

For my 2 cents ;)

KR.
Nicolas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions