Skip to content

Commit fe50382

Browse files
committed
Remove obsolete pg_attrdef.adsrc column
This has been deprecated and effectively unused for a long time. Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
1 parent 8a99f8a commit fe50382

File tree

4 files changed

+4
-31
lines changed

4 files changed

+4
-31
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -947,27 +947,13 @@
947947
<entry><structfield>adbin</structfield></entry>
948948
<entry><type>pg_node_tree</type></entry>
949949
<entry></entry>
950-
<entry>The internal representation of the column default value</entry>
951-
</row>
952-
953-
<row>
954-
<entry><structfield>adsrc</structfield></entry>
955-
<entry><type>text</type></entry>
956-
<entry></entry>
957-
<entry>A human-readable representation of the default value</entry>
950+
<entry>The column default value, in <function>nodeToString()</function>
951+
representation. Use <literal>pg_get_expr(adbin, adrelid)</literal> to
952+
convert it to an SQL expression.</entry>
958953
</row>
959954
</tbody>
960955
</tgroup>
961956
</table>
962-
963-
<para>
964-
The <structfield>adsrc</structfield> field is historical, and is best
965-
not used, because it does not track outside changes that might affect
966-
the representation of the default value. Reverse-compiling the
967-
<structfield>adbin</structfield> field (with <function>pg_get_expr</function> for
968-
example) is a better way to display the default value.
969-
</para>
970-
971957
</sect1>
972958

973959

src/backend/catalog/heap.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,7 +2152,6 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
21522152
Node *expr, bool is_internal, bool add_column_mode)
21532153
{
21542154
char *adbin;
2155-
char *adsrc;
21562155
Relation adrel;
21572156
HeapTuple tuple;
21582157
Datum values[4];
@@ -2169,21 +2168,12 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
21692168
*/
21702169
adbin = nodeToString(expr);
21712170

2172-
/*
2173-
* Also deparse it to form the mostly-obsolete adsrc field.
2174-
*/
2175-
adsrc = deparse_expression(expr,
2176-
deparse_context_for(RelationGetRelationName(rel),
2177-
RelationGetRelid(rel)),
2178-
false, false);
2179-
21802171
/*
21812172
* Make the pg_attrdef entry.
21822173
*/
21832174
values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
21842175
values[Anum_pg_attrdef_adnum - 1] = attnum;
21852176
values[Anum_pg_attrdef_adbin - 1] = CStringGetTextDatum(adbin);
2186-
values[Anum_pg_attrdef_adsrc - 1] = CStringGetTextDatum(adsrc);
21872177

21882178
adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
21892179

@@ -2198,10 +2188,8 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
21982188

21992189
/* now can free some of the stuff allocated above */
22002190
pfree(DatumGetPointer(values[Anum_pg_attrdef_adbin - 1]));
2201-
pfree(DatumGetPointer(values[Anum_pg_attrdef_adsrc - 1]));
22022191
heap_freetuple(tuple);
22032192
pfree(adbin);
2204-
pfree(adsrc);
22052193

22062194
/*
22072195
* Update the pg_attribute entry for the column to show that a default

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201810301
56+
#define CATALOG_VERSION_NO 201811011
5757

5858
#endif

src/include/catalog/pg_attrdef.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
3333

3434
#ifdef CATALOG_VARLEN /* variable-length fields start here */
3535
pg_node_tree adbin BKI_FORCE_NOT_NULL; /* nodeToString representation of default */
36-
text adsrc BKI_FORCE_NOT_NULL; /* human-readable representation of default */
3736
#endif
3837
} FormData_pg_attrdef;
3938

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