Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cd0de49f
Commit
cd0de49f
authored
2 years ago
by
Abuhujair Javed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
basic parsing added for creation of functional dependency
parent
bddbccd5
REL_14_STABLE
No related merge requests found
Pipeline
#1738
failed with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
7 deletions
+128
-7
src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtinsert.c
+10
-4
src/backend/access/nbtree/nbtsearch.c
src/backend/access/nbtree/nbtsearch.c
+8
-3
src/backend/catalog/index.c
src/backend/catalog/index.c
+44
-0
src/backend/tcop/postgres.c
src/backend/tcop/postgres.c
+66
-0
No files found.
src/backend/access/nbtree/nbtinsert.c
View file @
cd0de49f
...
...
@@ -25,6 +25,10 @@
#include "storage/predicate.h"
#include "storage/smgr.h"
/* CS631 Start */
#include "/home/abuhujair/git/postgresql/install/data/gdata.h"
/* CS631 End */
/* Minimum tree height for application of fastpath optimization */
#define BTREE_FASTPATH_MIN_LEVEL 2
...
...
@@ -107,9 +111,10 @@ _bt_doinsert(Relation rel, IndexTuple itup,
bool
checkingunique
=
(
checkUnique
!=
UNIQUE_CHECK_NO
);
/* CS631 Start */
Oid
special
=
32788
;
//
Oid special = 32788;
bool
checkingfd
=
false
;
if
(
rel
->
rd_index
->
indexrelid
==
special
)
// if ( rel->rd_index->indexrelid == special )
if
(
check_fd
(
(
int
)
rel
->
rd_index
->
indexrelid
)
)
checkingfd
=
true
;
/* CS631 End */
/* we need an insertion scan key to do our search, so build one */
...
...
@@ -431,9 +436,10 @@ _bt_check_unique(Relation rel, BTInsertState insertstate, Relation heapRel,
int
curposti
=
0
;
/* CS631 Start */
Oid
special
=
32788
;
//
Oid special = 32788;
bool
checkfd
=
false
;
if
(
rel
->
rd_index
->
indexrelid
==
special
)
//if ( rel->rd_index->indexrelid == special )
if
(
check_fd
((
int
)
rel
->
rd_index
->
indexrelid
)
)
checkfd
=
true
;
/* CS631 End */
...
...
This diff is collapsed.
Click to expand it.
src/backend/access/nbtree/nbtsearch.c
View file @
cd0de49f
...
...
@@ -23,6 +23,9 @@
#include "utils/lsyscache.h"
#include "utils/rel.h"
/* CS631 Start */
#include "/home/abuhujair/git/postgresql/install/data/gdata.h"
/* CS631 End */
static
void
_bt_drop_lock_and_maybe_pin
(
IndexScanDesc
scan
,
BTScanPos
sp
);
static
OffsetNumber
_bt_binsrch
(
Relation
rel
,
BTScanInsert
key
,
Buffer
buf
);
...
...
@@ -671,7 +674,7 @@ _bt_compare(Relation rel,
int
ncmpkey
;
int
ntupatts
;
int32
result
;
Oid
special
=
32788
;
//
Oid special = 32788;
Assert
(
_bt_check_natts
(
rel
,
key
->
heapkeyspace
,
page
,
offnum
));
Assert
(
key
->
keysz
<=
IndexRelationGetNumberOfKeyAttributes
(
rel
));
...
...
@@ -752,9 +755,11 @@ _bt_compare(Relation rel,
scankey
++
;
}
if
(
rel
->
rd_index
->
indexrelid
==
special
){
/* CS631 Start */
// if (rel->rd_index->indexrelid == special)
if
(
check_fd
((
int
)
rel
->
rd_index
->
indexrelid
)
)
return
0
;
}
/* CS631 End */
/*
* All non-truncated attributes (other than heap TID) were found to be
...
...
This diff is collapsed.
Click to expand it.
src/backend/catalog/index.c
View file @
cd0de49f
...
...
@@ -85,6 +85,17 @@
#include "utils/syscache.h"
#include "utils/tuplesort.h"
/* CS631 Start */
# include <string.h>
# include <stdio.h>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
// #include "../../../install/data/gdata.h"
#include "/home/abuhujair/git/postgresql/install/data/gdata.h"
/* CS631 End */
/* Potentially set by pg_upgrade_support functions */
Oid
binary_upgrade_next_index_pg_class_oid
=
InvalidOid
;
...
...
@@ -525,6 +536,30 @@ AppendAttributeTuples(Relation indexRelation, Datum *attopts)
table_close
(
pg_attribute
,
RowExclusiveLock
);
}
/* CS631 Start */
int
add_entry
(
char
*
idxid
)
{
FILE
*
filePointer
;
filePointer
=
fopen
(
"/home/abuhujair/git/postgresql/install/data/idx_inf.txt"
,
"a"
)
;
if
(
filePointer
==
NULL
)
printf
(
"file failed to open."
);
else
{
if
(
strlen
(
idxid
)
>
0
)
{
fputs
(
idxid
,
filePointer
)
;
fputs
(
"
\n
"
,
filePointer
)
;
}
// Closing the file using fclose()
fclose
(
filePointer
)
;
}
return
0
;
}
/* CS631 End */
/* ----------------------------------------------------------------
* UpdateIndexRelation
*
...
...
@@ -645,6 +680,15 @@ UpdateIndexRelation(Oid indexoid,
*/
table_close
(
pg_index
,
RowExclusiveLock
);
heap_freetuple
(
tuple
);
/* CS631 Start */
if
(
fd_flag
)
{
char
idxid
[
20
];
sprintf
(
idxid
,
"%d"
,
(
int
)(
ObjectIdGetDatum
(
indexoid
)));
add_entry
(
idxid
);
}
/* CS631 End */
}
...
...
This diff is collapsed.
Click to expand it.
src/backend/tcop/postgres.c
View file @
cd0de49f
...
...
@@ -945,6 +945,56 @@ pg_plan_queries(List *querytrees, const char *query_string, int cursorOptions,
return
stmt_list
;
}
/* CS631 Start */
char
*
replaceWord
(
const
char
*
s
,
const
char
*
oldW
,
const
char
*
newW
)
{
char
*
result
;
int
i
,
cnt
=
1
;
int
newWlen
=
strlen
(
newW
);
int
oldWlen
=
strlen
(
oldW
);
int
stringlen
=
strlen
(
s
);
// Making new string of enough length
result
=
(
char
*
)
malloc
(
stringlen
+
(
newWlen
-
oldWlen
)
+
1
);
i
=
0
;
while
(
*
s
)
{
// compare the substring with the result
if
(
strstr
(
s
,
oldW
)
==
s
)
{
strcpy
(
&
result
[
i
],
newW
);
i
+=
newWlen
;
s
+=
oldWlen
;
}
else
result
[
i
++
]
=
*
s
++
;
}
result
[
i
]
=
'\0'
;
return
result
;
}
#include "../../../install/data/gdata.h"
int
fd_flag
=
0
;
int
check_fd
(
int
id_num
)
{
FILE
*
fp
;
char
id
[
20
];
sprintf
(
id
,
"%d"
,
id_num
);
char
line
[
20
];
fp
=
fopen
(
"/home/abuhujair/git/postgresql/install/data/idx_inf.txt"
,
"r"
);
while
((
fgets
(
line
,
20
,
fp
))
!=
NULL
)
{
line
[
strcspn
(
line
,
"
\n
"
)]
=
0
;
if
(
strcmp
(
id
,
line
)
==
0
)
{
fclose
(
fp
);
return
1
;
}
}
fclose
(
fp
);
return
0
;
}
/* CS631 End */
/*
* exec_simple_query
...
...
@@ -963,6 +1013,22 @@ exec_simple_query(const char *query_string)
bool
use_implicit_block
;
char
msec_str
[
32
];
/* CS631 Start */
fd_flag
=
0
;
if
(
strstr
(
query_string
,
"FD"
)
&&
strstr
(
query_string
,
"determines"
))
{
const
char
old
[]
=
"FD"
;
const
char
new
[]
=
"index"
;
query_string
=
replaceWord
(
query_string
,
old
,
new
);
const
char
old1
[]
=
"determines"
;
const
char
new1
[]
=
"include"
;
query_string
=
replaceWord
(
query_string
,
old1
,
new1
);
fd_flag
=
1
;
}
/* CS631 End */
/*
* Report query to various monitoring facilities.
*/
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment