docs: def check_file(filename=None, show_filename=False, add_semicolon=False):
      """
      Check whether an input file is valid PostgreSQL. If no filename is
      passed, STDIN is checked.
  
      Returns a status code: 0 if the input is valid, 1 if invalid.
      """
      # either work with sys.stdin or open the file
      if filename is not None:
          with open(filename, "r") as filelike:
              sql_string = filelike.read()
      else:
          with sys.stdin as filelike:
              sql_string = sys.stdin.read()
  
      success, msg = check_string(sql_string, add_semicolon=add_semicolon)
  
      # report results
      result = 0
      if not success:
          # possibly show the filename with the error message
          prefix = ""
          if show_filename and filename is not None:
              prefix = filename + ": "
          print(prefix + msg)
          result = 1
  
      return result