Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8d507c2

Browse files
author
Thomas G. Lockhart
committed
Additional fixes for mixed-case table names from Billy Allie.
1 parent 91a6248 commit 8d507c2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/backend/catalog/heap.c

+5-2
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.65 1998/11/12 15:39:06 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.66 1998/11/17 14:26:39 thomas Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
* heap_create() - Create an uncataloged heap relation
@@ -1444,7 +1444,10 @@ StoreAttrDefault(Relation rel, AttrDefault *attrdef)
14441444
extern GlobalMemory CacheCxt;
14451445

14461446
start:;
1447-
sprintf(str, "select %s%s from %.*s", attrdef->adsrc, cast,
1447+
/* Surround table name with double quotes to allow mixed-case and
1448+
* whitespaces in names. - BGA 1998-11-14
1449+
*/
1450+
sprintf(str, "select %s%s from \"%.*s\"", attrdef->adsrc, cast,
14481451
NAMEDATALEN, rel->rd_rel->relname.data);
14491452
setheapoverride(true);
14501453
planTree_list = (List *) pg_parse_and_plan(str, NULL, 0, &queryTree_list, None, FALSE);

src/bin/psql/psql.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.163 1998/10/26 01:04:37 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.164 1998/11/17 14:26:31 thomas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -460,12 +460,17 @@ tableList(PsqlSettings *pset, bool deep_tablelist, char info_type,
460460
perror("malloc");
461461

462462
/* load table table */
463+
/* Put double quotes around the table name to allow for mixed-case
464+
* and whitespaces in the table name. - BGA 1998-11-14
465+
*/
463466
for (i = 0; i < nColumns; i++)
464467
{
465-
table[i] = (char *) malloc(PQgetlength(res, i, 1) * sizeof(char) + 1);
468+
table[i] = (char *) malloc(PQgetlength(res, i, 1) * sizeof(char) + 3);
466469
if (table[i] == NULL)
467470
perror("malloc");
468-
strcpy(table[i], PQgetvalue(res, i, 1));
471+
strcpy(table[i], "\"");
472+
strcat(table[i], PQgetvalue(res, i, 1));
473+
strcat(table[i], "\"");
469474
}
470475

471476
PQclear(res);

0 commit comments

Comments
 (0)