BUG #6328: Wrong error message for insert-sql
BUG #6328: Wrong error message for insert-sql
От:
eikenberg@golze.de
Дата:
The following bug has been logged on the website:
Bug reference: 6328
Logged by: Rigoletto Eikenberg
Email address: eikenberg@golze.de
PostgreSQL version: 9.0.0
Operating system: windows server 2008 R2
Description:=20=20=20=20=20=20=20=20
The sql
INSERT INTO auftragpos (orderno,position,item) VALUES
('testorder18',1,00123);
works fine,
but
INSERT INTO auftragpos (orderno,position,item) VALUES
(testorder18,1,00123);
brings error:
FEHLER: Spalte =C2=BBtestorder18=C2=AB existiert nicht (Column =C2=BBtesto=
rder18=C2=AB not
exists)
LINE 1: ...T INTO auftragpos (orderno,position,item) VALUES (testorder1...
But =C2=BBtestorder18=C2=AB is a value, not a column-name!?!?
If there is a problem it should bring a message that the value for column
"orderno" has the wrong format.
Regards
RigolettoRe: BUG #6328: Wrong error message for insert-sql
От:
"Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Дата:
wrote: =20 > INSERT INTO auftragpos (orderno,position,item) VALUES > (testorder18,1,00123); > brings error: > FEHLER: Spalte *testorder18* existiert nicht (Column > *testorder18* not exists) > LINE 1: ...T INTO auftragpos (orderno,position,item) VALUES > (testorder1... >=20 > But *testorder18* is a value, not a column-name!?!? > If there is a problem it should bring a message that the value for > column "orderno" has the wrong format. =20 'testorder18' is a literal value. Without the apostrophe quoting it is taken as an identifier, such as a column. It is entirely correct and appropriate for an error to be generated. The wording of the message could perhaps be adjusted to help the user understand their mistake more easily, since there are no columns in context from any table here; but the message is not actually wrong. Certain reserved words (such as CURRENT_DATE) would be allowed here, as would expressions of arbitrary complexity -- sub-selects, CASE predicates, functions, etc.; it would take a bit of work to sort out when something might be a malformed attempt at a literal versus a misspelled column name in a subquery. =20 -Kevin