Fix test for table existance to allow mixed-case and whitespace in
authorThomas G. Lockhart <[email protected]>
Thu, 12 Nov 1998 15:34:30 +0000 (15:34 +0000)
committerThomas G. Lockhart <[email protected]>
Thu, 12 Nov 1998 15:34:30 +0000 (15:34 +0000)
 the table name. Problem reported by Billy Allie.

src/backend/catalog/heap.c

index a160332b232ea914a0b15f9637c2274e361afbfe..b69ca6b8d3042e2af544d1bfb53da1fd2ccd1962 100644 (file)
@@ -1515,7 +1515,10 @@ StoreRelCheck(Relation rel, ConstrCheck *check)
        char            nulls[4] = {' ', ' ', ' ', ' '};
        extern GlobalMemory CacheCxt;
 
-       sprintf(str, "select 1 from %.*s where %s",
+       /* Check for table's existance. Surround table name with double-quotes
+        * to allow mixed-case and whitespace names. - thomas 1998-11-12
+        */
+       sprintf(str, "select 1 from \"%.*s\" where %s",
                        NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
        setheapoverride(true);
        planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);