input: Write a Python function to execute a SQL query to select all rows from a PostgreSQL table and return the results.
  assert execute_query('SELECT * FROM table_name') == [('row1_col1_value', 'row1_col2_value'), ('row2_col1_value', 'row2_col2_value')]
  assert execute_query('SELECT * FROM table_name WHERE id=1') == [('row1_col1_value', 'row1_col2_value')]
  assert execute_query('SELECT * FROM table_name WHERE id=999') == []
output: import psycopg2
  
  def execute_query(query):
      try:
          # Connect to your PostgreSQL database
          connection = psycopg2.connect(
              dbname="your_dbname",
              user="your_username",
              password="your_password",
              host="your_host",
              port="your_port"
          )
          cursor = connection.cursor()
          
          # Execute the provided query
          cursor.execute(query)
          
          # Fetch all rows from the executed query
          result = cursor.fetchall()
          
          return result
          
      except Exception as error:
          print(f"Error executing query: {error}")
          return []
          
      finally:
          if connection:
              cursor.close()
              connection.close()