diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index e2914ae..5ed5ded 100644 *** a/src/bin/psql/mainloop.c --- b/src/bin/psql/mainloop.c *************** MainLoop(FILE *source) *** 197,202 **** --- 197,244 ---- continue; } + #define MYSQL_HELP_CHECK(o) \ + (pg_strncasecmp(line, (o), strlen(o)) == 0 &&\ + (line[strlen(o)] == '\0' || line[strlen(o)] == ';' || isspace((unsigned char) line[strlen(o)]))) + + #define MYSQL_HELP_OUTPUT(o) \ + free(line);\ + printf(_("\nPerhaps you want \"" \ + o\ + "\"?\n"\ + "See \\? for help with psql commands\n"));\ + fflush(stdout);\ + continue; + + /* Present the Postgres equivalent common mysqlisms */ + if (pset.cur_cmd_interactive && query_buf->len == 0) + { + if (MYSQL_HELP_CHECK("use")) + { + MYSQL_HELP_OUTPUT("\\c database\" or \"set search_path = schema"); + } + else if (MYSQL_HELP_CHECK("show tables")) + { + MYSQL_HELP_OUTPUT("\\dt"); + } + else if (MYSQL_HELP_CHECK("show databases")) + { + MYSQL_HELP_OUTPUT("\\l"); + } + else if (MYSQL_HELP_CHECK("show processlist")) + { + MYSQL_HELP_OUTPUT("SELECT * FROM pg_stat_activity;"); + } + else if (MYSQL_HELP_CHECK("describe")) + { + MYSQL_HELP_OUTPUT("\\d tablename"); + } + else if (MYSQL_HELP_CHECK("desc")) + { + MYSQL_HELP_OUTPUT("\\d tablename"); + } + } + /* echo back if flag is set */ if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive) puts(line);