3
3
* out of it's tuple
4
4
*
5
5
* IDENTIFICATION
6
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.4 1998/10/02 16:27:51 momjian Exp $
6
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.5 1998/10/06 22:14:16 momjian Exp $
7
7
*
8
8
* This software is copyrighted by Jan Wieck - Hamburg.
9
9
*
@@ -415,7 +415,7 @@ pg_get_indexdef(Oid indexrelid)
415
415
* Start the index definition
416
416
* ----------
417
417
*/
418
- sprintf (buf , "CREATE %sINDEX %s ON %s USING %s (" ,
418
+ sprintf (buf , "CREATE %sINDEX \"%s\" ON \"%s\" USING %s (" ,
419
419
idxrec -> indisunique ? "UNIQUE " : "" ,
420
420
nameout (& (idxrelrec -> relname )),
421
421
nameout (& (indrelrec -> relname )),
@@ -439,11 +439,13 @@ pg_get_indexdef(Oid indexrelid)
439
439
* Add the indexed field name
440
440
* ----------
441
441
*/
442
+ strcat (keybuf , "\"" );
442
443
if (idxrec -> indkey [keyno ] == ObjectIdAttributeNumber - 1 )
443
444
strcat (keybuf , "oid" );
444
445
else
445
446
strcat (keybuf , get_attribute_name (idxrec -> indrelid ,
446
447
idxrec -> indkey [keyno ]));
448
+ strcat (keybuf , "\"" );
447
449
448
450
/* ----------
449
451
* If not a functional index, add the operator class name
@@ -462,8 +464,9 @@ pg_get_indexdef(Oid indexrelid)
462
464
spi_tup = SPI_tuptable -> vals [0 ];
463
465
spi_ttc = SPI_tuptable -> tupdesc ;
464
466
spi_fno = SPI_fnumber (spi_ttc , "opcname" );
465
- strcat (keybuf , " " );
467
+ strcat (keybuf , " \" " );
466
468
strcat (keybuf , SPI_getvalue (spi_tup , spi_ttc , spi_fno ));
469
+ strcat (keybuf , "\"" );
467
470
}
468
471
}
469
472
@@ -482,8 +485,9 @@ pg_get_indexdef(Oid indexrelid)
482
485
elog (ERROR , "cache lookup for proc %d failed" , idxrec -> indproc );
483
486
484
487
procStruct = (Form_pg_proc ) GETSTRUCT (proctup );
488
+ strcat (buf , "\"" );
485
489
strcat (buf , nameout (& (procStruct -> proname )));
486
- strcat (buf , " (" );
490
+ strcat (buf , "\" (" );
487
491
strcat (buf , keybuf );
488
492
strcat (buf , ") " );
489
493
@@ -498,7 +502,9 @@ pg_get_indexdef(Oid indexrelid)
498
502
spi_tup = SPI_tuptable -> vals [0 ];
499
503
spi_ttc = SPI_tuptable -> tupdesc ;
500
504
spi_fno = SPI_fnumber (spi_ttc , "opcname" );
505
+ strcat (buf , "\"" );
501
506
strcat (buf , SPI_getvalue (spi_tup , spi_ttc , spi_fno ));
507
+ strcat (buf , "\"" );
502
508
}
503
509
else
504
510
/* ----------
@@ -628,29 +634,29 @@ make_ruledef(HeapTuple ruletup, TupleDesc rulettc)
628
634
* Build the rules definition text
629
635
* ----------
630
636
*/
631
- strcpy (buf , "CREATE RULE " );
637
+ strcpy (buf , "CREATE RULE \" " );
632
638
633
639
/* The rule name */
634
640
strcat (buf , rulename );
635
- strcat (buf , " AS ON " );
641
+ strcat (buf , "\" AS ON " );
636
642
637
643
/* The event the rule is fired for */
638
644
switch (ev_type )
639
645
{
640
646
case '1' :
641
- strcat (buf , "SELECT TO " );
647
+ strcat (buf , "SELECT TO \" " );
642
648
break ;
643
649
644
650
case '2' :
645
- strcat (buf , "UPDATE TO " );
651
+ strcat (buf , "UPDATE TO \" " );
646
652
break ;
647
653
648
654
case '3' :
649
- strcat (buf , "INSERT TO " );
655
+ strcat (buf , "INSERT TO \" " );
650
656
break ;
651
657
652
658
case '4' :
653
- strcat (buf , "DELETE TO " );
659
+ strcat (buf , "DELETE TO \" " );
654
660
break ;
655
661
656
662
default :
@@ -661,10 +667,12 @@ make_ruledef(HeapTuple ruletup, TupleDesc rulettc)
661
667
662
668
/* The relation the rule is fired on */
663
669
strcat (buf , get_relation_name (ev_class ));
670
+ strcat (buf , "\"" );
664
671
if (ev_attr > 0 )
665
672
{
666
- strcat (buf , "." );
673
+ strcat (buf , ".\" " );
667
674
strcat (buf , get_attribute_name (ev_class , ev_attr ));
675
+ strcat (buf , "\"" );
668
676
}
669
677
670
678
/* If the rule has an event qualification, add it */
@@ -941,8 +949,9 @@ get_select_query_def(Query *query, QryHier *qh)
941
949
/* and do if so */
942
950
if (tell_as )
943
951
{
944
- strcat (buf , " AS " );
952
+ strcat (buf , " AS \" " );
945
953
strcat (buf , tle -> resdom -> resname );
954
+ strcat (buf , "\"" );
946
955
}
947
956
}
948
957
@@ -967,11 +976,14 @@ get_select_query_def(Query *query, QryHier *qh)
967
976
968
977
strcat (buf , sep );
969
978
sep = ", " ;
979
+ strcat (buf , "\"" );
970
980
strcat (buf , rte -> relname );
981
+ strcat (buf , "\"" );
971
982
if (strcmp (rte -> relname , rte -> refname ) != 0 )
972
983
{
973
- strcat (buf , " " );
984
+ strcat (buf , " \" " );
974
985
strcat (buf , rte -> refname );
986
+ strcat (buf , "\"" );
975
987
}
976
988
}
977
989
}
@@ -1071,8 +1083,9 @@ get_insert_query_def(Query *query, QryHier *qh)
1071
1083
* ----------
1072
1084
*/
1073
1085
rte = (RangeTblEntry * ) nth (query -> resultRelation - 1 , query -> rtable );
1074
- strcpy (buf , "INSERT INTO " );
1086
+ strcpy (buf , "INSERT INTO \" " );
1075
1087
strcat (buf , rte -> relname );
1088
+ strcat (buf , "\"" );
1076
1089
1077
1090
/* Add the target list */
1078
1091
sep = " (" ;
@@ -1082,7 +1095,9 @@ get_insert_query_def(Query *query, QryHier *qh)
1082
1095
1083
1096
strcat (buf , sep );
1084
1097
sep = ", " ;
1098
+ strcat (buf , "\"" );
1085
1099
strcat (buf , tle -> resdom -> resname );
1100
+ strcat (buf , "\"" );
1086
1101
}
1087
1102
strcat (buf , ") " );
1088
1103
@@ -1142,8 +1157,9 @@ get_update_query_def(Query *query, QryHier *qh)
1142
1157
1143
1158
strcat (buf , sep );
1144
1159
sep = ", " ;
1160
+ strcat (buf , "\"" );
1145
1161
strcat (buf , tle -> resdom -> resname );
1146
- strcat (buf , " = " );
1162
+ strcat (buf , "\" = " );
1147
1163
strcat (buf , get_tle_expr (qh , query -> resultRelation ,
1148
1164
tle , TRUE));
1149
1165
}
@@ -1179,8 +1195,9 @@ get_delete_query_def(Query *query, QryHier *qh)
1179
1195
* ----------
1180
1196
*/
1181
1197
rte = (RangeTblEntry * ) nth (query -> resultRelation - 1 , query -> rtable );
1182
- strcpy (buf , "DELETE FROM " );
1198
+ strcpy (buf , "DELETE FROM \" " );
1183
1199
strcat (buf , rte -> relname );
1200
+ strcat (buf , "\"" );
1184
1201
1185
1202
/* Add a WHERE clause if given */
1186
1203
if (query -> qual != NULL )
@@ -1232,8 +1249,9 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix)
1232
1249
{
1233
1250
Aggreg * agg = (Aggreg * ) node ;
1234
1251
1252
+ strcat (buf , "\"" );
1235
1253
strcat (buf , agg -> aggname );
1236
- strcat (buf , "(" );
1254
+ strcat (buf , "\" (" );
1237
1255
strcat (buf , get_rule_expr (qh , rt_index ,
1238
1256
(Node * ) (agg -> target ), varprefix ));
1239
1257
strcat (buf , ")" );
@@ -1328,10 +1346,8 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix)
1328
1346
int sup = var -> varlevelsup ;
1329
1347
1330
1348
while (sup -- > 0 ) qh = qh -> parent ;
1331
- rte = (RangeTblEntry * ) nth (var -> varno - 1 , qh -> query -> rtable );
1332
1349
1333
- if (qh -> parent == NULL && var -> varlevelsup > 0 )
1334
- rte = (RangeTblEntry * ) nth (var -> varno + 1 , qh -> query -> rtable );
1350
+ rte = (RangeTblEntry * ) nth (var -> varno - 1 , qh -> query -> rtable );
1335
1351
1336
1352
if (!strcmp (rte -> refname , "*NEW*" ))
1337
1353
strcat (buf , "new." );
@@ -1343,12 +1359,15 @@ get_rule_expr(QryHier *qh, int rt_index, Node *node, bool varprefix)
1343
1359
{
1344
1360
if (strcmp (rte -> relname , rte -> refname ) != 0 )
1345
1361
{
1362
+ strcat (buf , "\"" );
1346
1363
strcat (buf , rte -> refname );
1347
- strcat (buf , "." );
1364
+ strcat (buf , "\" ." );
1348
1365
}
1349
1366
}
1350
1367
}
1368
+ strcat (buf , "\"" );
1351
1369
strcat (buf , get_attribute_name (rte -> relid , var -> varattno ));
1370
+ strcat (buf , "\"" );
1352
1371
1353
1372
return pstrdup (buf );
1354
1373
}
@@ -1433,8 +1452,9 @@ get_func_expr(QryHier *qh, int rt_index, Expr *expr, bool varprefix)
1433
1452
* Build a string of proname(args)
1434
1453
* ----------
1435
1454
*/
1436
- strcpy (buf , proname );
1437
- strcat (buf , "(" );
1455
+ strcpy (buf , "\"" );
1456
+ strcat (buf , proname );
1457
+ strcat (buf , "\"(" );
1438
1458
sep = "" ;
1439
1459
foreach (l , expr -> args )
1440
1460
{
@@ -1561,7 +1581,7 @@ get_const_expr(Const *constval)
1561
1581
extval = (char * ) (* fmgr_faddr (& finfo_output )) (constval -> constvalue ,
1562
1582
& isnull , -1 );
1563
1583
1564
- sprintf (namebuf , "::%s " , nameout (& (typeStruct -> typname )));
1584
+ sprintf (namebuf , "::\"%s\" " , nameout (& (typeStruct -> typname )));
1565
1585
if (strcmp (namebuf , "::unknown" ) == 0 )
1566
1586
namebuf [0 ] = '\0' ;
1567
1587
sprintf (buf , "'%s'%s" , extval , namebuf );
0 commit comments