Skip to content

Commit ea4223c

Browse files
committed
FIx for indexing regex stuff. Change rowoid to objoid.
1 parent 145bae2 commit ea4223c

File tree

4 files changed

+20
-83
lines changed

4 files changed

+20
-83
lines changed

src/backend/parser/gram.y

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.64 1997/11/10 15:22:36 thomas Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.65 1997/11/14 05:57:23 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHOR DATE MAJOR EVENT
@@ -3552,7 +3552,8 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
35523552
Node *result = NULL;
35533553

35543554
/* we do this so indexes can be used */
3555-
if (strcmp(opname,"~") == 0)
3555+
if (strcmp(opname,"~") == 0 ||
3556+
strcmp(opname,"~*") == 0)
35563557
{
35573558
if (nodeTag(rexpr) == T_A_Const &&
35583559
((A_Const *)rexpr)->val.type == T_String &&
@@ -3570,7 +3571,8 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
35703571
n->val.val.str[pos] == '?' ||
35713572
n->val.val.str[pos] == '*' ||
35723573
n->val.val.str[pos] == '[' ||
3573-
n->val.val.str[pos] == '$')
3574+
n->val.val.str[pos] == '$' ||
3575+
(strcmp(opname,"~*") == 0 && isalpha(n->val.val.str[pos]))
35743576
break;
35753577
if (n->val.val.str[pos] == '\\')
35763578
pos++;
@@ -3599,71 +3601,6 @@ static Node *makeIndexable(char *opname, Node *lexpr, Node *rexpr)
35993601
}
36003602
}
36013603
}
3602-
else if (strcmp(opname,"~*") == 0)
3603-
{
3604-
if (nodeTag(rexpr) == T_A_Const &&
3605-
((A_Const *)rexpr)->val.type == T_String &&
3606-
((A_Const *)rexpr)->val.val.str[0] == '^')
3607-
{
3608-
A_Const *n = (A_Const *)rexpr;
3609-
char *match_lower_least = palloc(strlen(n->val.val.str)+2);
3610-
char *match_lower_most = palloc(strlen(n->val.val.str)+2);
3611-
char *match_upper_least = palloc(strlen(n->val.val.str)+2);
3612-
char *match_upper_most = palloc(strlen(n->val.val.str)+2);
3613-
int pos, match_pos=0;
3614-
3615-
/* skip leading ^ */
3616-
for (pos = 1; n->val.val.str[pos]; pos++)
3617-
{
3618-
if (n->val.val.str[pos] == '.' ||
3619-
n->val.val.str[pos] == '?' ||
3620-
n->val.val.str[pos] == '*' ||
3621-
n->val.val.str[pos] == '[' ||
3622-
n->val.val.str[pos] == '$')
3623-
break;
3624-
if (n->val.val.str[pos] == '\\')
3625-
pos++;
3626-
/* If we have punctuation, this works well */
3627-
match_lower_least[match_pos] = tolower(n->val.val.str[pos]);
3628-
match_lower_most[match_pos] = tolower(n->val.val.str[pos]);
3629-
match_upper_least[match_pos] = toupper(n->val.val.str[pos]);
3630-
match_upper_most[match_pos++] = toupper(n->val.val.str[pos]);
3631-
}
3632-
3633-
if (match_pos != 0)
3634-
{
3635-
A_Const *lower_least = makeNode(A_Const);
3636-
A_Const *lower_most = makeNode(A_Const);
3637-
A_Const *upper_least = makeNode(A_Const);
3638-
A_Const *upper_most = makeNode(A_Const);
3639-
3640-
/* make strings to be used in index use */
3641-
match_lower_least[match_pos] = '\0';
3642-
match_lower_most[match_pos] = '\377';
3643-
match_lower_most[match_pos+1] = '\0';
3644-
match_upper_least[match_pos] = '\0';
3645-
match_upper_most[match_pos] = '\377';
3646-
match_upper_most[match_pos+1] = '\0';
3647-
lower_least->val.type = T_String;
3648-
lower_least->val.val.str = match_lower_least;
3649-
lower_most->val.type = T_String;
3650-
lower_most->val.val.str = match_lower_most;
3651-
upper_least->val.type = T_String;
3652-
upper_least->val.val.str = match_upper_least;
3653-
upper_most->val.type = T_String;
3654-
upper_most->val.val.str = match_upper_most;
3655-
result = makeA_Expr(AND, NULL,
3656-
makeA_Expr(OP, "~*", lexpr, rexpr),
3657-
makeA_Expr(OR, NULL,
3658-
makeA_Expr(AND, NULL,
3659-
makeA_Expr(OP, ">=", lexpr, (Node *)lower_least),
3660-
makeA_Expr(OP, "<=", lexpr, (Node *)lower_most)),
3661-
makeA_Expr(AND, NULL,
3662-
makeA_Expr(OP, ">=", lexpr, (Node *)upper_least),
3663-
makeA_Expr(OP, "<=", lexpr, (Node *)upper_most))));
3664-
}
3665-
}
3666-
}
36673604
else if (strcmp(opname,"~~") == 0)
36683605
{
36693606
if (nodeTag(rexpr) == T_A_Const &&

src/bin/psql/psql.c

Lines changed: 8 additions & 8 deletions
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.103 1997/11/13 03:36:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.104 1997/11/14 05:57:35 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -729,7 +729,7 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
729729
strcat(descbuf, "pg_attribute.attname = '");
730730
strcat(descbuf, column);
731731
strcat(descbuf, "' and ");
732-
strcat(descbuf, " pg_attribute.oid = pg_description.rowoid " );
732+
strcat(descbuf, " pg_attribute.oid = pg_description.objoid " );
733733
if (!(res = PSQLexec(pset, descbuf)))
734734
return -1;
735735
}
@@ -740,7 +740,7 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
740740
strcat(descbuf, "WHERE pg_class.relname = '");
741741
strcat(descbuf, object);
742742
strcat(descbuf, "'" );
743-
strcat(descbuf, " and pg_class.oid = pg_description.rowoid " );
743+
strcat(descbuf, " and pg_class.oid = pg_description.objoid " );
744744
if (!(res = PSQLexec(pset, descbuf)))
745745
return -1;
746746
else if (PQntuples(res) <= 0)
@@ -752,7 +752,7 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
752752
strcat(descbuf, "WHERE pg_type.typname = '");
753753
strcat(descbuf, object);
754754
strcat(descbuf, "'" );
755-
strcat(descbuf, " and pg_type.oid = pg_description.rowoid " );
755+
strcat(descbuf, " and pg_type.oid = pg_description.objoid " );
756756
if (!(res = PSQLexec(pset, descbuf)))
757757
return -1;
758758
else if (PQntuples(res) <= 0)
@@ -764,7 +764,7 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
764764
strcat(descbuf, "WHERE pg_type.typname = '");
765765
strcat(descbuf, object);
766766
strcat(descbuf, "'" );
767-
strcat(descbuf, " and pg_type.oid = pg_description.rowoid " );
767+
strcat(descbuf, " and pg_type.oid = pg_description.objoid " );
768768
if (!(res = PSQLexec(pset, descbuf)))
769769
return -1;
770770
else if (PQntuples(res) <= 0)
@@ -776,7 +776,7 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
776776
strcat(descbuf, "WHERE pg_proc.proname = '");
777777
strcat(descbuf, object);
778778
strcat(descbuf, "'" );
779-
strcat(descbuf, " and pg_proc.oid = pg_description.rowoid " );
779+
strcat(descbuf, " and pg_proc.oid = pg_description.objoid " );
780780
if (!(res = PSQLexec(pset, descbuf)))
781781
return -1;
782782
else if (PQntuples(res) <= 0)
@@ -788,7 +788,7 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
788788
strcat(descbuf, "WHERE pg_operator.oprname = '");
789789
strcat(descbuf, object);
790790
strcat(descbuf, "'" );
791-
strcat(descbuf, " and pg_operator.oid = pg_description.rowoid " );
791+
strcat(descbuf, " and pg_operator.oid = pg_description.objoid " );
792792
if (!(res = PSQLexec(pset, descbuf)))
793793
return -1;
794794
else if (PQntuples(res) <= 0)
@@ -800,7 +800,7 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
800800
strcat(descbuf, "WHERE pg_aggregate.aggname = '");
801801
strcat(descbuf, object);
802802
strcat(descbuf, "'" );
803-
strcat(descbuf, " and pg_aggregate.oid = pg_description.rowoid " );
803+
strcat(descbuf, " and pg_aggregate.oid = pg_description.objoid " );
804804
if (!(res = PSQLexec(pset, descbuf)))
805805
return -1;
806806
}

