16

I have need of a placeholder while I develop some stored procedures in PostgreSQL 8.4. I'd typically use some sort of executable noop (one that's not going to generate an error when an attempt is made to execute it), but based upon a cursory examination, there doesn't appear to be such a function in PostgreSQL. What alternatives exist?

ceving
  • 21,900
  • 13
  • 104
  • 178
andand
  • 17,134
  • 11
  • 53
  • 79

2 Answers2

22

Try

NULL;

Postgresql 8.4 manual - Noop section

1

I know this question is quite old, but recently I tried using NULL; as a query and got an error.

The alternative way I found was to just have an empty transaction like so:

BEGIN;COMMIT;

I tried to simply use ";" as a query, but psycopg2 (the python driver I use) wasn't happy with this (even through psql console was):

(psycopg2.ProgrammingError) can't execute an empty query
[SQL: ;]

N.B.

Be aware that transactions ids can run out, at which point they'll wrap around. It's fine if this NOOP is used a few times, but if it exceeds the pool of available TXIDs, then you could run into issues. Should be fine in most cases though.

Samuel Prevost
  • 1,047
  • 1
  • 11
  • 30