PostgreSQL syntax check without running the query

前端 未结 8 1873
时光取名叫无心
时光取名叫无心 2020-12-24 05:03

I want to verify the syntax of files containing sql queries before they can be committed in my CVS project.

In order to do that, I have a commitinfo script, but I h

8条回答
  •  清酒与你
    2020-12-24 05:35

    You could just wrap it in SELECT 1 ( ) AS a WHERE 1 = 0;

    It'll fail on validation but it won't actually execute. Here's an example query plan:

    Result  (cost=0.00..0.01 rows=1 width=0)
      One-Time Filter: false
    

提交回复
热议问题