Mysql entry-level series: Client Program 5-MYSQL interactive query program [figure] _ MySQL

Source: Internet
Author: User
Mysql entry-level series: Client Program 5-MYSQL interactive query program [figure] 6.7 client Program 5-Interactive query program

Let's sort out a lot of research so far and write a simple interactive client program. Its functions include entering the query, executing the query with the general target query handler process_query, and displaying the query result with the display format process_result_set () previously studied.

Client Program 5 is similar to mysql in some aspects, although it is still different in several features. Client Program 5 has several constraints on input:

■ Each input line must contain a complete query.

■ The query will not end with a semicolon or 'g.

■ Do not recognize commands similar to quit, but end the program with Control-D. Writing client Program 5 is almost trivial (less than 10 lines of new code ). The client program framework (client4.c) and other written code provide almost everything we need. The only thing we need to add is to collect input rows and execute them in a loop. To build client Program 5, first copy client program framework client4.c to client5.c, and then add the code to process _ query (), process_result_set (), and print_dashes, finally, find the lines marked with the following characters in main () of client5.c:

/* Do the real work here */

Then replace it with the following loop:

Compile client5.c to generate client 5.o, connect client5.c to common. o and client library, and generate client Program 5. this completes all. You have an interactive MySQL client program that can execute any query and display results.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.