![]() |
.. (לתיקייה המכילה) | |
liquidateCompany(): May we liquidate a company which has employees?
| Yes! Not only you may, but you must! |
Can a company's value be a negative value?
| No! For each company: value > 0 |
liquidateLeafCompany(): How should we behave if the company for liquidation owns some shares of other companies?
| Don't liquidate such a company and return E_OWNS. |
I have troubles with passing float values into PQexecParams()/PQexecPrepared().
|
Indeed, there is a bug with passing float values into parametric queries. I propose the following solution: pass string representations of the float values with binary=0 for them or merely print the value into the text of the query Consider the following example: Consider the following code example: extern char *floatToString(float);Note that we pass non-string values as binary. The only exception is float point values, whose string representations are passed. The string representation can be created with floatToString(), whose implementation is given in the fresh version of main.c . Also note how we convert integer values into network byte order. |
האם אנחנו אמורים להדפיס<br/> CONNECTION SUCCESFUL
| No! Please, avoid printing anything out of your implementation. |
אם באחת הפונקציות התקיימו כמה שגיאות במקביל, האם יש להתייחס לעדיפות השגיאות לפי סדר הופעתן בשאלה?
| Yes! The order matters. |
What are functions htonl() and ntohl() used for? Which header does declare them?
|
htonl(): http://pubs.opengroup.org/onlinepubs/7908799/xns/htonl.html ntohl(): http://pubs.opengroup.org/onlinepubs/7908799/xns/ntohl.html In Linux the functions are declared in <arpa/inet.h>. When you send integer values to DB you should convert the byte order with htonl(). When you read integer values from DB you should convert the byte order with ntohl(). We can host the database not necessarily on csl1. The rest is relevant to those who develop in Visual Studio. MSDN has similar wrappers that execute a similar task. But if you include the headers of Windows you might encounter weird compilation errors. I suggest you to avoid converting the byte oder while your implementation runs in Windows, because I guess your DB is running locally on your computer. However, when your implementation runs on Linux, for example, csl1, htonl() and ntohl() should be called. You can insert the following piece of code, which is compilable both under Visual Studio and by gcc: #ifdef _MSC_VER |
Where can I download PostgreSQL for working locally on my computer?
| http://www.postgresql.org/download . Warning: before a submission make sure that your implementation runs smoothly on csl1 . |
Do we have to check NULL pointers passed into the API functions?
| No! We will not pass NULL pointers. |
sellShares(): there is no error specified for the case when there is no person with the id "fromId".
| You do not have to check existence of a person with the given Id. You have to verify that if the person existed, indeed, s/he'd have a sufficient amount of shares to sell. A non-existent person cannot have any shares. Therefore, the error status should be E_INSUFFICIENT. |
Id is unsigned. However, its type is INTEGER in DB. Can we assume that the value of an ID does not exceed INT_MAX?
| Yes! |
You deprecated calling PQExec() when a query depends on external parameters (SQL injection). What would you suggest to use?
|
Consider PQexecParams(), which enables passing parameters separately from the SQL command text. Frequently executed queries should be preferably implemented through prepared statements. Once you prepare a statement with PQprepare() you can call it many times with PQexecPrepared(). Links to the documentations of all the mentioned libpq functions can be found in Links section (look up for "PostgreSQL manuals"), for example: http://www.postgresql.org/docs/8.3/interactive/index.html and http://www.postgresql.org/files/documentation/pdf/8.3/postgresql-8.3-A4.pdf. |
getPureEmployees(): If a person is employed nowhere, should we include him/her in the array?
| No! |
I have PostgreSQL installed on my computer. I wish to work offline.
|
You should do the following: 1. Unzip Tables_hw2.zip . scripts and Tables_hw2 are the directories zipped in Table_hw2.zip . 2. Create a database 3. Create a user. The latter two operations can be done with scripts/createUser <username> <password>4. Grant necessary permissions to the user. It can be done with scripts/alterOwner <username>5. Create tables and initialize them with content. It can be done with: scripts/cur2user <username> Tables_hw2/table_names.txt Tables_hw2Some scripts mention psql. psql is the executable file of installed PostgreSQL. Its directory must be present in $path .As we warned in the assignment description, finally you must check that your implementation runs smoothly on csl1 . |
I cannot log on csl1 from home.
|
Try to log on t2 or tx and log in csl1 from there. For example, you can use ssh: [student@t2]> ssh csl1.cs.technion.ac.il student@csl1's password: .... [student@csl1]> |

