My question about the transaction

2023-10-19 Thread Wen Yi
Hi community,
I am learning the transaction of the postgresql, and I try to test using these:


##



terminal 1:



postgres=# select * from t;
number 

 1
(1 row)

postgres=# update t set number = 2;
UPDATE 1
postgres=# select * from t;
number 

 2
(1 row)

postgres=# select * from t;
number 

 2
(1 row)

postgres=# 



##


terminal 2:


postgres=# create table t (number integer);
CREATE TABLE
postgres=# insert into t values (1);
INSERT 0 1
postgres=# begin;
BEGIN
postgres=*# insert into t values (2);
INSERT 0 1
postgres=*# select * from t;
number 

 2
 2
(2 rows)

postgres=*# rollback;
ROLLBACK



My question is, in my view, the transaction model should make sure that when 
one on-process transaction don't commit itself, the data on this transaction 
shouldn't can be modified by other transaction(I the single-statement also be 
treated as a simple transaction), but why the update works?(I think terminal 1 
will block until the terminal 2's transaction commit or rollback).
Can someone share you opinion to me?
Thanks in advance!


Yours,
Wen Yi

[Beginner Question]What should I do if I want to achieve lsm-tree index in postgresql?

2023-09-19 Thread Wen Yi
Hi community,
I am a student and I want to achieve lsm-tree index in postgresql, for my 
database experiment,
I have already read the document of postgresql, and some postgresql's moudle 
source, but I really don't know where to start this work.
Make a new extension like 'https://github.com/HypoPG/hypopg'? Or directly 
change the kernel?

Can someone give me some advice?
Thanks in advance!


Yours,
Wen Yi

Re: A Good Beginner's Book

2023-08-21 Thread Wen Yi
I think the postgresql's document is the best place to learn.











Yours,
WenYi

---Original---
From: "Amn Ojee Uw"

Re:How to solve the warning?

2023-08-07 Thread Wen Yi
Hi,

I check the image you send, I think you pass on a incompatible pointer:
The PostgreSQL want you to pass on a 'List*' but you give a 'Node*'.


And please send plain text next time, the PostgreSQL community archieve always 
just store the patch  plain text.


Yours,
Wen Yi





--Original--
From:   
 "jacktby jacktby"  
  


[Question] Can someone provide the explain of the relation between PGPROC and transaction?

2023-08-07 Thread Wen Yi
Hi Community!
I have already read the comment of the proc.h, read some related question about 
it, and read the "74. Transaction Processing" of the PostgreSQL document.


But I really don't know how the PGPROC works in the transcation?
Can someone provide me some help? Thanks in advance!


Yours,
Wen Yi.

Re:How to build a new grammer for pg?

2023-08-01 Thread Wen Yi
If you want to add some new function to postgresql, just check this ducument:


https://www.postgresql.org/docs/current/extend-how.html




--Original--
From:   
 "jacktby"  
  


Re: Upgrading

2023-07-31 Thread Wen Yi
You can see this document.


https://www.postgresql.org/docs/current/pgupgrade.html










Yours,
WenYi

---Original---
From: "Amn Ojee Uw"

[Question]Can someone explain the context_freelists?

2023-07-31 Thread Wen Yi
In MemoryContext source code:


/* context_freelists[0] is for default params, [1] for small params */
static AllocSetFreeList context_freelists[2] =
{
 {
  0, NULL
 },
 {
  0, NULL
 }
};


I really don't know what this variable mean, can someone share me with your 
view?
Thanks in advance!


Yours,
Wen Yi

logging_collector is off, but the logging is opening

2023-07-26 Thread Wen Yi
Hi community,
When I use the postgres, I check the log.(I use the -l open the log)
As you can see, I type code like this:



postgres=# show logging_collector;
logging_collector 
---
off
(1 row)

postgres=# ^C


Follow the document, when logging_collector is off, there's no log output, but 
when I check my 'postgres' directory:


[postgres@fedora postgres]$ ls
build.sh logfile src startdb.sh stopdb.sh 
update.sh

[postgres@fedora postgres]$ cat logfile
2023-07-24 09:54:59.668 CST [35872] LOG: starting PostgreSQL 17devel on 
x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.1.1 20230614 (Red Hat 13.1.1-4), 
64-bit
2023-07-24 09:54:59.668 CST [35872] LOG: listening on IPv6 address "::1", 
port 5432
2023-07-24 09:54:59.668 CST [35872] LOG: listening on IPv4 address 
"127.0.0.1", port 5432
2023-07-24 09:54:59.684 CST [35872] LOG: listening on Unix socket 
"/tmp/.s.PGSQL.5432"
...


In a word, the log is actually open. (My startup command: pg_ctl -l logfile 
/home/postgres/postgres/bin/bin/pg_ctl -l logfile -D 
/home/postgres/postgres/data start)

So It's confuse me, the confilt of logging_collector  logfile.


Can someone give me some advice?
Thanks in advance!


Yours,
Wen Yi

[Beginner Question]Is there way to test the postgres's kernel function?

2023-07-24 Thread Wen Yi
Hi community,
I am learning the kernel of the postgres, and I want to test the 
make_relative_path function to know what it's operational principle.(I can read 
it's code, and I want to actually run it)
But I really don't know how to do it, wrtite a extension?


Can someone give me some advice?
Thanks in advance!


Yours,
Wen Yi.

\d don't print all the tables

2023-07-24 Thread Wen Yi
Hi community,
here's my shell:



postgres=# \d
Did not find any relations.
postgres=# create schema namespace_a;
CREATE SCHEMA
postgres=# create schema namespace_b;
CREATE SCHEMA
postgres=# create table simple (name varchar);
CREATE TABLE
postgres=# create table namespace_a.simple (name varchar);
CREATE TABLE
postgres=# create table namespace_b.simple (name varchar);
CREATE TABLE
postgres=# \d
 List of relations
Schema | Name | Type | Owner 
++---+--
public | simple | table | postgres
(1 row)

postgres=# 


I think it should print the table on namespace_a  namespace_b, not just 
public, it really confused me.
Can someone give me some advice?



Yours,
Wen Yi.

Re: Reset Postgresql users password

2023-07-17 Thread Wen Yi
I think maybe you can check the pg_hba.conf, change the method to the 'trust'.
(Allow the connection unconditionally. This method allows anyone that can 
connect to the PostgreSQL database server to login as any PostgreSQL user they 
wish, without the need for a password or any other authentication. See 
Section21.4 for details.)



And then login as the root user, after that do the things you wish.



https://www.postgresql.org/docs/current/auth-pg-hba-conf.html





--Original--
From:   
 "Ron"  
  


[Beginner Question]What is query jumbling?

2023-07-17 Thread Wen Yi
Hi community,
I am reading the 'Generate code for query jumbling through gen_node_support.pl' 
(https://www.postgresql.org/message-id/E1pMk51-000puf-55%40gemulon.postgresql.org)
 to understand the principle of the postgres's node, but I really don't know 
the meaning of the word 'query jumbling'.


Can someone provide me some advice?
Thanks in advance!


Yours,
Wen Yi

[Beginner Question] Will the vxid replace xid?

2023-07-12 Thread Wen Yi
Hi community,
When I read the newest document, I find there seems to be a new concept "vxid", 
and It's 64 bit.


Is there a plan to replace xid? Or just my careless?



Can someone give me some advice?
Thanks in advance!


Yours,
Wen Yi

[Beginner Question]What's the use of ResTarget?

2023-07-03 Thread Wen Yi
Hi community
When I read the Internals document (41.1. The Query Tree),
the introduction of the 'the result relation' confuse me.


In the document, it says


 This is an index into the range table that identifies the relation where 
the results of the query go.


And I cheak the corresponding code:



In parsenodes.h (A part)



typedef struct ResTarget
{
 NodeTag  type;
 char  *name; 
  /* column name or NULL */
 List  
*indirection; /* subscripts, field names, and '*', or NIL */
 Node  *val; 
  /* the value expression to compute or 
assign */
 int   
location;  /* token location, or -1 if 
unknown */
} ResTarget;


In gram.y (A part)


insert_column_item:
   ColId opt_indirection
{

 $$ = makeNode(ResTarget);


My question is:


I really don't the the use of ResTarget, in my original understand, I guess the 
use of ResTarget is to store the columns of the result, like:


SELECT row_1, row_2 FROM table;


After the parse, the ResTarget will store the row_1, row_2 in the ResTarget.



But the turth is, it also be used in the another clause, like INSERT, far from 
what I imagined.
So what's the use of ResTarget?



Can someone give me some advice?
Thanks in advance!


Yours,
Wen Yi

Re: [Beginner Question] How to print the call link graph?

2023-07-03 Thread Wen Yi
OK, that helps me a lot.
I just want to get the trace of function call.
Thanks very much!


Yours,
Wen Yi

[Beginner Question] How to print the call link graph?

2023-07-01 Thread Wen Yi
Hi community,
I use the gdb to track the postgres like this:


...

pq_getbyte () at pqcomm.c:980
980 in pqcomm.c
(gdb) next
985 in pqcomm.c
(gdb) next
986 in pqcomm.c
(gdb) next
SocketBackend (inBuf=0x7ffc8f7e1310) at postgres.c:372

372 postgres.c: Directory not empty.
(gdb) next
403 in postgres.c
(gdb) next
406 in postgres.c
(gdb) next
407 in postgres.c
(gdb) next

...


But the question is:
It's too slow to input 'next' to run the postgres, I used to try to use 
the 'continut', but the gdb will run the postgres directly and not print 
the function name and code line


I want to it print like this:


... - pq_getbyte () at pqcomm.c:980 - SocketBackend 
(inBuf=0x7ffc8f7e1310) at postgres.c:372 - ...


Can someone provide me some advice?
Thanks in advance!


Yours,
Wen Yi

A question about the postgres's website

2023-06-26 Thread wen-yi
Hi community,
When I check the postgres's website, I find something confused:



https://www.postgresql.org/community/ (Quick Links: Don't see the slack item)

https://www.postgresql.org/list/ (Quick Links: See the slack item)

Can someone give me some advice?
Thanks in advance!


Yours,
Wen Yi

Re: Why can't lseek the STDIN_FILENO?

2023-06-25 Thread wen-yi
OK, I see, I'm so sorry for my action.
I will ask in cpplang slack community in the future.
And really thanks for your advice.



Your,
Wen Yi





--Original--
From:   
 "John McKown"  
  
https://unix.stackexchange.com/questions/502518/problems-when-test-whether-standard-input-is-capable-of-seeking


The bottom line from the above post is that STDIN is not seekable when it is a 
terminal.

On Fri, Jun 23, 2023, 21:17 Wen Yi <896634...@qq.com wrote:

Hi community,
I am testing the lseek  write  read, and I write the code like this:


/*
 lseek_test.c
  Test the lseek
 Wen Yi
*/
#include 

Why can't lseek the STDIN_FILENO?

2023-06-23 Thread Wen Yi
Hi community,
I am testing the lseek  write  read, and I write the code like this:


/*
 lseek_test.c
  Test the lseek
 Wen Yi
*/
#include 

[Beginner Question]How to let the lex && yacc parsing the string? Instead of the console.

2023-06-19 Thread Wen Yi
Hi community,
When I read the postgres's code,I want to achieve a simple scanner_init, so I 
decided to write a function to analyse the config(Use yacc  lex)
That's means,I need to:


Raw config file - Buffer - Parse(Lex  Yacc) - Complete


Now I write the lex  yacc rule file, but the things confuse me is 
that, they all read from yyin(Always be stdin) and yyout(Always be stdout),
And I want to let them read from string, provide by a function user-defined.
Like this:(That's my design, not true)


int parse(char *string_want_to_analyse)
{
 yacc_init = lex_analyse(string_want_to_analyse);
 yacc_analyse(yacc_init);

}


Can someone provide me some advice?


Yours,
Wen Yi

Re: Is there a way make the lex program match multiple line?

2023-06-17 Thread Wen Yi
I rewrite, and I think the [']([^']|\n)['] should be [']([^']|\n)+[']
Thanks very much!



Yours,
Wen Yi.












--Original--
From:   
 "Tom Lane" 
   


Is there a way make the lex program match multiple line?

2023-06-17 Thread Wen Yi
Hi community,
I am making a config program, use the lex program to analyse input.


/*
 config.l
  The lex rule file for toysql
 Wen Yi
*/
%option noyywrap
%{
#include 

[Beginner Question] Will the backup wal file take too much storage space?

2023-06-13 Thread Wen Yi
Hi community,
When I learn the wal log, a question confuse me.
As you can see, base on the wal, we can restore the database to any check 
point, but sometimes, If we insert a large column to the postgres (Up to 1 GB), 
the postgres will also create a 1 GB wal to store it.
In this situation, will the backup wal file take too much storage space?

Thanks in advance!


Yours,
Wen Yi

Re: How to trace the postgres?

2023-06-13 Thread Wen Yi
That's works,
Thanks very much!


Yours,
Wen Yi











--Original--
From:   
 "Junwang Zhao" 
   


How to trace the postgres?

2023-06-12 Thread Wen Yi
Hi team,
Now I am start to analyse the process of the postgres, using the gdb.
As you can see, at the beginnning of my work, I use the ps to find the 
postgres's process.


[postgres@fedora postgresql]$ ps -ef | grep postgres
postgres 67468 1599 0 08:11 
? 00:00:01 
/home/postgres/pgsql/lib/bin/postgres -D /home/postgres/pgsql/data
postgres 67471 67468 0 08:11 
? 00:00:00 postgres: checkpointer 
postgres 67472 67468 0 08:11 
? 00:00:00 postgres: background 
writer 
postgres 67474 67468 0 08:11 
? 00:00:00 postgres: walwriter 
postgres 67475 67468 0 08:11 
? 00:00:00 postgres: autovacuum 
launcher 
postgres 67476 67468 0 08:11 
? 00:00:00 postgres: logical 
replication launcher 
root 90486 90459 0 14:32 
pts/0 00:00:00 su postgres
postgres 90494 90486 0 14:32 
pts/0 00:00:00 bash
postgres 90526 90494 0 14:32 
pts/0 00:00:00 psql
postgres 90527 67468 0 14:32 
? 00:00:00 postgres: postgres 
postgres [local] idle
root 90680 90652 0 14:33 
pts/2 00:00:00 su postgres
postgres 90683 90680 0 14:33 
pts/2 00:00:00 bash
postgres 90766 90683 0 14:33 
pts/2 00:00:00 ps -ef
postgres 90767 90683 0 14:33 
pts/2 00:00:00 grep --color=auto postgres


After that, I use the gdp to debug one of the postgres's process



[postgres@fedora postgresql]$ gdb -p 67468



WaitEventSetWait (set=0x25221d8, timeout=6, occurred_events=0x7ffe2ea9df70, 
nevents=64, wait_event_info=0) at latch.c:1478
1478 in latch.c
(gdb) next
1480 in latch.c
(gdb) next
1481 in latch.c
(gdb) next
1484 in latch.c
(gdb) next
1487 in latch.c
(gdb) next
1490 in latch.c
(gdb) next
1492 in latch.c
(gdb) next
1493 in latch.c
(gdb) next
1494 in latch.c
(gdb) next
1495 in latch.c
(gdb) next



With the gdb's work, I use the psql to send the query to the postgres.


One thing confuses me is, I really don't know how to trace the postgres's 
process, I try to trace the background writer, the walwriter but I still don't 
know what is them work logical.


I think they seem to work in a loop(I read the related code, that's true), but  
what I want to verify is to identify all the functions and objects  involved in 
the entire process of PGSQL (from syntax parsing to  rewriting, from rewriting 
to optimization, and from optimization to  execution).  


Can someone give me some advice?
Thanks in advance!


Yours,
Wen Yi

Re: What is gcda file?

2023-06-10 Thread Wen Yi
OK, I see.
Thanks very much!



Yours,
Wen Yi


--Original--
From:   
 "David G. Johnston"

https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Gcov-Data-Files.html

Seems like a reasonableanswer to "what it is".

David J.

What is gcda file?

2023-06-10 Thread Wen Yi
ling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/encnames_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/base64_shlib.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-auth.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/pqexpbuffer.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/libpq-events.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/legacy-pqsignal.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-trace.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-secure.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-protocol3.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-print.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-misc.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-lobj.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-exec.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-connect.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/interfaces/libpq/fe-auth-scram.gcda:Skip
_mcleanup: gmon.out: 


Yours,
Wen Yi

Re: initdb can't init the database

2023-06-10 Thread Wen Yi
OK. I find where the problem is, thanks very much!


Yours,
Wen Yi



--Original--
From:   
 "Ian Lawrence Barwick" 
   


initdb can't init the database

2023-06-09 Thread Wen Yi
Hi team,
I use the source to install the postgresql 15.3 (Fedora Linux 37), I create a 
install.sh as this:



install.sh:



sudo rm -r /home/postgres/pgsql 

sudo mkdir /home/postgres/pgsql
sudo rm -r /home/postgres/pgsql/lib 

sudo mkdir /home/postgres/pgsql/lib
./configure --prefix=/home/postgres/pgsql/bin 
--exec-prefix=/home/postgres/pgsql/lib --enable-debug --enable-coverage 
--enable-dtrace --enable-cassert --enable-profiling 

sudo make install
sudo useradd -m postgres 

sudo passwd -d postgres
make clean


Then, I start to execute this shell script:




[beginnerc@bogon postgresql-15.3]$ ./install.sh
[sudo] beginnerc's passwod??
...
[beginnerc@bogon postgresql-15.3]$ su postgres

bash-5.1$ ./initdb
initdb: error: no data directory specified
initdb: hint: You must identify the directory where the data for this database 
system will reside. Do this with either the invocation option -D or the 
environment variable PGDATA.
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/thread.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/strerror.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/snprintf.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/quotes.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pqsignal.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgstrsignal.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgstrcasecmp.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgmkdirp.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/pgcheckdir.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/path.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/chklocale.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/port/strlcpy.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/logging.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/sprompt.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/restricted_token.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/fe_memutils.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/wait_error.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/username.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/stringinfo.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/string.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/rmtree.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/psprintf.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/pgfnames.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/pg_prng.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/pg_get_line.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/kwlookup.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/keywords.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/file_utils.gcda:Skip
profiling:/home/beginnerc/work:Cannot create directory
profiling:/home/beginnerc/work/project/postgresql-15.3/src/common/file_perm.gcda:Skip

Why lex & yacc think this is a syntax error?

2023-06-09 Thread Wen Yi
Hi team,
I am learning the yacc  lex and want to use it to make a config parser, as 
you can see, the config file is following these rules:


key = value


For example:


memory_limit = 512
memory_unit = 'MB'

time_limit = 12
time_unit = 's'



And I make such a yacc  lex rule file:


/*
 config.y
  The yacc rule file to analyse the config 
string
 Wen Yi
*/
%{
#include 

[Question]What will happen if the server active close the connection?

2023-06-04 Thread Wen Yi
Hi team,
when I study the tcp connection, I found that if the server active close the 
connection, the server will send a fin package to the client and the client 
will reply a ack package.
As this:


Server (FIN) Client
Server <(ACK) Client


My question is, in so many articles, the following step is, the client will 
write some data(send some data) to the server and then cause the signal 
SIGNALPIPE.
But what will happen if the client died?(Example: was killed by the user)


Can someone provide some advice?
Thanks in advance!


Yours,
Wen Yi

Re: "pgsql-zh-general" can't send chinese mail.

2023-06-04 Thread Wen Yi
Sorry, it's all my fault, I use error mail-box settings.


Yours,
Wen Yi











--Original--
From:   
 "postgresql439848" 
   
https://www.postgresql.org/list/pgsql-zh-general/since/202306040910

 Can someone provide some solution?
 Thanks in advance!


 Yours,
 Wen Yi

"pgsql-zh-general" can't send chinese mail.

2023-06-04 Thread Wen Yi
Hi team,
I want to use the list "pgsql-zh-general" to communicate with chinese user.
But it can't send chinese mail, because he recognizes all Chinese emails 
as spam.




Can someone provide some solution?
Thanks in advance!


Yours,
Wen Yi

Re: Can't send mail to `pgsql-zh-gene...@lists.postgresql.org`

2023-06-03 Thread Wen Yi
Sure, I subscribe it, and let it send me a test mail.


Yours,
Wen Yi





--Original--
From:   
 "Adrian Klaver"

https://lists.postgresql.org/

 Thanks in advance!
 
 Yours,
 Wen Yi
 
 

-- 
Adrian Klaver
adrian.kla...@aklaver.com

Can't send mail to `pgsql-zh-gene...@lists.postgresql.org`

2023-06-03 Thread Wen Yi
Hi team,

I want to use the `pgsql-zh-gene...@lists.postgresql.org` mail list, and I send 
a test mail to it.


But my mail box told me that my mail was be returned:



host makus.postgresql.org[72.32.157.229] said: 550 This message was classified 
as SPAM (in reply to end of DATA command) 



Can someone provide some advice?
Thanks in advance!



Yours,
Wen Yi

[Beginner Question]A question about yacc & lex

2023-06-01 Thread Wen Yi
Hi team,
now I'm learning the yacc  lex to understand the principle of the 
postgres's parser.
And I write a test program as this:



/*
 array.l
  Array program
 Wen Yi
*/
%option noyywrap
%option noinput

%{
#include 

Is there a bug in psql? (SELECT ''';)

2023-05-31 Thread Wen Yi
Hi team,
when I learn the postgres, I try to store the ' into the database, 

but something unexpected happend.


postgres=# CREATE TABLE test (str varchar);
CREATE TABLE
postgres=# INSERT INTO test values (''');
postgres'# SELECT * FROM test;
postgres'# exit
Use control-D to quit.
postgres'# \q
Use control-D to quit.
postgres'# 
\q
bash-5.1$ 



And I do another test


postgres=# SELECT ''';
postgres'# exit
Use control-D to quit.
postgres'# \q
Use control-D to quit.
postgres'# 
\q
bash-5.1$ 



Is there a bug in psql?


Yours,
Wen Yi

Where I can find the achieve of the 'generate_series' ?

2023-05-29 Thread Wen Yi
Hi team,
I want to figure out the principle of the function 'generate_series', but I 
don't know it contains in which source file.(I download the pgsql 15.3 source 
code)
Can someone provide some advice?
Thanks in advance!


Yours,
Wen Yi

How to make the generate_series to generate the letter series?

2023-05-28 Thread Wen Yi
Hi team,
when I study the generate_series function, I found that it can not only 
generate the number series but also can generate the date series.(ref: 
https://www.postgresql.org/docs/current/functions-srf.html)
That means I can make the generate_series to generate the letter series.


So I try this command (I guess I can follow the ascil code rule to complete 
this work):


# SELECT * FROM generate_series('a'::int, 'z'::int, 1);


But the postgres reply me a error, because the 'a' can't translate into 
'integer' type.


Can someone provide me a better solution?
Thanks in advance!


Yours,
Wen Yi

Re: A question about generate_series

2023-05-28 Thread Wen Yi
Oh, I change my terminal settings (gnome-terminal), it works, thanks very much!
Yours,
Wen Yi




BeginnerC
896634...@qq.com





[Beginner question]How to solve multiple definition of `yylval'?

2023-05-11 Thread Wen Yi
Hi team,
I am studying on the yacc & lex to help me understand the parser of the 
postgres, but now I'm facing some trouble.

---
/*
  1-3.y
*/

%{
#include 
int yylex();
int yyerror(char *s);
typedef char* string;
#define YYSTPYE string
%}
%token NUMBER
%token ADD SUB MUL DIV ABS
%token NEWLINE

%%

calclist: /* Empty rule */
| calclist expression NEWLINE { printf (" = %lf", $2); }
;

expression: factor { $$ = $1; }
| expression ADD factor { $$ = $1 + $3; }
| expression SUB factor { $$ = $1 - $3; }
;

factor: term { $$ = $1; }
| factor MUL term { $$ = $1 * $3; }
| factor DIV term { $$ = $1 / $3; }
;

term: NUMBER  { $$ = $1; }
| ABS term { $$ = $2 > 0 ? $2 : - $2; }

%%

int main(int argc, char *argv[])
{
  yyparse();
}
int yyerror(char *s)
{
  puts(s);
}

-

/*
  1.3.l
Calc Program
  Jing Zhang
*/
%option noyywrap
%option noinput

%{
  #include 
  enum yyTokenType
  {
NUMBER = 258,
ADD,
SUB,
MUL,
DIV,
ABS,
NEWLINE
  };
  double yylval;
%}

%%

"+" { return ADD; }
"-" { return SUB; }
"*" { return MUL; }
"/" { return DIV; }
"|" { return ABS; }
[0-9]+ { yylval = atof (yytext); return NUMBER;}
\n { return NEWLINE; }
[ \t] { ; }
. { ; }
%%

---


When I use the yacc & lex to compile,

yacc -d 1-3.y
lex 1-3.l
gcc 1-3.tab.c lex.yy.c
/usr/bin/ld: /tmp/ccYqqE5N.o:(.bss+0x28): multiple definition of `yylval'; 
/tmp/ccdJ12gy.o:(.bss+0x4): first defined here

Can someone provide me a solution?
Thanks in advance!

Yours,
Jing Zhang.


What type of Compiler to SQL? Memory-Image (Load-and-Go) Format?

2023-05-04 Thread Wen Yi
Hi team,
I am a newbie to the postgres.
When I am studying the compiler,the text book tell me there is there type of 
compiler.

  1.  Assembly Language Format
  2.  Relocatable Binary Format
  3.  Memory-Image (Load-and-Go) Format

I check the postgres's sql compiler, and it's achieved by lex & yacc.
So What type of Compiler to SQL? Is Memory-Image (Load-and-Go) Format ?

Thanks in advance!

Yours,
WenYi


Can one user login in multile machine?

2023-05-03 Thread Wen Yi
Hi team,
can I use same user's information login in multile machines when connect to the 
postgres?
Thanks in advance!

Yours,
Wen Yi.


Why not use the calloc to replace malloc?

2023-04-22 Thread Wen Yi
HI team,
I'm a newbie to the postgres.
When I learn the code of libpq, the achieve of PQmakeEmptyPGresult, cause my  
curiosity.

The old version code:

PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
{
  PGresult   *result;

  result = (PGresult *) malloc(sizeof(PGresult));
  if (!result)
return NULL;

  result->ntups = 0;
  result->numAttributes = 0;
  result->attDescs = NULL;
  result->tuples = NULL;
  result->tupArrSize = 0;
  result->numParameters = 0;
  result->paramDescs = NULL;
  result->resultStatus = status;
  result->cmdStatus[0] = '\0';
  result->binary = 0;
  result->events = NULL;
  result->nEvents = 0;
  result->errMsg = NULL;
  result->errFields = NULL;
  result->errQuery = NULL;
  result->null_field[0] = '\0';
  result->curBlock = NULL;
  result->curOffset = 0;
  result->spaceLeft = 0;
  result->memorySize = sizeof(PGresult);
  /*
.
  */
  return result;
}

My version:

PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
{
  PGresult   *result;

  result = (PGresult *) calloc(sizeof(PGresult));
  if (!result)
return NULL;

  result->memorySize = sizeof(PGresult);
  /*
.
  */
  return result;
}

Why not have a change?I don't know.
I'm a newbie, so I don't think I can commit a patch for postgres, just instead 
of send mail to ask.

Yours,
Wenyi.


Where to find the Makefile.global?

2023-04-21 Thread Wen Yi
Hi team,
I'm a newbie to the postgres and I want to learn the principle of libpq.
When I read the makefile,I can't find the '/src/Makefile.global'
Can someone provide a suggestion?

Yours,
WenYI.


[Beginner Question]How can I use the yacc & lex in right way?

2022-12-09 Thread Wen Yi
Hello the team:
I'm now learning the yacc & lex and want to write a simple SQL parser,
Here's part of my code


%option noyywrap
%option bison-bridge
%option reentrant
...
enum {
UNDEFINED = 1,
CREATE,
TABLE,
UPDATE,
SET,
INSERT,
INTO,
VALUES,
DELETE,
FROM,
SELECT,
GET,
PUT,
EXIST,
USER,
BEGIN,
COMMIT,
ROLLBACK
};
...
[Cc][Rr][Ee][Aa][Tt][Ee] RETURN_TOKEN(CREATE)
[Tt][Aa][Bb][Ll][Ee] RETURN_TOKEN(TABLE)
[Uu][Pp][Dd][Aa][Tt][Ee] RETURN_TOKEN(UPDATE)
[Ss][Ee][Tt] RETURN_TOKEN(SET)
[Ii][Nn][Ss][Ee][Rr][Tt] RETURN_TOKEN(INSERT)
[Ii][Nn][Tt]Oo RETURN_TOKEN(INTO)

As you can see,I want to let the lex recognized the token,but when I compile 
the c code generated by the lex,
some error showed:


[beginnerc@fedora SimpleSQL]$ lex try.l
[beginnerc@fedora SimpleSQL]$ gcc lex.yy.c
lex.yy.c:145:18: error: expected ',' or '}' before '->' token
  145 |  */
  |  ^
try.l:32:5: note: in expansion of macro 'BEGIN'
   32 | BEGIN,
  | ^
lex.yy.c:559:5: error: unknown type name 'YYSTYPE'
  559 |
  | ^
lex.yy.c:606:1: error: unknown type name 'YYSTYPE'; did you mean 'YYSTATE'?
  606 |
  | ^
  | YYSTATE
lex.yy.c:608:19: error: unknown type name 'YYSTYPE'; did you mean 'YYSTATE'?
  608 |
  |   ^
  |   YYSTATE
lex.yy.c:726:17: error: unknown type name 'YYSTYPE'; did you mean 'YYSTATE'?
  726 | extern int yylex \
  | ^~
  | YYSTATE

Can someone give me some advice to fix the error?
Thanks in advance!
Yours,
WenYi.


[BeginnerQuestion]Why the postgres_fe.h not found?

2022-11-25 Thread Wen Yi
Hello everyone,
I want to study the source of the postgres,
but now I faced some problem:
(The lsp server can't find the postgres_fe.h)
[cid:f46601f4-aa60-4ee4-8776-c1d744c9e4a9]

[image.png]

6:54
And the VSCODE also can't find the position of the postgres_fe.h
image.png

[image.png]

6:55
How can I solve this problem?
Thanks in advance!



[Beginner Question]How to generate a call-graph for project?

2022-10-06 Thread Wen Yi
Hi teams,
I am a student who are interested in database,and now I want to generate a 
call-graph for this database that can help me to understand the structure.(The 
project is written in cpp,not only c)
I haved tried the doxygen,but the information that generates is very 
incomplete(Even if I open the extract-all opinion).
How can I achieve it(my system is fedora linux 36)?
Thanks in advance!
Yours,
JingZhang.


[BeginnerQuestion]Why I compile lex.yy.c failed?

2022-09-30 Thread Wen Yi
Hi community,
I am a beginner who are interested in database,when I do my study on the lex 
and yacc,I write a example.l like this:

%%
.\|n ECHO
%%

and then I generate a  lex.yy.c use lex
but when I compile this file,something wrong happend:

[beginnerc@bogon temp]$ flex '/home/beginnerc/work/temp/example.l'
[beginnerc@bogon temp]$ cc lex.yy.c -o first -ll
/home/beginnerc/work/temp/example.l: In function ‘yylex’:
lex.yy.c:619:28: error: expected ‘;’ before ‘break’
  619 | #ifndef YY_BREAK
  |^
/home/beginnerc/work/temp/example.l:3:2: note: in expansion of macro ‘YY_BREAK’
3 | %%
  |  ^
[beginnerc@bogon temp]$

Can some one give me some suggestion?
Thanks in advance!
Yours,
JingZhang.



Re: [Beginner Question]Where can I get the source of hstore?

2022-09-10 Thread Wen Yi
Thank you very much!
Yours,
BeginnerC

获取Outlook for Android<https://aka.ms/AAb9ysg>

From: Tom Lane 
Sent: Sunday, September 11, 2022 10:44:37 AM
To: Wen Yi 
Cc: pgsql-general 
Subject: Re: [Beginner Question]Where can I get the source of hstore?

Wen Yi  writes:
> I want to do some research on the hstore,but I can't find its source.

It's in the Postgres source distribution, under contrib/hstore/

regards, tom lane


[Beginner Question]Where can I get the source of hstore?

2022-09-10 Thread Wen Yi
Hi community,
I want to do some research on the hstore,but I can't find its source.
(My postgres distribution doesn't come with this extension)
I have looked it up in github,but gained nothing.
Can anyone provide me a copy of its code?Or just give a link to me?
Thanks in advance!
Yours,
BeginnerC.


Beginner Question:Why it always make sure that the postgres better than common csv file storage in disaster recovery?

2022-07-03 Thread Wen Yi
I am a student who are interesting in database kernel.When I am 
reviewing my database course,a question make me confused.


In file system,if a error happen when I insert some data into data 
saving system,the whole data exists will be broken and can't recovery 
anymore.


But when I check the code in postgres,I found the postgres also use the 
write function(That! is a UNIX file system api)


My question is:

Since it's all built on top of the file system,why it always make sure 
that the postgres better than common csv file storage in disaster 
recovery?


Thanks in advance!



A error happend when I am clone the git repository

2022-06-19 Thread Wen Yi
When I reinstall my system,I clone the postgresql repository,but there's 
something wrong.
The console print as these:

[beginnerc@fedora Research]$ git clone 
https://git.postgresql.org/git/postgresql.git
Cloning into 'postgresql'...
remote: Enumerating objects: 30747, done.
remote: Counting objects: 100% (30747/30747), done.
remote: Compressing objects: 100% (13431/13431), done.
error: RPC failed; curl 92 HTTP/2 stream 3 was not closed cleanly before end of 
the underlying stream
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

I not clone the repository from github,directly from 
git.postgresql.org
I try it again and again,but failed.
Eventually I have to download the source from the offical website.
My system is Fedora 36 and my git version is 2.36.1
I check the download speed,that is about 220kb/s.

I have ask this problem in the slack group,and now I report this to the mail 
list,please check it,thanks very much!



Simple question from a beginner: Can I use PostgreSQL as a file database?

2021-05-25 Thread Wen Yi
Hi everyone!
I'm a middle student and new to join this mail list.
I just want to ask a simple question:
Can I use PostgreSQL as a file database?
(I plan to make a web system to store my class note with some personal file)
Please give me some suggestions,thank you in advance!