(I've just posted this on sourceforge, but it seems to be a real bug so I thought I'd bring it to your notice.)
When I attempt to add a new field to a table, I get an error message that my SQL is malformed.
Using phppgadmin, I select a table and attempt to add a new field. I fill in the web form to with the name of the field ("PhoneNumber"), varchar, length 64, and NOT NULL (the default selection).
The system comes back with an error message and garbled SQL:
Warning: pg_exec() query failed: ERROR: parser: parse error at or near "SET" at character 80 in /usr/share/phppgadmin/tbl_addfield.php on line 32
Error - /usr/share/phppgadmin/tbl_addfield.php -- Line: 32
PostgreSQL said: ERROR: parser: parse error at or near "SET" at character 80
ALTER TABLE "importer" ADD "PhoneNumber" varchar (64) ;
ALTER TABLE "importer" SET NOT NULL NOT NULL;
Note that this last line is not sensible -- NOT NULL NOT NULL. The error does not happen if I select NULL from the drop-down box.
Since I've just started using the package this morning, I'm reluctant to propose patches, but it seems from a cursory examination of the code that
(a) this is in fact the output I'd expect to see, given line 22
(b) according to the Postgres documentation, it's illegal to create a non-null field in an existing table, I suppose even if it's empty of data: " A new column cannot have a not-null constraint since the column initially has to contain null values. But you can add a not-null constraint later. " (Postgres docs, section 2.6.1).
I am running Debian Linux, the latest Debian (unstable) phhpgadmin (2.4.2-2), and SQL version 7.3.3.
Sent via Contact Form on phppgadmin.sourceforge.net