Question

I would like to support PostgreSQL with my extension, however I'm running into a problem when I attempt to install it. Currently, I have the following in my XML for the install section:

<install>
   <sql>
      <file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
      <file driver="postgresql" charset="utf8">sql/install.postgresql.utf8.sql</file>
   </sql>
</install>

And here is the code for install.postgresql.utf8.sql:

CREATE TABLE "#__shoutbox" (
    "id" serial NOT NULL,
    "name" character varying(25) DEFAULT '' NOT NULL,
    "when" timestamp without time zone DEFAULT '' NOT NULL,
    "ip" character varying(15) DEFAULT '' NOT NULL,
    "msg" text NOT NULL,
    "user_id" bigint(11) DEFAULT 0 NOT NULL,
    PRIMARY KEY ("id")
);

INSERT INTO "#__shoutbox" ("name", "when", "msg", "user_id") VALUES ('JoomJunk', '2013-04-04 20:00:00', 'Welcome to the Shoutbox', '0');

I have noticed a few differences between the query for MySQL and PostgreSQL which I think I have taken into consideration, but when I attempt to install the extension, I get the following error:

Database query failed (error # %s): %s SQL=CREATE TABLE "pdo31_shoutbox" ( "id" serial NOT NULL, "name" character varying(25) DEFAULT '' NOT NULL, "when" timestamp without time zone DEFAULT '' NOT NULL, "ip" character varying(15) DEFAULT '' NOT NULL, "msg" text NOT NULL, "user_id" bigint(11) DEFAULT 0 NOT NULL, PRIMARY KEY ("id") );

There is no documentation on supporting PostgreSQL for extensions so I have done what I can by looking at the SQL file from the Joomla 3.1 installation folder.

Is the problem with my query?

Was it helpful?

Solution

The default value for when is not a valid timestamp. If you want when to be empty then remove the NOT NULL constraint so it can be NULL. Otherwise specify a valid timestamp like '2013-4-4 12:34:56'.

Bigint in postgresql does not support a size specification. It is always 64-bits (which is more then 11 decimal digits).

CREATE TABLE "pdo31_shoutbox" ( 
  "id" serial NOT NULL, 
  "name" character varying(25) DEFAULT '' NOT NULL, 
  "when" timestamp without time zone, 
  "ip" character varying(15) DEFAULT '' NOT NULL, 
  "msg" text NOT NULL, 
  "user_id" bigint DEFAULT 0 NOT NULL, 
  PRIMARY KEY ("id") 
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top