This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Created attachment 156424 [details] sql-color Hi, I have a sql where is bad color. Wrong color is visible on image. Example sql: [code] CREATE FUNCTION string_strip_tags(text) RETURNS text AS $BODY$ SELECT regexp_replace(regexp_replace($1, E'(?x)<[^>]*?(\s alt \s* = \s* ([\'"]) ([^>]*?) \2) [^>]*? >', E'\3'), E'(?x)(< [^>]*? >)', '', 'g'); $BODY$ LANGUAGE sql VOLATILE COST 100; [/code] Both version works wrong. Product Version: NetBeans IDE 8.0.2 (Build 201411181905) Java: 1.7.0_79; OpenJDK 64-Bit Server VM 24.79-b02 Runtime: OpenJDK Runtime Environment 1.7.0_79-b14 System: Linux version 3.13.0-63-generic running on amd64; UTF-8; cs_CZ (nb) User directory: /home/milan/.netbeans/8.0.2 Cache directory: /home/milan/.cache/netbeans/8.0.2 Product Version: NetBeans IDE 8.1 Beta (Build 201508041349) Java: 1.8.0_51; Java HotSpot(TM) 64-Bit Server VM 25.51-b03 Runtime: Java(TM) SE Runtime Environment 1.8.0_51-b16 System: Linux version 3.13.0-63-generic running on amd64; UTF-8; cs_CZ (nb) User directory: /home/milan/.netbeans/8.1beta Cache directory: /home/milan/.cache/netbeans/8.1beta Here is o thread on forum http://forums.netbeans.org/viewtopic.php?p=166322
Retyping to Enhancement - reason: The demostrated statement is not valid SQL. This is also documented in the postgresql documentation: http://www.postgresql.org/docs/9.4/static/sql-syntax-lexical.html "[...]4.1.2.2. String Constants with C-style Escapes PostgreSQL also accepts "escape" string constants, which are an extension to the SQL standard.[...] In this case the quoting rules run contrary to SQL-99 rules. SQL grammar defines, that escaping the quoting character is done by repeating it. So: '' => empty string '''' => string with a single quote The backslash has no special meaning and this breaks your syntax highlighting (look at the last two colored characters). This was raised as a bug for mysql, which is a bit more broken. For mysql this syntax can be used in "normal strings" (if I'm not mistaken this is a configuration option), than it gets to be real fun - the bug report asked for mysql specific behavior contradicting SQL standard. Example: '\'' => SQL-99: broken string (the string is not finished), for mysql this is a single quote '\' => SQL-99: valid string with a single backslash, broken string on mysql That request was closed as WONTFIX, as it is not parseable without server knowledge. In this case it should be possible to change the lexer to support this. I would strongly advice against it. The SQL can be rewritten to adhere more to SQL standard: [code] CREATE FUNCTION string_strip_tags(text) RETURNS text AS $BODY$ SELECT regexp_replace(regexp_replace($1, E'(?x)<[^>]*?(\\s alt \\s* = \\s* ([''"]) ([^>]*?) \\2) [^>]*? >', E'\\3'), E'(?x)(< [^>]*? >)', '', 'g'); $BODY$ LANGUAGE sql VOLATILE COST 100; [/code] I changed two things: 1. I asume by \s you want to get the regexp escape sequence for white-space and \2 and \3 represent back-references, if so the documentation requires the backslashed to be doubled 2. I replace the sequence \' with the SQL conformant '' which is interpreted correctly according to documentation.