1

I want to install the pgcrypto extension on my postgresql installation on Windows. I found that I just have to call CREATE EXTENSION pgcrypto; but I've got an error :

Syntax error on « CREATE »
LINE 1: SELECT COUNT(*) AS total FROM (CREATE EXTENSION pgcrypto) AS...

(I'm on PostgreSQL 9.2.4 and I executed the sql line from phpPgAdmin with postgres user)

closed as too localized by dezso, Max Vernon, RolandoMySQLDBA, Mark Storey-Smith, Derek Downey Apr 23 '13 at 14:20

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Now you have a description of how to do that - why do you do it differently? CREATE ... cannot be part of a subquery. – dezso Apr 22 '13 at 17:03
  • I really typed CREATE EXTENSION pgcrypto; on the text field but it seems to automatically transform my query in SELECT ... FROM (CREATE ... Well, you tell me it can't be part of a subquery so I'll try to execue my query differently. Thank you. – Maxime L Apr 22 '13 at 22:45
2

As dezso said in the comment, the problem was that CREATE can't be part of a subquery. And phpPgAdmin transform the query before executing it so it had put the CREATE as a subquery.

So the solution was to execute the CREATE query in PgAdmin for example.

  • Interesting. So this doesn't work in phpPgAdmin? That's one for the record. Thanks much. – Chris Travers Apr 23 '13 at 12:31
0

Utility statements cannot be mixed with DML in PostgreSQL. They are fundamentally different and get executed entirely differently (for example no planning goes into them).

You should just run

CREATE EXTENSION pgcryto;

Not the answer you're looking for? Browse other questions tagged or ask your own question.