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
b992e200
Commit
b992e200
authored
Aug 19, 1997
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NOT NULL implementation (submitted by Robson Paniago de Miranda).
parent
b99c63cf
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
453 additions
and
337 deletions
+453
-337
src/backend/access/common/tupdesc.c
src/backend/access/common/tupdesc.c
+17
-2
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+12
-13
src/backend/catalog/index.c
src/backend/catalog/index.c
+12
-12
src/backend/commands/command.c
src/backend/commands/command.c
+7
-2
src/backend/commands/copy.c
src/backend/commands/copy.c
+17
-1
src/backend/commands/creatinh.c
src/backend/commands/creatinh.c
+6
-3
src/backend/executor/execMain.c
src/backend/executor/execMain.c
+32
-1
src/backend/parser/gram.y
src/backend/parser/gram.y
+9
-3
src/backend/utils/cache/relcache.c
src/backend/utils/cache/relcache.c
+22
-3
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.c
+9
-2
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/pg_dump.h
+2
-1
src/bin/psql/psql.c
src/bin/psql/psql.c
+2
-2
src/bin/psql/psqlHelp.h
src/bin/psql/psqlHelp.h
+2
-2
src/include/access/tupdesc.h
src/include/access/tupdesc.h
+9
-1
src/include/catalog/pg_attribute.h
src/include/catalog/pg_attribute.h
+293
-288
src/include/nodes/parsenodes.h
src/include/nodes/parsenodes.h
+2
-1
No files found.
src/backend/access/common/tupdesc.c
View file @
b992e200
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.1
3 1997/08/18 20:51:31 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.1
4 1997/08/19 04:42:31 vadim
Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
...
...
@@ -60,6 +60,7 @@ CreateTemplateTupleDesc(int natts)
size
=
natts
*
sizeof
(
AttributeTupleForm
);
desc
=
(
TupleDesc
)
palloc
(
sizeof
(
struct
tupleDesc
));
desc
->
attrs
=
(
AttributeTupleForm
*
)
palloc
(
size
);
desc
->
constr
=
NULL
;
memset
(
desc
->
attrs
,
0
,
size
);
desc
->
natts
=
natts
;
...
...
@@ -87,7 +88,7 @@ CreateTupleDesc(int natts, AttributeTupleForm* attrs)
desc
=
(
TupleDesc
)
palloc
(
sizeof
(
struct
tupleDesc
));
desc
->
attrs
=
attrs
;
desc
->
natts
=
natts
;
desc
->
constr
=
NULL
;
return
(
desc
);
}
...
...
@@ -117,6 +118,11 @@ CreateTupleDescCopy(TupleDesc tupdesc)
tupdesc
->
attrs
[
i
],
ATTRIBUTE_TUPLE_SIZE
);
}
if
(
tupdesc
->
constr
)
{
desc
->
constr
=
(
AttrConstr
*
)
palloc
(
sizeof
(
struct
attrConstr
));
memmove
(
desc
->
constr
,
tupdesc
->
constr
,
sizeof
(
struct
attrConstr
));
}
else
desc
->
constr
=
NULL
;
return
desc
;
}
...
...
@@ -379,6 +385,15 @@ BuildDescForRelation(List *schema, char *relname)
if
(
entry
->
typename
->
typlen
>
0
)
{
desc
->
attrs
[
attnum
-
1
]
->
attlen
=
entry
->
typename
->
typlen
;
}
/* This is for constraints */
if
(
entry
->
is_not_null
)
{
if
(
!
desc
->
constr
)
desc
->
constr
=
(
AttrConstr
*
)
palloc
(
sizeof
(
struct
attrConstr
));
desc
->
constr
->
has_not_null
=
true
;
}
desc
->
attrs
[
attnum
-
1
]
->
attnotnull
=
entry
->
is_not_null
;
}
return
desc
;
}
...
...
src/backend/catalog/heap.c
View file @
b992e200
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.1
5 1997/08/12 22:52:07 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.1
6 1997/08/19 04:42:54 vadim
Exp $
*
* INTERFACE ROUTINES
* heap_creatr() - Create an uncataloged heap relation
...
...
@@ -72,57 +72,57 @@
static
FormData_pg_attribute
a1
=
{
0xffffffff
,
{
"ctid"
},
27l
,
0l
,
0l
,
0l
,
sizeof
(
ItemPointerData
),
SelfItemPointerAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
SelfItemPointerAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a2
=
{
0xffffffff
,
{
"oid"
},
26l
,
0l
,
0l
,
0l
,
sizeof
(
Oid
),
ObjectIdAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
ObjectIdAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a3
=
{
0xffffffff
,
{
"xmin"
},
28l
,
0l
,
0l
,
0l
,
sizeof
(
TransactionId
),
MinTransactionIdAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
MinTransactionIdAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a4
=
{
0xffffffff
,
{
"cmin"
},
29l
,
0l
,
0l
,
0l
,
sizeof
(
CommandId
),
MinCommandIdAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
's'
MinCommandIdAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
's'
,
'\0'
};
static
FormData_pg_attribute
a5
=
{
0xffffffff
,
{
"xmax"
},
28l
,
0l
,
0l
,
0l
,
sizeof
(
TransactionId
),
MaxTransactionIdAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
MaxTransactionIdAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a6
=
{
0xffffffff
,
{
"cmax"
},
29l
,
0l
,
0l
,
0l
,
sizeof
(
CommandId
),
MaxCommandIdAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
's'
MaxCommandIdAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
's'
,
'\0'
};
static
FormData_pg_attribute
a7
=
{
0xffffffff
,
{
"chain"
},
27l
,
0l
,
0l
,
0l
,
sizeof
(
ItemPointerData
),
ChainItemPointerAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
ChainItemPointerAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a8
=
{
0xffffffff
,
{
"anchor"
},
27l
,
0l
,
0l
,
0l
,
sizeof
(
ItemPointerData
),
AnchorItemPointerAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
AnchorItemPointerAttributeNumber
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a9
=
{
0xffffffff
,
{
"tmin"
},
20l
,
0l
,
0l
,
0l
,
sizeof
(
AbsoluteTime
),
MinAbsoluteTimeAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
MinAbsoluteTimeAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a10
=
{
0xffffffff
,
{
"tmax"
},
20l
,
0l
,
0l
,
0l
,
sizeof
(
AbsoluteTime
),
MaxAbsoluteTimeAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
MaxAbsoluteTimeAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
,
'\0'
};
static
FormData_pg_attribute
a11
=
{
0xffffffff
,
{
"vtype"
},
18l
,
0l
,
0l
,
0l
,
sizeof
(
char
),
VersionTypeAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'c'
VersionTypeAttributeNumber
,
0
,
'\001'
,
'\001'
,
0l
,
'c'
,
'\0'
};
static
AttributeTupleForm
HeapAtt
[]
=
...
...
@@ -565,7 +565,6 @@ AddNewAttributeTuples(Oid new_rel_oid,
(
char
*
)
*
dpp
);
heap_insert
(
rdesc
,
tup
);
if
(
hasindex
)
CatalogIndexInsert
(
idescs
,
Num_pg_attr_indices
,
rdesc
,
tup
);
...
...
src/backend/catalog/index.c
View file @
b992e200
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.1
6 1997/08/12 22:52:09 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.1
7 1997/08/19 04:42:55 vadim
Exp $
*
*
* INTERFACE ROUTINES
...
...
@@ -112,17 +112,17 @@ static void DefaultBuild(Relation heapRelation, Relation indexRelation,
* ----------------------------------------------------------------
*/
static
FormData_pg_attribute
sysatts
[]
=
{
{
0l
,
{
"ctid"
},
27l
,
0l
,
0l
,
0l
,
6
,
-
1
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"oid"
},
26l
,
0l
,
0l
,
0l
,
4
,
-
2
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"xmin"
},
28l
,
0l
,
0l
,
0l
,
5
,
-
3
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"cmin"
},
29l
,
0l
,
0l
,
0l
,
1
,
-
4
,
0
,
'\001'
,
'\001'
,
0l
,
's'
},
{
0l
,
{
"xmax"
},
28l
,
0l
,
0l
,
0l
,
5
,
-
5
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"cmax"
},
29l
,
0l
,
0l
,
0l
,
1
,
-
6
,
0
,
'\001'
,
'\001'
,
0l
,
's'
},
{
0l
,
{
"chain"
},
27l
,
0l
,
0l
,
0l
,
6
,
-
7
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"anchor"
},
27l
,
0l
,
0l
,
0l
,
6
,
-
8
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"tmin"
},
20l
,
0l
,
0l
,
0l
,
4
,
-
9
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"tmax"
},
20l
,
0l
,
0l
,
0l
,
4
,
-
10
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
},
{
0l
,
{
"vtype"
},
18l
,
0l
,
0l
,
0l
,
1
,
-
11
,
0
,
'\001'
,
'\001'
,
0l
,
'c'
},
{
0l
,
{
"ctid"
},
27l
,
0l
,
0l
,
0l
,
6
,
-
1
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"oid"
},
26l
,
0l
,
0l
,
0l
,
4
,
-
2
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"xmin"
},
28l
,
0l
,
0l
,
0l
,
5
,
-
3
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"cmin"
},
29l
,
0l
,
0l
,
0l
,
1
,
-
4
,
0
,
'\001'
,
'\001'
,
0l
,
's'
,
'\0'
},
{
0l
,
{
"xmax"
},
28l
,
0l
,
0l
,
0l
,
5
,
-
5
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"cmax"
},
29l
,
0l
,
0l
,
0l
,
1
,
-
6
,
0
,
'\001'
,
'\001'
,
0l
,
's'
,
'\0'
},
{
0l
,
{
"chain"
},
27l
,
0l
,
0l
,
0l
,
6
,
-
7
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"anchor"
},
27l
,
0l
,
0l
,
0l
,
6
,
-
8
,
0
,
'\0'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"tmin"
},
20l
,
0l
,
0l
,
0l
,
4
,
-
9
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"tmax"
},
20l
,
0l
,
0l
,
0l
,
4
,
-
10
,
0
,
'\001'
,
'\001'
,
0l
,
'i'
,
'\0'
},
{
0l
,
{
"vtype"
},
18l
,
0l
,
0l
,
0l
,
1
,
-
11
,
0
,
'\001'
,
'\001'
,
0l
,
'c'
,
'\0'
},
};
/* ----------------------------------------------------------------
...
...
src/backend/commands/command.c
View file @
b992e200
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.
9 1997/08/18 20:52:11 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.
10 1997/08/19 04:43:27 vadim
Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
...
...
@@ -279,7 +279,11 @@ PerformAddAttribute(char *relationName,
elog
(
WARN
,
"PerformAddAttribute: you do not own class
\"
%s
\"
"
,
relationName
);
#endif
/*
* we can't add a not null attribute
*/
if
(
colDef
->
is_not_null
)
elog
(
WARN
,
"Can't add a not null attribute to a existent relation"
);
/*
* if the first element in the 'schema' list is a "*" then we are
* supposed to add this attribute to all classes that inherit from
...
...
@@ -454,6 +458,7 @@ PerformAddAttribute(char *relationName,
attribute
->
attcacheoff
=
-
1
;
attribute
->
attisset
=
(
bool
)
(
form
->
typtype
==
'c'
);
attribute
->
attalign
=
form
->
typalign
;
attribute
->
attnotnull
=
false
;
heap_insert
(
attrdesc
,
attributeTuple
);
if
(
hasindex
)
...
...
src/backend/commands/copy.c
View file @
b992e200
...
...
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.2
5 1997/08/18 02:14:34 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.2
6 1997/08/19 04:43:28 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -602,6 +602,22 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
tuple
=
heap_formtuple
(
tupDesc
,
values
,
nulls
);
if
(
oids
)
tuple
->
t_oid
=
loaded_oid
;
/* ----------------
* Check the constraints of a tuple
* ----------------
*/
if
(
rel
->
rd_att
->
constr
&&
rel
->
rd_att
->
constr
->
has_not_null
)
{
int
attrChk
;
for
(
attrChk
=
1
;
attrChk
<=
rel
->
rd_att
->
natts
;
attrChk
++
)
{
if
(
rel
->
rd_att
->
attrs
[
attrChk
-
1
]
->
attnotnull
&&
heap_attisnull
(
tuple
,
attrChk
))
elog
(
WARN
,
"CopyFrom: Fail to add null value in not null attribute %s"
,
rel
->
rd_att
->
attrs
[
attrChk
-
1
]
->
attname
.
data
);
}
}
heap_insert
(
rel
,
tuple
);
if
(
has_index
)
{
...
...
src/backend/commands/creatinh.c
View file @
b992e200
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.1
1 1997/08/18 20:52:16 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.1
2 1997/08/19 04:43:30 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -276,14 +276,16 @@ MergeAttributes(List *schema, List *supers)
AttributeTupleForm
attribute
=
tupleDesc
->
attrs
[
attrno
];
char
*
attributeName
;
char
*
attributeType
;
AttrConstr
constraints
;
HeapTuple
tuple
;
ColumnDef
*
def
;
TypeName
*
typename
;
/*
* form name
and type
* form name
, type and constraints
*/
attributeName
=
(
attribute
->
attname
).
data
;
constraints
.
has_not_null
=
attribute
->
attnotnull
;
tuple
=
SearchSysCacheTuple
(
TYPOID
,
ObjectIdGetDatum
(
attribute
->
atttypid
),
...
...
@@ -311,7 +313,8 @@ MergeAttributes(List *schema, List *supers)
def
->
colname
=
pstrdup
(
attributeName
);
typename
->
name
=
pstrdup
(
attributeType
);
def
->
typename
=
typename
;
partialResult
=
lcons
(
def
,
partialResult
);
def
->
is_not_null
=
constraints
.
has_not_null
;
partialResult
=
lcons
(
def
,
partialResult
);
}
/*
...
...
src/backend/executor/execMain.c
View file @
b992e200
...
...
@@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.1
5 1997/08/18 20:52:25 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.1
6 1997/08/19 04:43:45 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -401,6 +401,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
if
(
resultRelation
!=
0
&&
operation
!=
CMD_SELECT
)
{
/* ----------------
* if we have a result relation, open it and
* initialize the result relation info stuff.
* ----------------
*/
...
...
@@ -910,6 +911,21 @@ ExecAppend(TupleTableSlot *slot,
* ----------------
*/
/* ----------------
* Check the constraints of a tuple
* ----------------
*/
if
(
resultRelationDesc
->
rd_att
->
constr
&&
resultRelationDesc
->
rd_att
->
constr
->
has_not_null
)
{
int
attrChk
;
for
(
attrChk
=
1
;
attrChk
<=
resultRelationDesc
->
rd_att
->
natts
;
attrChk
++
)
{
if
(
resultRelationDesc
->
rd_att
->
attrs
[
attrChk
-
1
]
->
attnotnull
&&
heap_attisnull
(
tuple
,
attrChk
))
elog
(
WARN
,
"ExecAppend: Fail to add null value in not null attribute %s"
,
resultRelationDesc
->
rd_att
->
attrs
[
attrChk
-
1
]
->
attname
.
data
);
}
}
/* ----------------
* insert the tuple
* ----------------
...
...
@@ -1030,6 +1046,21 @@ ExecReplace(TupleTableSlot *slot,
* ----------------
*/
/* ----------------
* Check the constraints of a tuple
* ----------------
*/
if
(
resultRelationDesc
->
rd_att
->
constr
&&
resultRelationDesc
->
rd_att
->
constr
->
has_not_null
)
{
int
attrChk
;
for
(
attrChk
=
1
;
attrChk
<=
resultRelationDesc
->
rd_att
->
natts
;
attrChk
++
)
{
if
(
resultRelationDesc
->
rd_att
->
attrs
[
attrChk
-
1
]
->
attnotnull
&&
heap_attisnull
(
tuple
,
attrChk
))
elog
(
WARN
,
"ExecReplace: Fail to update null value in not null attribute %s"
,
resultRelationDesc
->
rd_att
->
attrs
[
attrChk
-
1
]
->
attname
.
data
);
}
}
/* ----------------
* replace the heap tuple
*
...
...
src/backend/parser/gram.y
View file @
b992e200
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.3
5 1997/08/12 20:15:33 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.3
6 1997/08/19 04:44:01 vadim
Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -135,7 +135,7 @@ static Node *makeA_Expr(int oper, char *opname, Node *lexpr, Node *rexpr);
def_list, opt_indirection, group_clause, groupby_list
%type <boolean> opt_inh_star, opt_binary, opt_instead, opt_with_copy,
index_opt_unique, opt_verbose, opt_analyze
index_opt_unique, opt_verbose, opt_analyze
, opt_null
%type <ival> copy_dirn, archive_type, OptArchiveType, OptArchiveLocation,
def_type, opt_direction, remove_type, opt_column, event
...
...
@@ -333,14 +333,20 @@ AddAttrStmt: ALTER TABLE relation_name opt_inh_star ADD COLUMN columnDef
}
;
columnDef: Id Typename
columnDef: Id Typename
opt_null
{
$$ = makeNode(ColumnDef);
$$->colname = $1;
$$->typename = $2;
$$->is_not_null = $3;
}
;
opt_null: PNULL { $$ = false; }
| NOT PNULL { $$ = true; }
| NOTNULL { $$ = true; }
| /* EMPTY */ { $$ = false; }
;
/*****************************************************************************
*
...
...
src/backend/utils/cache/relcache.c
View file @
b992e200
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.1
3 1997/08/18 20:53:48 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.1
4 1997/08/19 04:44:21 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -506,7 +506,7 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
HeapScanDesc
pg_attribute_scan
;
ScanKeyData
key
;
int
need
;
/* ----------------
* form a scan key
* ----------------
...
...
@@ -529,6 +529,10 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
* ----------------
*/
need
=
natts
;
if
(
!
relation
->
rd_att
->
constr
)
relation
->
rd_att
->
constr
=
(
AttrConstr
*
)
palloc
(
sizeof
(
struct
attrConstr
));
relation
->
rd_att
->
constr
->
has_not_null
=
false
;
pg_attribute_tuple
=
heap_getnext
(
pg_attribute_scan
,
0
,
(
Buffer
*
)
NULL
);
while
(
HeapTupleIsValid
(
pg_attribute_tuple
)
&&
need
>
0
)
{
attp
=
(
AttributeTupleForm
)
GETSTRUCT
(
pg_attribute_tuple
);
...
...
@@ -540,6 +544,11 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo,
memmove
((
char
*
)
(
relation
->
rd_att
->
attrs
[
attp
->
attnum
-
1
]),
(
char
*
)
attp
,
ATTRIBUTE_TUPLE_SIZE
);
/* Update if this attribute have a constraint */
if
(
attp
->
attnotnull
)
relation
->
rd_att
->
constr
->
has_not_null
=
true
;
need
--
;
}
pg_attribute_tuple
=
heap_getnext
(
pg_attribute_scan
,
...
...
@@ -567,6 +576,10 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
Relation
attrel
;
HeapTuple
atttup
;
int
i
;
if
(
!
relation
->
rd_att
->
constr
)
relation
->
rd_att
->
constr
=
(
AttrConstr
*
)
palloc
(
sizeof
(
struct
attrConstr
));
relation
->
rd_att
->
constr
->
has_not_null
=
false
;
attrel
=
heap_openr
(
AttributeRelationName
);
...
...
@@ -585,6 +598,10 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo,
memmove
((
char
*
)
(
relation
->
rd_att
->
attrs
[
i
-
1
]),
(
char
*
)
attp
,
ATTRIBUTE_TUPLE_SIZE
);
/* Update if this attribute have a constraint */
if
(
attp
->
attnotnull
)
relation
->
rd_att
->
constr
->
has_not_null
=
true
;
}
heap_close
(
attrel
);
...
...
@@ -1229,7 +1246,9 @@ RelationFlushRelation(Relation *relationPtr,
for
(
i
=
0
;
i
<
relation
->
rd_rel
->
relnatts
;
i
++
,
p
++
)
pfree
(
*
p
);
pfree
(
relation
->
rd_att
->
attrs
);
pfree
(
relation
->
rd_att
);
if
(
relation
->
rd_att
->
constr
)
pfree
(
relation
->
rd_att
->
constr
);
pfree
(
relation
->
rd_att
);
#if 0
if (relation->rd_rules) {
...
...
src/bin/pg_dump/pg_dump.c
View file @
b992e200
...
...
@@ -21,7 +21,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.3
6 1997/07/28 23:53:54 momjian
Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.3
7 1997/08/19 04:44:38 vadim
Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
...
...
@@ -798,6 +798,8 @@ clearTableInfo(TableInfo *tblinfo, int numTables)
if
(
tblinfo
[
i
].
sequence
)
continue
;
if
(
tblinfo
[
i
].
notnull
)
free
(
tblinfo
[
i
].
notnull
);
/* Process Attributes */
for
(
j
=
0
;
j
<
tblinfo
[
i
].
numatts
;
j
++
)
{
if
(
tblinfo
[
i
].
attnames
[
j
])
free
(
tblinfo
[
i
].
attnames
[
j
]);
...
...
@@ -1233,6 +1235,7 @@ getTableAttrs(TableInfo* tblinfo, int numTables)
int
i_attname
;
int
i_typname
;
int
i_attlen
;
int
i_attnotnull
;
PGresult
*
res
;
int
ntups
;
...
...
@@ -1255,7 +1258,7 @@ getTableAttrs(TableInfo* tblinfo, int numTables)
tblinfo
[
i
].
relname
,
g_comment_end
);
sprintf
(
q
,
"SELECT a.attnum, a.attname, t.typname, a.attlen "
sprintf
(
q
,
"SELECT a.attnum, a.attname, t.typname, a.attlen
, a.attnotnull
"
"from pg_attribute a, pg_type t "
"where a.attrelid = '%s'::oid and a.atttypid = t.oid "
"and a.attnum > 0 order by attnum"
,
...
...
@@ -1272,12 +1275,14 @@ getTableAttrs(TableInfo* tblinfo, int numTables)
i_attname
=
PQfnumber
(
res
,
"attname"
);
i_typname
=
PQfnumber
(
res
,
"typname"
);
i_attlen
=
PQfnumber
(
res
,
"attlen"
);
i_attnotnull
=
PQfnumber
(
res
,
"attnotnull"
);
tblinfo
[
i
].
numatts
=
ntups
;
tblinfo
[
i
].
attnames
=
(
char
**
)
malloc
(
ntups
*
sizeof
(
char
*
));
tblinfo
[
i
].
typnames
=
(
char
**
)
malloc
(
ntups
*
sizeof
(
char
*
));
tblinfo
[
i
].
attlen
=
(
int
*
)
malloc
(
ntups
*
sizeof
(
int
));
tblinfo
[
i
].
inhAttrs
=
(
int
*
)
malloc
(
ntups
*
sizeof
(
int
));
tblinfo
[
i
].
notnull
=
(
bool
*
)
malloc
(
ntups
*
sizeof
(
bool
));
tblinfo
[
i
].
parentRels
=
NULL
;
tblinfo
[
i
].
numParents
=
0
;
for
(
j
=
0
;
j
<
ntups
;
j
++
)
{
...
...
@@ -1287,6 +1292,7 @@ getTableAttrs(TableInfo* tblinfo, int numTables)
if
(
tblinfo
[
i
].
attlen
[
j
]
>
0
)
tblinfo
[
i
].
attlen
[
j
]
=
tblinfo
[
i
].
attlen
[
j
]
-
4
;
tblinfo
[
i
].
inhAttrs
[
j
]
=
0
;
/* this flag is set in flagInhAttrs()*/
tblinfo
[
i
].
notnull
[
j
]
=
PQgetvalue
(
res
,
j
,
i_attnotnull
)[
0
]
==
't'
?
true
:
false
;
}
PQclear
(
res
);
}
...
...
@@ -1766,6 +1772,7 @@ void dumpTables(FILE* fout, TableInfo *tblinfo, int numTables,
tblinfo
[
i
].
typnames
[
j
]);
actual_atts
++
;
}
sprintf
(
q
,
"%s%s NULL"
,
q
,
tblinfo
[
i
].
notnull
[
j
]
?
" NOT"
:
""
);
}
}
...
...
src/bin/pg_dump/pg_dump.h
View file @
b992e200
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_dump.h,v 1.1
7 1997/07/23 17:15:13 momjian
Exp $
* $Id: pg_dump.h,v 1.1
8 1997/08/19 04:44:40 vadim
Exp $
*
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
*
...
...
@@ -70,6 +70,7 @@ typedef struct _tableInfo {
an inherited attribute */
char
**
attnames
;
/* the attribute names */
char
**
typnames
;
/* fill out attributes */
bool
*
notnull
;
/* Not null constraints of an attribute */
int
numParents
;
/* number of (immediate) parent supertables */
char
**
parentRels
;
/* names of parent relations, NULL
if numParents == 0 */
...
...
src/bin/psql/psql.c
View file @
b992e200
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.8
2 1997/08/17 00:48:45 scrappy
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.8
3 1997/08/19 04:45:02 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -422,7 +422,7 @@ tableDesc(PsqlSettings * ps, char *table)
table
[
i
]
=
tolower
(
table
[
i
]);
descbuf
[
0
]
=
'\0'
;
strcat
(
descbuf
,
"SELECT a.attnum, a.attname, t.typname, a.attlen"
);
strcat
(
descbuf
,
"SELECT a.attnum, a.attname, t.typname, a.attlen
, a.attnotnull
"
);
strcat
(
descbuf
,
" FROM pg_class c, pg_attribute a, pg_type t "
);
strcat
(
descbuf
,
" WHERE c.relname = '"
);
strcat
(
descbuf
,
table
);
...
...
src/bin/psql/psqlHelp.h
View file @
b992e200
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: psqlHelp.h,v 1.2
0 1997/07/24 19:11:53 momjian
Exp $
* $Id: psqlHelp.h,v 1.2
1 1997/08/19 04:45:04 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -76,7 +76,7 @@ static struct _helpStruct QL_HELP[] = {
"create sequence <sequence_name>
\n\t
[increment <NUMBER>]
\n\t
[start <NUMBER>]
\n\t
[minvalue <NUMBER>]
\n\t
[maxvalue <NUMBER>]
\n\t
[cache <NUMBER>]
\n\t
[cycle];"
},
{
"create table"
,
"create a new table"
,
"create table <class_name> ( <attr1> <type1>,... <attrN> <typeN>)
\n\t
[inherits (<class_name1>,...<class_nameN>
\n\t
archive=<archive_mode>
\n\t
store=<smgr_name>
\n\t
arch_store=<smgr_name>];"
},
"create table <class_name> ( <attr1> <type1>
[[not] null]
,... <attrN> <typeN>)
\n\t
[inherits (<class_name1>,...<class_nameN>
\n\t
archive=<archive_mode>
\n\t
store=<smgr_name>
\n\t
arch_store=<smgr_name>];"
},
{
"create type"
,
"create a new user-defined base data type"
,
"create type <typename> (
\n\t
internallength = (<number> | variable),
\n\t
[externallength = (<number>|variable),]
\n\t
input=<input_function>, output = <output_function>
\n\t
[,element = <typename>][,delimiter=<character>][,default=
\'
<string>
\'
]
\n\t
[,send = <send_function>][,receive = <receive_function>][,passedbyvalue]);"
},
...
...
src/include/access/tupdesc.h
View file @
b992e200
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: tupdesc.h,v 1.
5 1996/11/04 07:45:28 scrappy
Exp $
* $Id: tupdesc.h,v 1.
6 1997/08/19 04:45:20 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -17,6 +17,13 @@
#include <access/attnum.h>
#include <catalog/pg_attribute.h>
typedef
struct
attrConstr
{
/*------------------------------------------------------------------------
This structure contains flags to the constraints of a tuple
------------------------------------------------------------------------*/
bool
has_not_null
;
}
AttrConstr
;
typedef
struct
tupleDesc
{
/*------------------------------------------------------------------------
This structure contains all the attribute information (i.e. from Class
...
...
@@ -26,6 +33,7 @@ typedef struct tupleDesc {
/* Number of attributes in the tuple */
AttributeTupleForm
*
attrs
;
/* attrs[N] is a pointer to the description of Attribute Number N+1. */
AttrConstr
*
constr
;
}
*
TupleDesc
;
extern
TupleDesc
CreateTemplateTupleDesc
(
int
natts
);
...
...
src/include/catalog/pg_attribute.h
View file @
b992e200
This diff is collapsed.
Click to expand it.
src/include/nodes/parsenodes.h
View file @
b992e200
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.1
6 1997/05/22 00:16:13 scrappy
Exp $
* $Id: parsenodes.h,v 1.1
7 1997/08/19 04:46:15 vadim
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -607,6 +607,7 @@ typedef struct ColumnDef {
NodeTag
type
;
char
*
colname
;
/* name of column */
TypeName
*
typename
;
/* type of column */
bool
is_not_null
;
/* flag to NOT NULL constraint */
}
ColumnDef
;
/*
...
...
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