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>
This commit is contained in:
parent
8a99f8a827
commit
fe5038236c
@ -947,27 +947,13 @@
|
|||||||
<entry><structfield>adbin</structfield></entry>
|
<entry><structfield>adbin</structfield></entry>
|
||||||
<entry><type>pg_node_tree</type></entry>
|
<entry><type>pg_node_tree</type></entry>
|
||||||
<entry></entry>
|
<entry></entry>
|
||||||
<entry>The internal representation of the column default value</entry>
|
<entry>The column default value, in <function>nodeToString()</function>
|
||||||
</row>
|
representation. Use <literal>pg_get_expr(adbin, adrelid)</literal> to
|
||||||
|
convert it to an SQL expression.</entry>
|
||||||
<row>
|
|
||||||
<entry><structfield>adsrc</structfield></entry>
|
|
||||||
<entry><type>text</type></entry>
|
|
||||||
<entry></entry>
|
|
||||||
<entry>A human-readable representation of the default value</entry>
|
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<para>
|
|
||||||
The <structfield>adsrc</structfield> field is historical, and is best
|
|
||||||
not used, because it does not track outside changes that might affect
|
|
||||||
the representation of the default value. Reverse-compiling the
|
|
||||||
<structfield>adbin</structfield> field (with <function>pg_get_expr</function> for
|
|
||||||
example) is a better way to display the default value.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
|
||||||
|
@ -2152,7 +2152,6 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
|
|||||||
Node *expr, bool is_internal, bool add_column_mode)
|
Node *expr, bool is_internal, bool add_column_mode)
|
||||||
{
|
{
|
||||||
char *adbin;
|
char *adbin;
|
||||||
char *adsrc;
|
|
||||||
Relation adrel;
|
Relation adrel;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
Datum values[4];
|
Datum values[4];
|
||||||
@ -2169,21 +2168,12 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
|
|||||||
*/
|
*/
|
||||||
adbin = nodeToString(expr);
|
adbin = nodeToString(expr);
|
||||||
|
|
||||||
/*
|
|
||||||
* Also deparse it to form the mostly-obsolete adsrc field.
|
|
||||||
*/
|
|
||||||
adsrc = deparse_expression(expr,
|
|
||||||
deparse_context_for(RelationGetRelationName(rel),
|
|
||||||
RelationGetRelid(rel)),
|
|
||||||
false, false);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make the pg_attrdef entry.
|
* Make the pg_attrdef entry.
|
||||||
*/
|
*/
|
||||||
values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
|
values[Anum_pg_attrdef_adrelid - 1] = RelationGetRelid(rel);
|
||||||
values[Anum_pg_attrdef_adnum - 1] = attnum;
|
values[Anum_pg_attrdef_adnum - 1] = attnum;
|
||||||
values[Anum_pg_attrdef_adbin - 1] = CStringGetTextDatum(adbin);
|
values[Anum_pg_attrdef_adbin - 1] = CStringGetTextDatum(adbin);
|
||||||
values[Anum_pg_attrdef_adsrc - 1] = CStringGetTextDatum(adsrc);
|
|
||||||
|
|
||||||
adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
adrel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
@ -2198,10 +2188,8 @@ StoreAttrDefault(Relation rel, AttrNumber attnum,
|
|||||||
|
|
||||||
/* now can free some of the stuff allocated above */
|
/* now can free some of the stuff allocated above */
|
||||||
pfree(DatumGetPointer(values[Anum_pg_attrdef_adbin - 1]));
|
pfree(DatumGetPointer(values[Anum_pg_attrdef_adbin - 1]));
|
||||||
pfree(DatumGetPointer(values[Anum_pg_attrdef_adsrc - 1]));
|
|
||||||
heap_freetuple(tuple);
|
heap_freetuple(tuple);
|
||||||
pfree(adbin);
|
pfree(adbin);
|
||||||
pfree(adsrc);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the pg_attribute entry for the column to show that a default
|
* Update the pg_attribute entry for the column to show that a default
|
||||||
|
@ -53,6 +53,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 201810301
|
#define CATALOG_VERSION_NO 201811011
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,6 @@ CATALOG(pg_attrdef,2604,AttrDefaultRelationId)
|
|||||||
|
|
||||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
||||||
pg_node_tree adbin BKI_FORCE_NOT_NULL; /* nodeToString representation of default */
|
pg_node_tree adbin BKI_FORCE_NOT_NULL; /* nodeToString representation of default */
|
||||||
text adsrc BKI_FORCE_NOT_NULL; /* human-readable representation of default */
|
|
||||||
#endif
|
#endif
|
||||||
} FormData_pg_attrdef;
|
} FormData_pg_attrdef;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user