@@ -101,9 +101,9 @@ enum FdwModifyPrivateIndex
101101 FdwModifyPrivateUpdateSql ,
102102 /* Integer list of target attribute numbers for INSERT/UPDATE */
103103 FdwModifyPrivateTargetAttnums ,
104- /* Length till the end of VALUES clause (as an integer Value node) */
104+ /* Length till the end of VALUES clause (as an Integer node) */
105105 FdwModifyPrivateLen ,
106- /* has-returning flag (as an integer Value node) */
106+ /* has-returning flag (as an Integer node) */
107107 FdwModifyPrivateHasReturning ,
108108 /* Integer list of attribute numbers retrieved by RETURNING */
109109 FdwModifyPrivateRetrievedAttrs
@@ -122,11 +122,11 @@ enum FdwDirectModifyPrivateIndex
122122{
123123 /* SQL statement to execute remotely (as a String node) */
124124 FdwDirectModifyPrivateUpdateSql ,
125- /* has-returning flag (as an integer Value node) */
125+ /* has-returning flag (as an Integer node) */
126126 FdwDirectModifyPrivateHasReturning ,
127127 /* Integer list of attribute numbers retrieved by RETURNING */
128128 FdwDirectModifyPrivateRetrievedAttrs ,
129- /* set-processed flag (as an integer Value node) */
129+ /* set-processed flag (as an Integer node) */
130130 FdwDirectModifyPrivateSetProcessed
131131};
132132
@@ -280,9 +280,9 @@ typedef struct PgFdwAnalyzeState
280280 */
281281enum FdwPathPrivateIndex
282282{
283- /* has-final-sort flag (as an integer Value node) */
283+ /* has-final-sort flag (as an Integer node) */
284284 FdwPathPrivateHasFinalSort ,
285- /* has-limit flag (as an integer Value node) */
285+ /* has-limit flag (as an Integer node) */
286286 FdwPathPrivateHasLimit
287287};
288288
@@ -5287,45 +5287,41 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
52875287 "SELECT relname, "
52885288 " attname, "
52895289 " format_type(atttypid, atttypmod), "
5290- " attnotnull, " );
5290+ " attnotnull, "
5291+ " pg_get_expr(adbin, adrelid), " );
52915292
52925293 /* Generated columns are supported since Postgres 12 */
52935294 if (PQserverVersion (conn ) >= 120000 )
52945295 appendStringInfoString (& buf ,
5295- " attgenerated, "
5296- " pg_get_expr(adbin, adrelid), " );
5296+ " attgenerated, " );
52975297 else
52985298 appendStringInfoString (& buf ,
5299- " NULL, "
5300- " pg_get_expr(adbin, adrelid), " );
5299+ " NULL, " );
53015300
53025301 if (import_collate )
53035302 appendStringInfoString (& buf ,
53045303 " collname, "
5305- " collnsp.nspname "
5306- "FROM pg_class c "
5307- " JOIN pg_namespace n ON "
5308- " relnamespace = n.oid "
5309- " LEFT JOIN pg_attribute a ON "
5310- " attrelid = c.oid AND attnum > 0 "
5311- " AND NOT attisdropped "
5312- " LEFT JOIN pg_attrdef ad ON "
5313- " adrelid = c.oid AND adnum = attnum "
5304+ " collnsp.nspname " );
5305+ else
5306+ appendStringInfoString (& buf ,
5307+ " NULL, NULL " );
5308+
5309+ appendStringInfoString (& buf ,
5310+ "FROM pg_class c "
5311+ " JOIN pg_namespace n ON "
5312+ " relnamespace = n.oid "
5313+ " LEFT JOIN pg_attribute a ON "
5314+ " attrelid = c.oid AND attnum > 0 "
5315+ " AND NOT attisdropped "
5316+ " LEFT JOIN pg_attrdef ad ON "
5317+ " adrelid = c.oid AND adnum = attnum " );
5318+
5319+ if (import_collate )
5320+ appendStringInfoString (& buf ,
53145321 " LEFT JOIN pg_collation coll ON "
53155322 " coll.oid = attcollation "
53165323 " LEFT JOIN pg_namespace collnsp ON "
53175324 " collnsp.oid = collnamespace " );
5318- else
5319- appendStringInfoString (& buf ,
5320- " NULL, NULL "
5321- "FROM pg_class c "
5322- " JOIN pg_namespace n ON "
5323- " relnamespace = n.oid "
5324- " LEFT JOIN pg_attribute a ON "
5325- " attrelid = c.oid AND attnum > 0 "
5326- " AND NOT attisdropped "
5327- " LEFT JOIN pg_attrdef ad ON "
5328- " adrelid = c.oid AND adnum = attnum " );
53295325
53305326 appendStringInfoString (& buf ,
53315327 "WHERE c.relkind IN ("
@@ -5405,9 +5401,9 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
54055401 attname = PQgetvalue (res , i , 1 );
54065402 typename = PQgetvalue (res , i , 2 );
54075403 attnotnull = PQgetvalue (res , i , 3 );
5408- attgenerated = PQgetisnull (res , i , 4 ) ? (char * ) NULL :
5404+ attdefault = PQgetisnull (res , i , 4 ) ? (char * ) NULL :
54095405 PQgetvalue (res , i , 4 );
5410- attdefault = PQgetisnull (res , i , 5 ) ? (char * ) NULL :
5406+ attgenerated = PQgetisnull (res , i , 5 ) ? (char * ) NULL :
54115407 PQgetvalue (res , i , 5 );
54125408 collname = PQgetisnull (res , i , 6 ) ? (char * ) NULL :
54135409 PQgetvalue (res , i , 6 );
0 commit comments