Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2795fae

Browse files
author
Thomas G. Lockhart
committed
Fix test for table existance to allow mixed-case and whitespace in
the table name. Problem reported by Billy Allie.
1 parent c7d9aca commit 2795fae

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/backend/catalog/heap.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.64 1998/09/01 04:27:29 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.65 1998/11/12 15:39:06 thomas Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
* heap_create() - Create an uncataloged heap relation
@@ -1515,7 +1515,10 @@ StoreRelCheck(Relation rel, ConstrCheck *check)
15151515
char nulls[4] = {' ', ' ', ' ', ' '};
15161516
extern GlobalMemory CacheCxt;
15171517

1518-
sprintf(str, "select 1 from %.*s where %s",
1518+
/* Check for table's existance. Surround table name with double-quotes
1519+
* to allow mixed-case and whitespace names. - thomas 1998-11-12
1520+
*/
1521+
sprintf(str, "select 1 from \"%.*s\" where %s",
15191522
NAMEDATALEN, rel->rd_rel->relname.data, check->ccsrc);
15201523
setheapoverride(true);
15211524
planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);

0 commit comments

Comments
 (0)