Skip to content

Commit

Permalink
Merge pull request #222 from jcarnu/fix_no_table_in_schema
Browse files Browse the repository at this point in the history
Fix import schema with no table check, no tested yet
  • Loading branch information
GeoffMontee authored Dec 3, 2019
2 parents b70f974 + 26f1a0c commit 818433f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/tds_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -3041,6 +3041,17 @@ tdsImportSqlServerSchema(ImportForeignSchemaStmt *stmt, DBPROCESS *dbproc,
bool first_column = true;
bool first_table = true;

/* Check if there's rows in resultset and if not do not execute the rest */
erc = dbrows(dbproc);

if (erc == FAIL)
{
ereport(NOTICE,
(errmsg("tds_fdw: No table were found in schema %s", stmt->remote_schema))
);
return commands;
}

prev_table[0] = '\0';

erc = dbbind(dbproc, 1, NTBSTRINGBIND, sizeof(table_name), (BYTE *) table_name);
Expand Down Expand Up @@ -3430,6 +3441,16 @@ tdsImportSybaseSchema(ImportForeignSchemaStmt *stmt, DBPROCESS *dbproc,
numeric_scale;
bool first_column = true;
bool first_table = true;
/* Check if there's rows in resultset and if not do not execute the rest */
erc = dbrows(dbproc);

if (erc == FAIL)
{
ereport(NOTICE,
(errmsg("tds_fdw: No table were found in schema %s", stmt->remote_schema))
);
return commands;
}

prev_table[0] = '\0';

Expand Down

0 comments on commit 818433f

Please sign in to comment.