src/include/catalog/indexing.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: indexing.h,v 1.8 1997/11/13 03:22:54 momjian Exp $
10+
* $Id: indexing.h,v 1.9 1997/11/14 05:57:42 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -46,7 +46,7 @@
4646
#define AttrDefaultIndex "pg_attrdefind"
4747
#define RelCheckIndex "pg_relcheckind"
4848
#define TriggerRelidIndex "pg_trigrelidind"
49-
#define DescriptionRowOidIndex "pg_descrrowoidind"
49+
#define DescriptionObjOidIndex "pg_descrobjoidind"
5050

5151
extern char *Name_pg_attr_indices[];
5252
extern char *Name_pg_proc_indices[];
@@ -55,7 +55,7 @@ extern char *Name_pg_class_indices[];
5555
extern char *Name_pg_attrdef_indices[];
5656
extern char *Name_pg_relcheck_indices[];
5757
extern char *Name_pg_trigger_indices[];
58-
extern char *Name_pg_rowoid_indices[];
58+
extern char *Name_pg_objoid_indices[];
5959

6060
extern char *IndexedCatalogNames[];
6161

@@ -119,7 +119,7 @@ DECLARE_INDEX(pg_relcheckind on pg_relcheck using btree(rcrelid oid_ops));
119119

120120
DECLARE_INDEX(pg_trigrelidind on pg_trigger using btree(tgrelid oid_ops));
121121

122-
DECLARE_INDEX(pg_descrrowoidind on pg_description using btree(rowoid oid_ops));
122+
DECLARE_INDEX(pg_descrobjoidind on pg_description using btree(objoid oid_ops));
123123

124124
/* now build indices in the initialization scripts */
125125
BUILD_INDICES

src/include/catalog/pg_description.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_description.h,v 1.1 1997/11/13 03:22:59 momjian Exp $
9+
* $Id: pg_description.h,v 1.2 1997/11/14 05:57:46 momjian Exp $
1010
*
1111
* NOTES
1212
* the genbki.sh script reads this file and generates .bki
@@ -34,7 +34,7 @@
3434
*/
3535
CATALOG(pg_description)
3636
{
37-
Oid rowoid;
37+
Oid objoid;
3838
text description;
3939
} FormData_pg_description;
4040

@@ -50,7 +50,7 @@ typedef FormData_pg_description *Form_pg_description;
5050
* ----------------
5151
*/
5252
#define Natts_pg_description 2
53-
#define Anum_pg_description_rowoid 1
53+
#define Anum_pg_description_objoid 1
5454
#define Anum_pg_description_description 2
5555

5656
/* ----------------

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy