Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-5308

Problems using SQL files with UTF-8 Byte Order Mark (BOM)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 12.1
    • None
    • db - SQL Editor
    • None

    Description

      While using NetBeans for doing database development work there are files that have UTF-8 BOM (Byte Order Mark) at the beginning that cause execution to fail mysteriously due to the invisible characters.

      [1:1] Failed in 0 s.
      [Exception, Error code 0, SQLState 42601] ERROR: syntax error at or near "DO"
       Position: 1
       Line 1, column 1
      
      
      Execution finished after 0.004 s, 7 errors occurred.
      

      Retyping the first line after backspacing it away doesn't remove the characters. Selecting the very first character to the end of the file doesn't help either. Checking View->Show non printable characters shows whitespace characters, but not the BOM. the Only visual clue what's happening is that the syntax highlighter isn't highlighting the first line correctly. Viewing the file with a hex editor is what revealed the BOM at the beginning causing all of the problems.

      The BOM is stripped away when opening the file in the editor or running it from the Projects panel (Right-click -> Run File). It is debatable whether the BOM should be stripped or preserved on save of the file.

      Steps to reproduce the problem:

      • Import the attached UTF-8 (+BOM) SQL file into a project that is set to UTF-8 encoding (Right-click -> Properties -> Sources -> Encoding)
      • Open the SQL editor
      • Pick a database connection (PostgreSQL 10.4 in my case)
      • Click the Run SQL button at the top
        • Query fails similarly above due to a problem at line1 column 1
      • Select all in the file, right-click -> Run Selection
        • Query fails similarly
      • Try putting a new line at the beginning, select just the first SQL command to the end of the file and Run Selection
        • Query fails similarly
      • Try running the SQL file from the Projects panels, right-click -> Run File
        • Query fails similarly

      Attachments

        1. 386.sql
          0.1 kB
          Chris McGee

        Activity

          People

            Unassigned Unassigned
            cmcgee-mac Chris McGee
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: