![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
"Michael Lush" <michael (AT) galton (DOT) ucl.ac.uk> writes: CREATE OR REPLACE FUNCTION quote_bug(text) RETURNS text AS $$ $data = $_[0]; $sql = "SELECT * FROM test WHERE foo = '$data'"; $rv_unique = spi_exec_query($sql); It's hardly a bug that you get a syntax error when $data contains a single quote. It's up to you to construct a well-formed query string to give to spi_exec_query, and this code is not doing that. regards, tom lane |
#2
| |||
| |||
|
|
michael <michael (AT) galton (DOT) ucl.ac.uk> writes: On Wed, 1 Feb 2006, Tom Lane wrote: It's hardly a bug that you get a syntax error when $data contains a single quote. It's up to you to construct a well-formed query string to give to spi_exec_query, and this code is not doing that. As I understand it the input strings are correctly escaped INSERT INTO test VALUES ('No problem here'); INSERT INTO test VALUES ('It''s a problem here'); INSERT INTO test VALUES ('It\'s also a problem here'); Yeah, but by the time your trigger sees it, the data isn't escaped anymore. |
![]() |
| Thread Tools | |
| Display Modes | |
| |