• PostgreSQL的 initdb 源代码分析之二


    继续分析

    下面这一段,当 initdb --version 或者  initdb --help 才有意义。

        if (argc > 1)
        {
    
            if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
            {
                usage(progname);
                exit(0);
            }
            if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
            {
                puts("initdb (PostgreSQL) " PG_VERSION);
                exit(0);
            }
        }

    再看下一段:

    实际上就是 initdb 运行时候,后面可以跟各种参数。我这里只考虑 -D那种就好了

        /* process command-line options */
        while ((c = getopt_long(argc, argv, "dD:E:L:nU:WA:sT:X:", long_options, &option_index)) != -1)
        {
            switch (c)
            {
                case 'A':
                    authmethod = xstrdup(optarg);
                    break;
                case 'D':
                    pg_data = xstrdup(optarg);
                    break;
                case 'E':
                    encoding = xstrdup(optarg);
                    break;
                case 'W':
                    pwprompt = true;
                    break;
                case 'U':
                    username = xstrdup(optarg);
                    break;
                case 'd':
                    debug = true;
                    printf(_("Running in debug mode.
    "));
                    break;
                case 'n':
                    noclean = true;
                    printf(_("Running in noclean mode.  Mistakes will not be cleaned up.
    "));
                    break;
                case 'L':
                    share_path = xstrdup(optarg);
                    break;
                case 1:
                    locale = xstrdup(optarg);
                    break;
                case 2:
                    lc_collate = xstrdup(optarg);
                    break;
                case 3:
                    lc_ctype = xstrdup(optarg);
                    break;
                case 4:
                    lc_monetary = xstrdup(optarg);
                    break;
                case 5:
                    lc_numeric = xstrdup(optarg);
                    break;
                case 6:
                    lc_time = xstrdup(optarg);
                    break;
                case 7:
                    lc_messages = xstrdup(optarg);
                    break;
                case 8:
                    locale = "C";
                    break;
                case 9:
                    pwfilename = xstrdup(optarg);
                    break;
                case 's':
                    show_setting = true;
                    break;
                case 'T':
                    default_text_search_config = xstrdup(optarg);
                    break;
                case 'X':
                    xlog_dir = xstrdup(optarg);
                    break;
                default:
                    /* getopt_long already emitted a complaint */
                    fprintf(stderr, _("Try "%s --help" for more information.
    "),
                            progname);
                    exit(1);
            }
        }

    也就是这段:

                case 'D':
                    pg_data = xstrdup(optarg);
                    break;
  • 相关阅读:
    玩转 CSS3 3D 技术
    什么是网站劫持?
    html5 播放 rtsp
    display:none和visibility:hidden两者的区别
    css中div透明度有几种方法设置?
    前端有架构吗?
    HTML a标签打开新标签页避免出现安全漏洞,请使用“noopener”
    写给刚入门的前端工程师的前后端交互指南
    为什么会出现CSS前缀?
    cookies和session得一些理解
  • 原文地址:https://www.cnblogs.com/gaojian/p/3173833.html
Copyright © 2020-2023  润新知