@@ -87,3 +87,92 @@ new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster, bool check_mode)
8787 else
8888 check_ok ();
8989}
90+
91+
92+ /*
93+ * old_9_3_check_for_line_data_type_usage()
94+ * 9.3 -> 9.4
95+ * Fully implement the 'line' data type in 9.4, which previously returned
96+ * "not enabled" by default and was only functionally enabled with a
97+ * compile-time switch; 9.4 "line" has different binary and text
98+ * representation formats; checks tables and indexes.
99+ */
100+ void
101+ old_9_3_check_for_line_data_type_usage (ClusterInfo * cluster )
102+ {
103+ int dbnum ;
104+ FILE * script = NULL ;
105+ bool found = false;
106+ char output_path [MAXPGPATH ];
107+
108+ prep_status ("Checking for invalid \"line\" user columns" );
109+
110+ snprintf (output_path , sizeof (output_path ), "tables_using_line.txt" );
111+
112+ for (dbnum = 0 ; dbnum < cluster -> dbarr .ndbs ; dbnum ++ )
113+ {
114+ PGresult * res ;
115+ bool db_used = false;
116+ int ntups ;
117+ int rowno ;
118+ int i_nspname ,
119+ i_relname ,
120+ i_attname ;
121+ DbInfo * active_db = & cluster -> dbarr .dbs [dbnum ];
122+ PGconn * conn = connectToServer (cluster , active_db -> db_name );
123+
124+ res = executeQueryOrDie (conn ,
125+ "SELECT n.nspname, c.relname, a.attname "
126+ "FROM pg_catalog.pg_class c, "
127+ " pg_catalog.pg_namespace n, "
128+ " pg_catalog.pg_attribute a "
129+ "WHERE c.oid = a.attrelid AND "
130+ " NOT a.attisdropped AND "
131+ " a.atttypid = 'pg_catalog.line'::pg_catalog.regtype AND "
132+ " c.relnamespace = n.oid AND "
133+ /* exclude possible orphaned temp tables */
134+ " n.nspname !~ '^pg_temp_' AND "
135+ " n.nspname !~ '^pg_toast_temp_' AND "
136+ " n.nspname NOT IN ('pg_catalog', 'information_schema')" );
137+
138+ ntups = PQntuples (res );
139+ i_nspname = PQfnumber (res , "nspname" );
140+ i_relname = PQfnumber (res , "relname" );
141+ i_attname = PQfnumber (res , "attname" );
142+ for (rowno = 0 ; rowno < ntups ; rowno ++ )
143+ {
144+ found = true;
145+ if (script == NULL && (script = fopen_priv (output_path , "w" )) == NULL )
146+ pg_fatal ("could not open file \"%s\": %s\n" , output_path , getErrorText (errno ));
147+ if (!db_used )
148+ {
149+ fprintf (script , "Database: %s\n" , active_db -> db_name );
150+ db_used = true;
151+ }
152+ fprintf (script , " %s.%s.%s\n" ,
153+ PQgetvalue (res , rowno , i_nspname ),
154+ PQgetvalue (res , rowno , i_relname ),
155+ PQgetvalue (res , rowno , i_attname ));
156+ }
157+
158+ PQclear (res );
159+
160+ PQfinish (conn );
161+ }
162+
163+ if (script )
164+ fclose (script );
165+
166+ if (found )
167+ {
168+ pg_log (PG_REPORT , "fatal\n" );
169+ pg_fatal ("Your installation contains the \"line\" data type in user tables. This\n"
170+ "data type changed its internal and input/output format between your old\n"
171+ "and new clusters so this cluster cannot currently be upgraded. You can\n"
172+ "remove the problem tables and restart the upgrade. A list of the problem\n"
173+ "columns is in the file:\n"
174+ " %s\n\n" , output_path );
175+ }
176+ else
177+ check_ok ();
178+ }
0 commit comments