views:

167

answers:

1

I'm in psql trying to create a table for a python admin. It's actually an extension of a working admin, so I'm adding a new table and some relations. When I enter in the following sequence, it never executes to completion:

BEGIN;

   CREATE TABLE "work_projectinteractiveasset" (
     "id" serial NOT NULL PRIMARY KEY,
     "name" varchar(200) NOT NULL,
     "image" varchar(100) NOT NULL,
     "project_id" integer NOT NULL REFERENCES "work_project" ("id") DEFERRABLE INITIALLY DEFERRED
   );

    CREATE INDEX "work_projectinteractiveasset_project_id" 
        ON "work_projectinteractiveasset" ("project_id");

COMMIT;

The prompt ends with

NOTICE: CREATE TABLE will create implicit sequence "work_projectinteractiveasset_id_seq" for serial column "work_projectinteractiveasset.id"

But it just stays there until I ctrl-c out of it. Is there some way to force the completion?

+2  A: 

I am not actually able to produce this error. However what it sounds like is you have a lock that is stopping the work from completing.

 postgres=# create table work_project (id int primary key);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "work_project_pkey" for table "work_project"
CREATE TABLE
postgres=# BEGIN;
BEGIN
postgres=# 
postgres=#    CREATE TABLE "work_projectinteractiveasset" (
postgres(#      "id" serial NOT NULL PRIMARY KEY,
postgres(#      "name" varchar(200) NOT NULL,
postgres(#      "image" varchar(100) NOT NULL,
postgres(#      "project_id" integer NOT NULL REFERENCES "work_project" ("id") DEFERRABLE INITIALLY DEFERRED
postgres(#    );
NOTICE:  CREATE TABLE will create implicit sequence "work_projectinteractiveasset_id_seq" for serial column "work_projectinteractiveasset.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "work_projectinteractiveasset_pkey" for table "work_projectinteractiveasset"
CREATE TABLE
postgres=# 
postgres=#     CREATE INDEX "work_projectinteractiveasset_project_id" 
postgres-#         ON "work_projectinteractiveasset" ("project_id");
CREATE INDEX
postgres=# 
postgres=# COMMIT;
COMMIT

postgres=# select version();

version

PostgreSQL 8.3.8 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.4.real (Ubuntu 4.4.1-3ubuntu3) 4.4.1 (1 row)

Joshua D. Drake